Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jxf111348
vue-vben-admin
提交
aedb8e53
V
vue-vben-admin
项目概览
jxf111348
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
aedb8e53
编写于
4月 05, 2023
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: 优化env字段
上级
358b77fe
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
38 addition
and
54 deletion
+38
-54
.env
.env
+0
-3
internal/vite-config/package.json
internal/vite-config/package.json
+1
-0
internal/vite-config/src/config/application.ts
internal/vite-config/src/config/application.ts
+1
-1
internal/vite-config/src/plugins/appConfig.ts
internal/vite-config/src/plugins/appConfig.ts
+2
-1
package.json
package.json
+1
-3
pnpm-lock.yaml
pnpm-lock.yaml
+22
-9
src/hooks/setting/index.ts
src/hooks/setting/index.ts
+3
-15
src/utils/env.ts
src/utils/env.ts
+8
-19
types/config.d.ts
types/config.d.ts
+0
-2
types/global.d.ts
types/global.d.ts
+0
-1
未找到文件。
.env
浏览文件 @
aedb8e53
# spa-title
# spa-title
VITE_GLOB_APP_TITLE = Vben Admin
VITE_GLOB_APP_TITLE = Vben Admin
# spa shortname
VITE_GLOB_APP_SHORT_NAME = vue_vben_admin
internal/vite-config/package.json
浏览文件 @
aedb8e53
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
"stub"
:
"pnpm unbuild --stub"
"stub"
:
"pnpm unbuild --stub"
},
},
"dependencies"
:
{
"dependencies"
:
{
"@ant-design/colors"
:
"^7.0.0"
,
"vite"
:
"^4.3.0-beta.1"
"vite"
:
"^4.3.0-beta.1"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
...
...
internal/vite-config/src/config/application.ts
浏览文件 @
aedb8e53
...
@@ -74,7 +74,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
...
@@ -74,7 +74,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
output
:
{
output
:
{
manualChunks
:
{
manualChunks
:
{
vue
:
[
'
vue
'
,
'
pinia
'
,
'
vue-router
'
],
vue
:
[
'
vue
'
,
'
pinia
'
,
'
vue-router
'
],
antd
v
:
[
'
ant-design-vue
'
,
'
@ant-design/icons-vue
'
],
antd
:
[
'
ant-design-vue
'
,
'
@ant-design/icons-vue
'
],
},
},
},
},
},
},
...
...
internal/vite-config/src/plugins/appConfig.ts
浏览文件 @
aedb8e53
...
@@ -26,7 +26,8 @@ async function createAppConfigPlugin({
...
@@ -26,7 +26,8 @@ async function createAppConfigPlugin({
return
{
return
{
name
:
PLUGIN_NAME
,
name
:
PLUGIN_NAME
,
async
configResolved
(
_config
)
{
async
configResolved
(
_config
)
{
const
appTitle
=
_config
?.
env
?.
VITE_GLOB_APP_SHORT_NAME
??
''
;
let
appTitle
=
_config
?.
env
?.
VITE_GLOB_APP_TITLE
??
''
;
appTitle
=
appTitle
.
replace
(
/
\s
/g
,
'
_
'
);
publicPath
=
_config
.
base
;
publicPath
=
_config
.
base
;
source
=
await
getConfigSource
(
appTitle
);
source
=
await
getConfigSource
(
appTitle
);
},
},
...
...
package.json
浏览文件 @
aedb8e53
...
@@ -66,13 +66,10 @@
...
@@ -66,13 +66,10 @@
}
}
},
},
"dependencies"
:
{
"dependencies"
:
{
"
@ant-design/colors
"
:
"
^7.0.0
"
,
"
@ant-design/icons-vue
"
:
"
^6.1.0
"
,
"
@ant-design/icons-vue
"
:
"
^6.1.0
"
,
"
@iconify/iconify
"
:
"
^3.1.0
"
,
"
@iconify/iconify
"
:
"
^3.1.0
"
,
"
@logicflow/core
"
:
"
^1.2.1
"
,
"
@logicflow/core
"
:
"
^1.2.1
"
,
"
@logicflow/extension
"
:
"
^1.2.1
"
,
"
@logicflow/extension
"
:
"
^1.2.1
"
,
"
@vue/runtime-core
"
:
"
^3.2.47
"
,
"
@vue/shared
"
:
"
^3.2.47
"
,
"
@vueuse/core
"
:
"
^9.13.0
"
,
"
@vueuse/core
"
:
"
^9.13.0
"
,
"
@vueuse/shared
"
:
"
^9.13.0
"
,
"
@vueuse/shared
"
:
"
^9.13.0
"
,
"
@zxcvbn-ts/core
"
:
"
^2.2.1
"
,
"
@zxcvbn-ts/core
"
:
"
^2.2.1
"
,
...
@@ -111,6 +108,7 @@
...
@@ -111,6 +108,7 @@
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@commitlint/cli
"
:
"
^17.5.1
"
,
"
@commitlint/cli
"
:
"
^17.5.1
"
,
"
@commitlint/config-conventional
"
:
"
^17.4.4
"
,
"
@iconify/json
"
:
"
^2.2.45
"
,
"
@iconify/json
"
:
"
^2.2.45
"
,
"
@purge-icons/generated
"
:
"
^0.9.0
"
,
"
@purge-icons/generated
"
:
"
^0.9.0
"
,
"
@types/codemirror
"
:
"
^5.60.7
"
,
"
@types/codemirror
"
:
"
^5.60.7
"
,
...
...
pnpm-lock.yaml
浏览文件 @
aedb8e53
...
@@ -4,9 +4,6 @@ importers:
...
@@ -4,9 +4,6 @@ importers:
.
:
.
:
dependencies
:
dependencies
:
'
@ant-design/colors'
:
specifier
:
^7.0.0
version
:
7.0.0
'
@ant-design/icons-vue'
:
'
@ant-design/icons-vue'
:
specifier
:
^6.1.0
specifier
:
^6.1.0
version
:
6.1.0(vue@3.2.47)
version
:
6.1.0(vue@3.2.47)
...
@@ -19,12 +16,6 @@ importers:
...
@@ -19,12 +16,6 @@ importers:
'
@logicflow/extension'
:
'
@logicflow/extension'
:
specifier
:
^1.2.1
specifier
:
^1.2.1
version
:
1.2.1
version
:
1.2.1
'
@vue/runtime-core'
:
specifier
:
^3.2.47
version
:
3.2.47
'
@vue/shared'
:
specifier
:
^3.2.47
version
:
3.2.47
'
@vueuse/core'
:
'
@vueuse/core'
:
specifier
:
^9.13.0
specifier
:
^9.13.0
version
:
9.13.0(vue@3.2.47)
version
:
9.13.0(vue@3.2.47)
...
@@ -134,6 +125,9 @@ importers:
...
@@ -134,6 +125,9 @@ importers:
'
@commitlint/cli'
:
'
@commitlint/cli'
:
specifier
:
^17.5.1
specifier
:
^17.5.1
version
:
17.5.1
version
:
17.5.1
'
@commitlint/config-conventional'
:
specifier
:
^17.4.4
version
:
17.4.4
'
@iconify/json'
:
'
@iconify/json'
:
specifier
:
^2.2.45
specifier
:
^2.2.45
version
:
2.2.45
version
:
2.2.45
...
@@ -378,6 +372,9 @@ importers:
...
@@ -378,6 +372,9 @@ importers:
internal/vite-config
:
internal/vite-config
:
dependencies
:
dependencies
:
'
@ant-design/colors'
:
specifier
:
^7.0.0
version
:
7.0.0
vite
:
vite
:
specifier
:
^4.3.0-beta.1
specifier
:
^4.3.0-beta.1
version
:
4.3.0-beta.1(@types/node@18.15.11)(less@4.1.3)(sass@1.60.0)
version
:
4.3.0-beta.1(@types/node@18.15.11)(less@4.1.3)(sass@1.60.0)
...
@@ -791,6 +788,13 @@ packages:
...
@@ -791,6 +788,13 @@ packages:
-
'
@swc/wasm'
-
'
@swc/wasm'
dev
:
true
dev
:
true
/@commitlint/config-conventional@17.4.4
:
resolution
:
{
integrity
:
sha512-u6ztvxqzi6NuhrcEDR7a+z0yrh11elY66nRrQIpqsqW6sZmpxYkDLtpRH8jRML+mmxYQ8s4qqF06Q/IQx5aJeQ==
}
engines
:
{
node
:
'
>=v14'
}
dependencies
:
conventional-changelog-conventionalcommits
:
5.0.0
dev
:
true
/@commitlint/config-validator@17.4.4
:
/@commitlint/config-validator@17.4.4
:
resolution
:
{
integrity
:
sha512-bi0+TstqMiqoBAQDvdEP4AFh0GaKyLFlPPEObgI29utoKEYoPQTvF0EYqIwYYLEoJYhj5GfMIhPHJkTJhagfeg==
}
resolution
:
{
integrity
:
sha512-bi0+TstqMiqoBAQDvdEP4AFh0GaKyLFlPPEObgI29utoKEYoPQTvF0EYqIwYYLEoJYhj5GfMIhPHJkTJhagfeg==
}
engines
:
{
node
:
'
>=v14'
}
engines
:
{
node
:
'
>=v14'
}
...
@@ -3176,6 +3180,15 @@ packages:
...
@@ -3176,6 +3180,15 @@ packages:
q
:
1.5.1
q
:
1.5.1
dev
:
true
dev
:
true
/conventional-changelog-conventionalcommits@5.0.0
:
resolution
:
{
integrity
:
sha512-lCDbA+ZqVFQGUj7h9QBKoIpLhl8iihkO0nCTyRNzuXtcd7ubODpYB04IFy31JloiJgG0Uovu8ot8oxRzn7Nwtw==
}
engines
:
{
node
:
'
>=10'
}
dependencies
:
compare-func
:
2.0.0
lodash
:
4.17.21
q
:
1.5.1
dev
:
true
/conventional-commits-parser@3.2.4
:
/conventional-commits-parser@3.2.4
:
resolution
:
{
integrity
:
sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q==
}
resolution
:
{
integrity
:
sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q==
}
engines
:
{
node
:
'
>=10'
}
engines
:
{
node
:
'
>=10'
}
...
...
src/hooks/setting/index.ts
浏览文件 @
aedb8e53
import
type
{
GlobConfig
}
from
'
/#/config
'
;
import
type
{
GlobConfig
}
from
'
/#/config
'
;
import
{
warn
}
from
'
/@/utils/log
'
;
import
{
getAppEnvConfig
}
from
'
/@/utils/env
'
;
import
{
getAppEnvConfig
}
from
'
/@/utils/env
'
;
export
const
useGlobSetting
=
():
Readonly
<
GlobConfig
>
=>
{
export
const
useGlobSetting
=
():
Readonly
<
GlobConfig
>
=>
{
const
{
const
{
VITE_GLOB_APP_TITLE
,
VITE_GLOB_API_URL
,
VITE_GLOB_API_URL_PREFIX
,
VITE_GLOB_UPLOAD_URL
}
=
VITE_GLOB_APP_TITLE
,
getAppEnvConfig
();
VITE_GLOB_API_URL
,
VITE_GLOB_APP_SHORT_NAME
,
VITE_GLOB_API_URL_PREFIX
,
VITE_GLOB_UPLOAD_URL
,
}
=
getAppEnvConfig
();
if
(
!
/
[
a-zA-Z_
]
*/
.
test
(
VITE_GLOB_APP_SHORT_NAME
))
{
warn
(
`VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`
,
);
}
// Take global configuration
// Take global configuration
const
glob
:
Readonly
<
GlobConfig
>
=
{
const
glob
:
Readonly
<
GlobConfig
>
=
{
title
:
VITE_GLOB_APP_TITLE
,
title
:
VITE_GLOB_APP_TITLE
,
apiUrl
:
VITE_GLOB_API_URL
,
apiUrl
:
VITE_GLOB_API_URL
,
shortName
:
VITE_GLOB_APP_
SHORT_NAME
,
shortName
:
VITE_GLOB_APP_
TITLE
.
replace
(
/
\s
/g
,
'
_
'
)
,
urlPrefix
:
VITE_GLOB_API_URL_PREFIX
,
urlPrefix
:
VITE_GLOB_API_URL_PREFIX
,
uploadUrl
:
VITE_GLOB_UPLOAD_URL
,
uploadUrl
:
VITE_GLOB_UPLOAD_URL
,
};
};
...
...
src/utils/env.ts
浏览文件 @
aedb8e53
import
type
{
GlobEnvConfig
}
from
'
/#/config
'
;
import
type
{
GlobEnvConfig
}
from
'
/#/config
'
;
import
{
warn
}
from
'
/@/utils/log
'
;
import
pkg
from
'
../../package.json
'
;
import
pkg
from
'
../../package.json
'
;
const
getVariableName
=
(
title
:
string
)
=>
{
const
getVariableName
=
(
title
:
string
)
=>
{
return
`__PRODUCTION__
${
title
||
'
__APP
'
}
__CONF__`
.
toUpperCase
().
replace
(
/
\s
/g
,
''
);
return
`__PRODUCTION__
${
title
.
replace
(
/
\s
/g
,
'
_
'
)
||
'
__APP
'
}
__CONF__`
.
toUpperCase
()
.
replace
(
/
\s
/g
,
''
);
};
};
export
function
getCommonStoragePrefix
()
{
export
function
getCommonStoragePrefix
()
{
const
{
VITE_GLOB_APP_
SHORT_NAM
E
}
=
getAppEnvConfig
();
const
{
VITE_GLOB_APP_
TITL
E
}
=
getAppEnvConfig
();
return
`
${
VITE_GLOB_APP_
SHORT_NAME
}
__
${
getEnv
()}
`
.
toUpperCase
();
return
`
${
VITE_GLOB_APP_
TITLE
.
replace
(
/
\s
/g
,
'
_
'
)
}
__
${
getEnv
()}
`
.
toUpperCase
();
}
}
// Generate cache key according to version
// Generate cache key according to version
...
@@ -18,31 +19,19 @@ export function getStorageShortName() {
...
@@ -18,31 +19,19 @@ export function getStorageShortName() {
}
}
export
function
getAppEnvConfig
()
{
export
function
getAppEnvConfig
()
{
const
ENV_NAME
=
getVariableName
(
import
.
meta
.
env
.
VITE_GLOB_APP_
SHORT_NAM
E
);
const
ENV_NAME
=
getVariableName
(
import
.
meta
.
env
.
VITE_GLOB_APP_
TITL
E
);
const
ENV
=
(
import
.
meta
.
env
.
DEV
const
ENV
=
(
import
.
meta
.
env
.
DEV
?
// Get the global configuration (the configuration will be extracted independently when packaging)
?
// Get the global configuration (the configuration will be extracted independently when packaging)
(
import
.
meta
.
env
as
unknown
as
GlobEnvConfig
)
(
import
.
meta
.
env
as
unknown
as
GlobEnvConfig
)
:
window
[
ENV_NAME
as
any
])
as
unknown
as
GlobEnvConfig
;
:
window
[
ENV_NAME
as
any
])
as
unknown
as
GlobEnvConfig
;
const
{
const
{
VITE_GLOB_APP_TITLE
,
VITE_GLOB_API_URL
,
VITE_GLOB_API_URL_PREFIX
,
VITE_GLOB_UPLOAD_URL
}
=
VITE_GLOB_APP_TITLE
,
ENV
;
VITE_GLOB_API_URL
,
VITE_GLOB_APP_SHORT_NAME
,
VITE_GLOB_API_URL_PREFIX
,
VITE_GLOB_UPLOAD_URL
,
}
=
ENV
;
if
(
!
/^
[
a-zA-Z_
]
*$/
.
test
(
VITE_GLOB_APP_SHORT_NAME
))
{
warn
(
`VITE_GLOB_APP_SHORT_NAME Variables can only be characters/underscores, please modify in the environment variables and re-running.`
,
);
}
return
{
return
{
VITE_GLOB_APP_TITLE
,
VITE_GLOB_APP_TITLE
,
VITE_GLOB_API_URL
,
VITE_GLOB_API_URL
,
VITE_GLOB_APP_SHORT_NAME
,
VITE_GLOB_API_URL_PREFIX
,
VITE_GLOB_API_URL_PREFIX
,
VITE_GLOB_UPLOAD_URL
,
VITE_GLOB_UPLOAD_URL
,
};
};
...
...
types/config.d.ts
浏览文件 @
aedb8e53
...
@@ -155,8 +155,6 @@ export interface GlobEnvConfig {
...
@@ -155,8 +155,6 @@ export interface GlobEnvConfig {
VITE_GLOB_API_URL
:
string
;
VITE_GLOB_API_URL
:
string
;
// Service interface url prefix
// Service interface url prefix
VITE_GLOB_API_URL_PREFIX
?:
string
;
VITE_GLOB_API_URL_PREFIX
?:
string
;
// Project abbreviation
VITE_GLOB_APP_SHORT_NAME
:
string
;
// Upload url
// Upload url
VITE_GLOB_UPLOAD_URL
?:
string
;
VITE_GLOB_UPLOAD_URL
?:
string
;
}
}
types/global.d.ts
浏览文件 @
aedb8e53
...
@@ -61,7 +61,6 @@ declare global {
...
@@ -61,7 +61,6 @@ declare global {
VITE_PUBLIC_PATH
:
string
;
VITE_PUBLIC_PATH
:
string
;
VITE_PROXY
:
[
string
,
string
][];
VITE_PROXY
:
[
string
,
string
][];
VITE_GLOB_APP_TITLE
:
string
;
VITE_GLOB_APP_TITLE
:
string
;
VITE_GLOB_APP_SHORT_NAME
:
string
;
VITE_BUILD_COMPRESS
:
'
gzip
'
|
'
brotli
'
|
'
none
'
;
VITE_BUILD_COMPRESS
:
'
gzip
'
|
'
brotli
'
|
'
none
'
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录