Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
啊嘞嘞EC
vue-vben-admin
提交
b350098f
V
vue-vben-admin
项目概览
啊嘞嘞EC
/
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,发现更多精彩内容 >>
提交
b350098f
编写于
10月 27, 2020
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf: adjust the logic of
上级
bfac425d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
43 deletion
+50
-43
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+5
-0
src/router/guard/index.ts
src/router/guard/index.ts
+11
-3
src/router/guard/pageTitleGuard.ts
src/router/guard/pageTitleGuard.ts
+0
-39
src/utils/browser.ts
src/utils/browser.ts
+29
-0
src/views/demo/feat/tab-params/index.vue
src/views/demo/feat/tab-params/index.vue
+5
-1
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
b350098f
...
...
@@ -12,6 +12,10 @@
-
依赖更新
-
文档更新
### ⚡ Performance Improvements
-
`setTitle`
逻辑调整
### ✨ Refactor
-
独立出
`vite-plugin-html`
,并修改相关插入 html 的逻辑
...
...
@@ -19,6 +23,7 @@
### 🐛 Bug Fixes
-
修复热更新时多次注册组件警告问题
-
修复登录后出现登录标签页
## 2.0.0-rc.5 (2020-10-26)
...
...
src/router/guard/index.ts
浏览文件 @
b350098f
...
...
@@ -2,14 +2,14 @@ import type { Router } from 'vue-router';
import
{
Modal
,
notification
}
from
'
ant-design-vue
'
;
import
{
AxiosCanceler
}
from
'
/@/utils/http/axios/axiosCancel
'
;
import
{
createPageTitleGuard
}
from
'
./pageTitleGuard
'
;
import
{
createProgressGuard
}
from
'
./progressGuard
'
;
import
{
createPermissionGuard
}
from
'
./permissionGuard
'
;
import
{
createPageLoadingGuard
}
from
'
./pageLoadingGuard
'
;
import
{
useSetting
}
from
'
/@/hooks/core/useSetting
'
;
import
{
getIsOpenTab
,
setCurrentTo
}
from
'
/@/utils/helper/routeHelper
'
;
import
{
setTitle
}
from
'
/@/utils/browser
'
;
const
{
projectSetting
}
=
useSetting
();
const
{
projectSetting
,
globSetting
}
=
useSetting
();
export
function
createGuard
(
router
:
Router
)
{
const
{
openNProgress
,
closeMessageOnSwitch
,
removeAllHttpPending
}
=
projectSetting
;
let
axiosCanceler
:
AxiosCanceler
|
null
;
...
...
@@ -33,8 +33,16 @@ export function createGuard(router: Router) {
setCurrentTo
(
to
);
return
true
;
});
router
.
afterEach
((
to
)
=>
{
// change html title
setTimeout
(()
=>
{
setTitle
(
to
.
meta
.
title
,
globSetting
.
title
);
},
0
);
});
openNProgress
&&
createProgressGuard
(
router
);
createPermissionGuard
(
router
);
createPageTitleGuard
(
router
);
createPageLoadingGuard
(
router
);
}
src/router/guard/pageTitleGuard.ts
已删除
100644 → 0
浏览文件 @
bfac425d
import
type
{
Router
}
from
'
vue-router
'
;
import
{
useSetting
}
from
'
/@/hooks/core/useSetting
'
;
/**
* 设置页面标题
* @param {*} title :页面标题
*/
const
setDocumentTitle
=
(
title
:
string
)
=>
{
document
.
title
=
title
;
const
ua
=
navigator
.
userAgent
;
const
regex
=
/
\b
MicroMessenger
\/([\d
.
]
+
)
/
;
// 兼容
if
(
regex
.
test
(
ua
)
&&
/ip
(
hone|od|ad
)
/i
.
test
(
ua
))
{
const
i
=
document
.
createElement
(
'
iframe
'
);
i
.
src
=
'
/favicon.ico
'
;
i
.
style
.
display
=
'
none
'
;
i
.
onload
=
function
()
{
setTimeout
(
function
()
{
i
.
remove
();
},
9
);
};
document
.
body
.
appendChild
(
i
);
}
};
export
const
createPageTitleGuard
=
(
router
:
Router
)
=>
{
router
.
beforeEach
(
async
(
to
)
=>
{
// This operation does not require synchronization
setTimeout
(()
=>
{
const
{
globSetting
}
=
useSetting
();
if
(
to
.
meta
.
title
)
{
const
{
title
}
=
globSetting
;
const
_title
=
to
.
meta
.
title
?
`
${
to
.
meta
.
title
}
-
${
title
}
`
:
`
${
title
}
`
;
setDocumentTitle
(
_title
);
}
},
30
);
return
true
;
});
};
src/utils/browser.ts
浏览文件 @
b350098f
...
...
@@ -70,3 +70,32 @@ export function isFirefoxFn() {
export
function
isOperaFn
()
{
return
type
===
'
Opera
'
;
}
/**
* set page Title
* @param {*} title :page Title
*/
const
setDocumentTitle
=
(
title
:
string
)
=>
{
document
.
title
=
title
;
const
ua
=
navigator
.
userAgent
;
const
regex
=
/
\b
MicroMessenger
\/([\d
.
]
+
)
/
;
// 兼容
if
(
regex
.
test
(
ua
)
&&
/ip
(
hone|od|ad
)
/i
.
test
(
ua
))
{
const
i
=
document
.
createElement
(
'
iframe
'
);
i
.
src
=
'
/favicon.ico
'
;
i
.
style
.
display
=
'
none
'
;
i
.
onload
=
function
()
{
setTimeout
(
function
()
{
i
.
remove
();
},
9
);
};
document
.
body
.
appendChild
(
i
);
}
};
export
function
setTitle
(
title
:
string
,
appTitle
?:
string
)
{
if
(
title
)
{
const
_title
=
title
?
`
${
title
}
-
${
appTitle
}
`
:
`
${
appTitle
}
`
;
setDocumentTitle
(
_title
);
}
}
src/views/demo/feat/tab-params/index.vue
浏览文件 @
b350098f
<
template
>
<div
class=
"p-4"
>
Current Param :
{{
params
}}
</div>
<div
class=
"p-4"
>
Current Param :
{{
params
}}
<input
/>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
computed
,
defineComponent
,
unref
}
from
'
vue
'
;
import
{
useRouter
}
from
'
vue-router
'
;
export
default
defineComponent
({
name
:
'
TestTab
'
,
setup
()
{
const
{
currentRoute
}
=
useRouter
();
return
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录