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 打包
npm run dev 本地运行
npm run preview 本地预览打包完的文件
### 如何添加模块
添加一个子应用至 modules ,子应用首页如下设置说明模块名
...
...
index.html
View file @
9b9fe71d
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<link
rel=
"icon"
href=
"/favicon.ico"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Vite App
</title>
</head>
<body>
<div
id=
"app"
></div>
<script
type=
"module"
src=
"/src/main.js"
></script>
</body>
</html>
<head>
<meta
charset=
"UTF-8"
>
<link
rel=
"icon"
href=
"/favicon.ico"
>
<meta
name=
"x5-cache"
content=
"disable"
/>
<meta
name=
"x5-fullscreen"
content=
"true"
/>
<meta
name=
"full-screen"
content=
"yes"
/>
<meta
content=
"no-cache, no-store, must-revalidate"
http-equiv=
"Cache-Control"
/>
<meta
content=
"no-cache"
http-equiv=
"Pragma"
/>
<meta
content=
"0"
http-equiv=
"Expires"
/>
<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 @@
"name"
:
"komatsu-lease-app"
,
"version"
:
"0.1.0"
,
"scripts"
:
{
"dev"
:
"
VITE_TARGET=ALL
vite "
,
"dev"
:
"vite "
,
"build"
:
"vite build"
,
"preview"
:
"vite preview"
,
"build:selfService"
:
"VITE_TARGET=selfService vite build"
,
"build:intention"
:
"VITE_TARGET=intention vite build"
,
"build:calculator"
:
"VITE_TARGET=calculator vite build"
...
...
src/App.vue
View file @
9b9fe71d
...
...
@@ -32,10 +32,14 @@ export default {
async
mounted
()
{
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
;
route
.
replace
(
jumpRouter
.
path
?
jumpRouter
:
"applications"
);
const
jumpRouter
=
await
login
(
TempAccess
)
this
.
$router
.
push
({
path
:
jumpRouter
.
path
?
jumpRouter
:
"applications"
,
replace
:
true
}
);
}
};
</
script
>
...
...
src/main.js
View file @
9b9fe71d
...
...
@@ -4,14 +4,13 @@ import App from './App.vue'
import
router
from
'./router'
import
moment
from
'moment'
import
{
Notify
,
Toast
}
from
'vant'
;
import
VConsole
from
'vconsole'
moment
.
locale
(
'zh-cn'
)
let
vConsole
if
(
import
.
meta
.
env
.
VITE_DEBUG
===
"true"
)
{
let
vc
=
await
import
(
"vconsole"
);
vConsole
=
new
vc
.
default
();
}
// if (import.meta.env.VITE_DEBUG === "true") {
const
vConsole
=
new
VConsole
();
// }
const
app
=
createApp
(
App
)
...
...
src/router/index.js
View file @
9b9fe71d
...
...
@@ -5,7 +5,7 @@ let realRoutes = routes;
if
(
import
.
meta
.
env
.
PROD
)
{
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
);
...
...
vite.config.js
View file @
9b9fe71d
import
{
fileURLToPath
,
URL
}
from
'node:url'
import
{
defineConfig
}
from
'vite'
import
{
defineConfig
,
loadEnv
}
from
'vite'
import
vue
from
'@vitejs/plugin-vue'
import
legacy
from
'@vitejs/plugin-legacy'
import
Pages
from
'vite-plugin-pages'
...
...
@@ -25,39 +25,55 @@ const loader_pxtovw = pxtovw({
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/
export
default
{
plugins
:
[
vue
({
reactivityTransform
:
true
}),
Pages
({
dirs
:
[
'src/views'
,
'src/modules'
],
extensions
:
[
'vue'
],
exclude
:
[
'**/components/*.vue'
]
}),
legacy
({
targets
:
[
'defaults'
,
'not IE 11'
]
}),
styleImport
({
resolves
:
[
VantResolve
()],
libs
:
[{
libraryName
:
'vant'
,
esModule
:
false
,
resolveStyle
:
(
name
)
=>
`vant/es/
${
name
}
/style/index`
}],
}),
],
css
:
{
postcss
:
{
plugins
:
[
loader_pxtovw
]
}
},
resolve
:
{
alias
:
{
'@'
:
fileURLToPath
(
new
URL
(
'./src'
,
import
.
meta
.
url
))
export
default
({
mode
})
=>
{
let
VITE_TARGET
=
loadEnv
(
mode
,
process
.
cwd
()).
VITE_TARGET
;
return
{
plugins
:
[
vue
({
reactivityTransform
:
true
}),
Pages
(
setRouteConfig
(
VITE_TARGET
)),
legacy
({
targets
:
[
'defaults'
,
'not IE 11'
]
}),
styleImport
({
resolves
:
[
VantResolve
()],
libs
:
[{
libraryName
:
'vant'
,
esModule
:
false
,
resolveStyle
:
(
name
)
=>
`vant/es/
${
name
}
/style/index`
}],
}),
],
css
:
{
postcss
:
{
plugins
:
[
loader_pxtovw
]
}
},
resolve
:
{
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