Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Dr.Disrespect
vue-vben-admin
提交
b476e1c8
V
vue-vben-admin
项目概览
Dr.Disrespect
/
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 搜索 >>
提交
b476e1c8
编写于
3月 01, 2021
作者:
V
Vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: ensure that the correct components are dynamically imported
上级
3b8ca420
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
32 addition
and
5 deletion
+32
-5
.env
.env
+3
-0
build/utils.ts
build/utils.ts
+1
-0
src/router/helper/routeHelper.ts
src/router/helper/routeHelper.ts
+17
-3
src/settings/projectSetting.ts
src/settings/projectSetting.ts
+1
-1
types/window.d.ts
types/window.d.ts
+1
-0
vite.config.ts
vite.config.ts
+9
-1
未找到文件。
.env
浏览文件 @
b476e1c8
...
...
@@ -6,3 +6,6 @@ VITE_GLOB_APP_TITLE = Vben Admin
# spa shortname
VITE_GLOB_APP_SHORT_NAME = vue_vben_admin
VITE_DYNAMIC_IMPORT = false
build/utils.ts
浏览文件 @
b476e1c8
...
...
@@ -30,6 +30,7 @@ export interface ViteEnv {
VITE_BUILD_COMPRESS
:
'
gzip
'
|
'
brotli
'
|
'
none
'
;
VITE_LEGACY
:
boolean
;
VITE_USE_IMAGEMIN
:
boolean
;
VITE_DYNAMIC_IMPORT
:
boolean
;
}
// Read all environment variable configuration files to process.env
...
...
src/router/helper/routeHelper.ts
浏览文件 @
b476e1c8
...
...
@@ -9,10 +9,22 @@ export type LayoutMapKey = 'LAYOUT';
const
LayoutMap
=
new
Map
<
LayoutMapKey
,
()
=>
Promise
<
typeof
import
(
'
*.vue
'
)
>>
();
const
dynamicViewsModules
=
import
.
meta
.
glob
(
'
../../views/**/*.{vue,tsx}
'
);
let
dynamicViewsModules
:
Record
<
string
,
()
=>
Promise
<
{
[
key
:
string
]:
any
;
}
>
>
;
// 动态引入
function
asyncImportRoute
(
routes
:
AppRouteRecordRaw
[]
|
undefined
)
{
// TODO It may be a bug in Vite. When the conditions are not established, the dynamically imported files will still be packaged in.
if
(
!
__DYNAMIC_IMPORT__
)
{
dynamicViewsModules
=
{};
}
else
{
dynamicViewsModules
=
dynamicViewsModules
||
import
.
meta
.
glob
(
'
../../views/**/*.{vue,tsx}
'
);
}
if
(
!
routes
)
return
;
routes
.
forEach
((
item
)
=>
{
const
{
component
,
name
}
=
item
;
...
...
@@ -37,8 +49,10 @@ function dynamicImport(
)
{
const
keys
=
Object
.
keys
(
dynamicViewsModules
);
const
matchKeys
=
keys
.
filter
((
key
)
=>
{
const
k
=
key
.
replace
(
'
../../views
'
,
''
);
return
k
.
startsWith
(
`
${
component
}
`
)
||
k
.
startsWith
(
`/
${
component
}
`
);
let
k
=
key
.
replace
(
'
../../views
'
,
''
);
const
lastIndex
=
k
.
lastIndexOf
(
'
.
'
);
k
=
k
.
substring
(
0
,
lastIndex
);
return
k
===
component
;
});
if
(
matchKeys
?.
length
===
1
)
{
const
matchKey
=
matchKeys
[
0
];
...
...
src/settings/projectSetting.ts
浏览文件 @
b476e1c8
...
...
@@ -19,7 +19,7 @@ const setting: ProjectConfig = {
settingButtonPosition
:
SettingButtonPositionEnum
.
AUTO
,
// Permission mode
permissionMode
:
PermissionModeEnum
.
ROLE
,
permissionMode
:
PermissionModeEnum
.
BACK
,
// Permission-related cache is stored in sessionStorage or localStorage
permissionCacheType
:
CacheTypeEnum
.
SESSION
,
...
...
types/window.d.ts
浏览文件 @
b476e1c8
import
type
{
App
}
from
'
vue
'
;
declare
global
{
declare
const
__DYNAMIC_IMPORT__
:
boolean
;
declare
interface
Window
{
// Global vue app instance
__APP__
:
App
<
Element
>
;
...
...
vite.config.ts
浏览文件 @
b476e1c8
...
...
@@ -21,7 +21,14 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
// The boolean type read by loadEnv is a string. This function can be converted to boolean type
const
viteEnv
=
wrapperEnv
(
env
);
const
{
VITE_PORT
,
VITE_PUBLIC_PATH
,
VITE_PROXY
,
VITE_DROP_CONSOLE
,
VITE_LEGACY
}
=
viteEnv
;
const
{
VITE_PORT
,
VITE_PUBLIC_PATH
,
VITE_PROXY
,
VITE_DROP_CONSOLE
,
VITE_LEGACY
,
VITE_DYNAMIC_IMPORT
,
}
=
viteEnv
;
const
isBuild
=
command
===
'
build
'
;
...
...
@@ -68,6 +75,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
define
:
{
// setting vue-i18-next
// Suppress warning
__DYNAMIC_IMPORT__
:
VITE_DYNAMIC_IMPORT
,
__VUE_I18N_LEGACY_API__
:
false
,
__VUE_I18N_FULL_INSTALL__
:
false
,
__INTLIFY_PROD_DEVTOOLS__
:
false
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录