Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 488ccb59
authored
Nov 05, 2024
by
Netfan
Committed by
GitHub
Nov 05, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: page title is not updated after language switch. fixed: #4799 (#4813)
1 parent
bbc426ca
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
49 deletions
apps/web-antd/src/bootstrap.ts
apps/web-antd/src/router/guard.ts
apps/web-ele/src/bootstrap.ts
apps/web-ele/src/router/guard.ts
apps/web-naive/src/bootstrap.ts
apps/web-naive/src/router/guard.ts
playground/src/bootstrap.ts
playground/src/router/guard.ts
apps/web-antd/src/bootstrap.ts
View file @
488ccb5
import
{
createApp
}
from
'vue'
;
import
{
createApp
,
watchEffect
}
from
'vue'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
preferences
}
from
'@vben/preferences'
;
import
{
initStores
}
from
'@vben/stores'
;
import
{
initStores
}
from
'@vben/stores'
;
import
'@vben/styles'
;
import
'@vben/styles'
;
import
'@vben/styles/antd'
;
import
'@vben/styles/antd'
;
import
{
setupI18n
}
from
'#/locales'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
,
setupI18n
}
from
'#/locales'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
App
from
'./app.vue'
;
import
App
from
'./app.vue'
;
...
@@ -29,6 +32,16 @@ async function bootstrap(namespace: string) {
...
@@ -29,6 +32,16 @@ async function bootstrap(namespace: string) {
// 配置路由及路由守卫
// 配置路由及路由守卫
app
.
use
(
router
);
app
.
use
(
router
);
// 动态更新标题
watchEffect
(()
=>
{
if
(
preferences
.
app
.
dynamicTitle
)
{
const
routeTitle
=
router
.
currentRoute
.
value
.
meta
?.
title
;
const
pageTitle
=
(
routeTitle
?
`
${
$t
(
routeTitle
)}
- `
:
''
)
+
preferences
.
app
.
name
;
useTitle
(
pageTitle
);
}
});
app
.
mount
(
'#app'
);
app
.
mount
(
'#app'
);
}
}
...
...
apps/web-antd/src/router/guard.ts
View file @
488ccb5
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
}
from
'#/locales'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
useAuthStore
}
from
'#/store'
;
import
{
useAuthStore
}
from
'#/store'
;
...
@@ -40,13 +37,6 @@ function setupCommonGuard(router: Router) {
...
@@ -40,13 +37,6 @@ function setupCommonGuard(router: Router) {
if
(
preferences
.
transition
.
progress
)
{
if
(
preferences
.
transition
.
progress
)
{
stopProgress
();
stopProgress
();
}
}
// 动态修改标题
if
(
preferences
.
app
.
dynamicTitle
)
{
const
{
title
}
=
to
.
meta
;
// useTitle(`${$t(title)} - ${preferences.app.name}`);
useTitle
(
`
${
$t
(
title
)}
-
${
preferences
.
app
.
name
}
`
);
}
});
});
}
}
...
...
apps/web-ele/src/bootstrap.ts
View file @
488ccb5
import
{
createApp
}
from
'vue'
;
import
{
createApp
,
watchEffect
}
from
'vue'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
preferences
}
from
'@vben/preferences'
;
import
{
initStores
}
from
'@vben/stores'
;
import
{
initStores
}
from
'@vben/stores'
;
import
'@vben/styles'
;
import
'@vben/styles'
;
import
'@vben/styles/ele'
;
import
'@vben/styles/ele'
;
import
{
setupI18n
}
from
'#/locales'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
,
setupI18n
}
from
'#/locales'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
App
from
'./app.vue'
;
import
App
from
'./app.vue'
;
...
@@ -28,6 +31,16 @@ async function bootstrap(namespace: string) {
...
@@ -28,6 +31,16 @@ async function bootstrap(namespace: string) {
// 配置路由及路由守卫
// 配置路由及路由守卫
app
.
use
(
router
);
app
.
use
(
router
);
// 动态更新标题
watchEffect
(()
=>
{
if
(
preferences
.
app
.
dynamicTitle
)
{
const
routeTitle
=
router
.
currentRoute
.
value
.
meta
?.
title
;
const
pageTitle
=
(
routeTitle
?
`
${
$t
(
routeTitle
)}
- `
:
''
)
+
preferences
.
app
.
name
;
useTitle
(
pageTitle
);
}
});
app
.
mount
(
'#app'
);
app
.
mount
(
'#app'
);
}
}
...
...
apps/web-ele/src/router/guard.ts
View file @
488ccb5
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
}
from
'#/locales'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
useAuthStore
}
from
'#/store'
;
import
{
useAuthStore
}
from
'#/store'
;
...
@@ -40,13 +37,6 @@ function setupCommonGuard(router: Router) {
...
@@ -40,13 +37,6 @@ function setupCommonGuard(router: Router) {
if
(
preferences
.
transition
.
progress
)
{
if
(
preferences
.
transition
.
progress
)
{
stopProgress
();
stopProgress
();
}
}
// 动态修改标题
if
(
preferences
.
app
.
dynamicTitle
)
{
const
{
title
}
=
to
.
meta
;
// useTitle(`${$t(title)} - ${preferences.app.name}`);
useTitle
(
`
${
$t
(
title
)}
-
${
preferences
.
app
.
name
}
`
);
}
});
});
}
}
...
...
apps/web-naive/src/bootstrap.ts
View file @
488ccb5
import
{
createApp
}
from
'vue'
;
import
{
createApp
,
watchEffect
}
from
'vue'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
preferences
}
from
'@vben/preferences'
;
import
{
initStores
}
from
'@vben/stores'
;
import
{
initStores
}
from
'@vben/stores'
;
import
'@vben/styles'
;
import
'@vben/styles'
;
import
{
setupI18n
}
from
'#/locales'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
,
setupI18n
}
from
'#/locales'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
App
from
'./app.vue'
;
import
App
from
'./app.vue'
;
...
@@ -27,6 +30,16 @@ async function bootstrap(namespace: string) {
...
@@ -27,6 +30,16 @@ async function bootstrap(namespace: string) {
// 配置路由及路由守卫
// 配置路由及路由守卫
app
.
use
(
router
);
app
.
use
(
router
);
// 动态更新标题
watchEffect
(()
=>
{
if
(
preferences
.
app
.
dynamicTitle
)
{
const
routeTitle
=
router
.
currentRoute
.
value
.
meta
?.
title
;
const
pageTitle
=
(
routeTitle
?
`
${
$t
(
routeTitle
)}
- `
:
''
)
+
preferences
.
app
.
name
;
useTitle
(
pageTitle
);
}
});
app
.
mount
(
'#app'
);
app
.
mount
(
'#app'
);
}
}
...
...
apps/web-naive/src/router/guard.ts
View file @
488ccb5
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
}
from
'#/locales'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
useAuthStore
}
from
'#/store'
;
import
{
useAuthStore
}
from
'#/store'
;
...
@@ -40,13 +37,6 @@ function setupCommonGuard(router: Router) {
...
@@ -40,13 +37,6 @@ function setupCommonGuard(router: Router) {
if
(
preferences
.
transition
.
progress
)
{
if
(
preferences
.
transition
.
progress
)
{
stopProgress
();
stopProgress
();
}
}
// 动态修改标题
if
(
preferences
.
app
.
dynamicTitle
)
{
const
{
title
}
=
to
.
meta
;
// useTitle(`${$t(title)} - ${preferences.app.name}`);
useTitle
(
`
${
$t
(
title
)}
-
${
preferences
.
app
.
name
}
`
);
}
});
});
}
}
...
...
playground/src/bootstrap.ts
View file @
488ccb5
import
{
createApp
}
from
'vue'
;
import
{
createApp
,
watchEffect
}
from
'vue'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
registerAccessDirective
}
from
'@vben/access'
;
import
{
preferences
}
from
'@vben/preferences'
;
import
{
initStores
}
from
'@vben/stores'
;
import
{
initStores
}
from
'@vben/stores'
;
import
'@vben/styles'
;
import
'@vben/styles'
;
import
'@vben/styles/antd'
;
import
'@vben/styles/antd'
;
import
{
VueQueryPlugin
}
from
'@tanstack/vue-query'
;
import
{
VueQueryPlugin
}
from
'@tanstack/vue-query'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
setupI18n
}
from
'#/locales'
;
import
{
$t
,
setupI18n
}
from
'#/locales'
;
import
{
router
}
from
'#/router'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
{
initComponentAdapter
}
from
'./adapter/component'
;
import
App
from
'./app.vue'
;
import
App
from
'./app.vue'
;
import
{
router
}
from
'./router'
;
async
function
bootstrap
(
namespace
:
string
)
{
async
function
bootstrap
(
namespace
:
string
)
{
// 初始化组件适配器
// 初始化组件适配器
...
@@ -34,6 +36,16 @@ async function bootstrap(namespace: string) {
...
@@ -34,6 +36,16 @@ async function bootstrap(namespace: string) {
// 配置@tanstack/vue-query
// 配置@tanstack/vue-query
app
.
use
(
VueQueryPlugin
);
app
.
use
(
VueQueryPlugin
);
// 动态更新标题
watchEffect
(()
=>
{
if
(
preferences
.
app
.
dynamicTitle
)
{
const
routeTitle
=
router
.
currentRoute
.
value
.
meta
?.
title
;
const
pageTitle
=
(
routeTitle
?
`
${
$t
(
routeTitle
)}
- `
:
''
)
+
preferences
.
app
.
name
;
useTitle
(
pageTitle
);
}
});
app
.
mount
(
'#app'
);
app
.
mount
(
'#app'
);
}
}
...
...
playground/src/router/guard.ts
View file @
488ccb5
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
...
@@ -5,9 +5,6 @@ import { preferences } from '@vben/preferences';
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
useAccessStore
,
useUserStore
}
from
'@vben/stores'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
startProgress
,
stopProgress
}
from
'@vben/utils'
;
import
{
useTitle
}
from
'@vueuse/core'
;
import
{
$t
}
from
'#/locales'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
accessRoutes
,
coreRouteNames
}
from
'#/router/routes'
;
import
{
useAuthStore
}
from
'#/store'
;
import
{
useAuthStore
}
from
'#/store'
;
...
@@ -39,13 +36,6 @@ function setupCommonGuard(router: Router) {
...
@@ -39,13 +36,6 @@ function setupCommonGuard(router: Router) {
if
(
preferences
.
transition
.
progress
)
{
if
(
preferences
.
transition
.
progress
)
{
stopProgress
();
stopProgress
();
}
}
// 动态修改标题
if
(
preferences
.
app
.
dynamicTitle
)
{
const
{
title
}
=
to
.
meta
;
// useTitle(`${$t(title)} - ${preferences.app.name}`);
useTitle
(
`
${
$t
(
title
)}
-
${
preferences
.
app
.
name
}
`
);
}
});
});
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment