Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
komatsu-lease-app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
komatsu
komatsu-lease-app
Commits
9b9fe71d
Commit
9b9fe71d
authored
Dec 01, 2022
by
Step_by_step
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 支持按需打包
parent
10f2c2c8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
87 additions
and
54 deletions
+87
-54
README.md
README.md
+2
-0
index.html
index.html
+22
-11
package.json
package.json
+2
-1
App.vue
src/App.vue
+7
-3
main.js
src/main.js
+4
-5
index.js
src/router/index.js
+1
-1
vite.config.js
vite.config.js
+49
-33
www.zip
www.zip
+0
-0
No files found.
README.md
View file @
9b9fe71d
...
@@ -4,6 +4,8 @@ npm run build 打包
...
@@ -4,6 +4,8 @@ npm run build 打包
npm run dev 本地运行
npm run dev 本地运行
npm run preview 本地预览打包完的文件
### 如何添加模块
### 如何添加模块
添加一个子应用至 modules ,子应用首页如下设置说明模块名
添加一个子应用至 modules ,子应用首页如下设置说明模块名
...
...
index.html
View file @
9b9fe71d
<!DOCTYPE html>
<!DOCTYPE html>
<html
lang=
"en"
>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<head>
<link
rel=
"icon"
href=
"/favicon.ico"
>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"icon"
href=
"/favicon.ico"
>
<title>
Vite App
</title>
<meta
name=
"x5-cache"
content=
"disable"
/>
</head>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<body>
<meta
name=
"full-screen"
content=
"yes"
/>
<div
id=
"app"
></div>
<meta
content=
"no-cache, no-store, must-revalidate"
http-equiv=
"Cache-Control"
/>
<script
type=
"module"
src=
"/src/main.js"
></script>
<meta
content=
"no-cache"
http-equiv=
"Pragma"
/>
</body>
<meta
content=
"0"
http-equiv=
"Expires"
/>
</html>
<meta
http-equiv=
"expires"
content=
"0"
/>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,viewport-fit=cover"
>
<title>
Vite App
</title>
</head>
<body>
<div
id=
"app"
></div>
<script
type=
"module"
src=
"/src/main.js"
></script>
</body>
</html>
\ No newline at end of file
package.json
View file @
9b9fe71d
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
"name"
:
"komatsu-lease-app"
,
"name"
:
"komatsu-lease-app"
,
"version"
:
"0.1.0"
,
"version"
:
"0.1.0"
,
"scripts"
:
{
"scripts"
:
{
"dev"
:
"
VITE_TARGET=ALL
vite "
,
"dev"
:
"vite "
,
"build"
:
"vite build"
,
"build"
:
"vite build"
,
"preview"
:
"vite preview"
,
"build:selfService"
:
"VITE_TARGET=selfService vite build"
,
"build:selfService"
:
"VITE_TARGET=selfService vite build"
,
"build:intention"
:
"VITE_TARGET=intention vite build"
,
"build:intention"
:
"VITE_TARGET=intention vite build"
,
"build:calculator"
:
"VITE_TARGET=calculator vite build"
"build:calculator"
:
"VITE_TARGET=calculator vite build"
...
...
src/App.vue
View file @
9b9fe71d
...
@@ -32,10 +32,14 @@ export default {
...
@@ -32,10 +32,14 @@ export default {
async
mounted
()
{
async
mounted
()
{
const
TempAccess
=
import
.
meta
.
env
.
DEV
?
'60243b9f-5f2b-41f8-8007-67984b5ae1cd'
:
''
const
TempAccess
=
import
.
meta
.
env
.
DEV
?
'60243b9f-5f2b-41f8-8007-67984b5ae1cd'
:
''
const
jumpRouter
=
await
login
(
TempAccess
)
if
(
import
.
meta
.
env
.
PROD
)
{
let
index
=
this
.
$router
.
getRoutes
().
filter
(
route
=>
route
.
meta
.
title
)
this
.
$router
.
push
({
path
:
index
[
0
].
path
,
replace
:
true
});
return
;
}
const
route
=
this
.
$router
;
const
jumpRouter
=
await
login
(
TempAccess
)
route
.
replace
(
jumpRouter
.
path
?
jumpRouter
:
"applications"
);
this
.
$router
.
push
({
path
:
jumpRouter
.
path
?
jumpRouter
:
"applications"
,
replace
:
true
}
);
}
}
};
};
</
script
>
</
script
>
...
...
src/main.js
View file @
9b9fe71d
...
@@ -4,14 +4,13 @@ import App from './App.vue'
...
@@ -4,14 +4,13 @@ import App from './App.vue'
import
router
from
'./router'
import
router
from
'./router'
import
moment
from
'moment'
import
moment
from
'moment'
import
{
Notify
,
Toast
}
from
'vant'
;
import
{
Notify
,
Toast
}
from
'vant'
;
import
VConsole
from
'vconsole'
moment
.
locale
(
'zh-cn'
)
moment
.
locale
(
'zh-cn'
)
let
vConsole
// if (import.meta.env.VITE_DEBUG === "true") {
if
(
import
.
meta
.
env
.
VITE_DEBUG
===
"true"
)
{
const
vConsole
=
new
VConsole
();
let
vc
=
await
import
(
"vconsole"
);
// }
vConsole
=
new
vc
.
default
();
}
const
app
=
createApp
(
App
)
const
app
=
createApp
(
App
)
...
...
src/router/index.js
View file @
9b9fe71d
...
@@ -5,7 +5,7 @@ let realRoutes = routes;
...
@@ -5,7 +5,7 @@ let realRoutes = routes;
if
(
import
.
meta
.
env
.
PROD
)
{
if
(
import
.
meta
.
env
.
PROD
)
{
let
reg
=
new
RegExp
(
`
${
import
.
meta
.
env
.
VITE_TARGET
}
`
);
let
reg
=
new
RegExp
(
`
${
import
.
meta
.
env
.
VITE_TARGET
}
`
);
realRoutes
=
realRoutes
.
filter
((
route
)
=>
reg
.
test
(
route
.
path
))
realRoutes
=
realRoutes
.
filter
((
route
)
=>
reg
.
test
(
route
.
name
))
}
}
console
.
info
(
'已渲染路由--'
,
realRoutes
);
console
.
info
(
'已渲染路由--'
,
realRoutes
);
...
...
vite.config.js
View file @
9b9fe71d
import
{
fileURLToPath
,
URL
}
from
'node:url'
import
{
fileURLToPath
,
URL
}
from
'node:url'
import
{
defineConfig
}
from
'vite'
import
{
defineConfig
,
loadEnv
}
from
'vite'
import
vue
from
'@vitejs/plugin-vue'
import
vue
from
'@vitejs/plugin-vue'
import
legacy
from
'@vitejs/plugin-legacy'
import
legacy
from
'@vitejs/plugin-legacy'
import
Pages
from
'vite-plugin-pages'
import
Pages
from
'vite-plugin-pages'
...
@@ -25,39 +25,55 @@ const loader_pxtovw = pxtovw({
...
@@ -25,39 +25,55 @@ const loader_pxtovw = pxtovw({
landscapeWidth
:
568
landscapeWidth
:
568
})
})
const
setRouteConfig
=
(
VITE_TARGET
)
=>
{
let
dirs
=
[
'src/views'
,
'src/modules'
]
if
(
VITE_TARGET
)
{
dirs
=
[{
dir
:
`src/modules/
${
VITE_TARGET
}
`
,
baseRoute
:
VITE_TARGET
}]
}
return
{
dirs
,
extensions
:
[
'vue'
],
exclude
:
[
'**/components/*.vue'
]
}
}
// https://vitejs.dev/config/
// https://vitejs.dev/config/
export
default
{
export
default
({
mode
})
=>
{
plugins
:
[
let
VITE_TARGET
=
loadEnv
(
mode
,
process
.
cwd
()).
VITE_TARGET
;
vue
({
reactivityTransform
:
true
}),
return
{
Pages
({
plugins
:
[
dirs
:
[
'src/views'
,
'src/modules'
],
vue
({
reactivityTransform
:
true
}),
extensions
:
[
'vue'
],
Pages
(
setRouteConfig
(
VITE_TARGET
)),
exclude
:
[
'**/components/*.vue'
]
legacy
({
}),
targets
:
[
'defaults'
,
'not IE 11'
]
legacy
({
}),
targets
:
[
'defaults'
,
'not IE 11'
]
styleImport
({
}),
resolves
:
[
VantResolve
()],
styleImport
({
libs
:
[{
resolves
:
[
VantResolve
()],
libraryName
:
'vant'
,
libs
:
[{
esModule
:
false
,
libraryName
:
'vant'
,
resolveStyle
:
(
name
)
=>
`vant/es/
${
name
}
/style/index`
esModule
:
false
,
}],
resolveStyle
:
(
name
)
=>
`vant/es/
${
name
}
/style/index`
}),
}],
],
}),
css
:
{
],
postcss
:
{
css
:
{
plugins
:
[
loader_pxtovw
]
postcss
:
{
}
plugins
:
[
loader_pxtovw
]
},
}
resolve
:
{
},
alias
:
{
resolve
:
{
'@'
:
fileURLToPath
(
new
URL
(
'./src'
,
import
.
meta
.
url
))
alias
:
{
}
'@'
:
fileURLToPath
(
new
URL
(
'./src'
,
import
.
meta
.
url
))
},
server
:
{
host
:
'0.0.0.0'
,
port
:
5678
},
build
:
{
outDir
:
`dist/
${
VITE_TARGET
}
`
}
}
},
server
:
{
host
:
'0.0.0.0'
,
port
:
5678
}
}
}
}
www.zip
deleted
100644 → 0
View file @
10f2c2c8
File deleted
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment