mirror of
https://github.com/hi2shark/nazhua.git
synced 2026-01-16 17:20:42 +08:00
✨ 读取节点名称,设置页面标题
This commit is contained in:
parent
5a771a4932
commit
a321ce2f69
@ -4,6 +4,7 @@ import {
|
|||||||
createWebHashHistory,
|
createWebHashHistory,
|
||||||
} from 'vue-router';
|
} from 'vue-router';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
|
import pageTitle from '@/utils/page-title';
|
||||||
|
|
||||||
const constantRoutes = [{
|
const constantRoutes = [{
|
||||||
name: 'Home',
|
name: 'Home',
|
||||||
@ -35,7 +36,7 @@ const routerOptions = {
|
|||||||
const router = createRouter(routerOptions);
|
const router = createRouter(routerOptions);
|
||||||
|
|
||||||
router.beforeResolve((to, from, next) => {
|
router.beforeResolve((to, from, next) => {
|
||||||
document.title = [to?.meta?.title, config.nazhua.title].filter((i) => i).join(' - ');
|
pageTitle(to?.meta?.title);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
5
src/utils/page-title.js
Normal file
5
src/utils/page-title.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import config from '@/config';
|
||||||
|
|
||||||
|
export default (...args) => {
|
||||||
|
document.title = [...args, config.nazhua.title].filter((i) => i).join(' - ');
|
||||||
|
};
|
||||||
@ -54,6 +54,7 @@ import {
|
|||||||
alias2code,
|
alias2code,
|
||||||
locationCode2Info,
|
locationCode2Info,
|
||||||
} from '@/utils/world-map';
|
} from '@/utils/world-map';
|
||||||
|
import pageTitle from '@/utils/page-title';
|
||||||
|
|
||||||
import WorldMap from '@/components/world-map/world-map.vue';
|
import WorldMap from '@/components/world-map/world-map.vue';
|
||||||
import ServerName from './components/server-detail/server-name.vue';
|
import ServerName from './components/server-detail/server-name.vue';
|
||||||
@ -131,6 +132,7 @@ function handleWorldMapWidth() {
|
|||||||
|
|
||||||
watch(() => info.value, () => {
|
watch(() => info.value, () => {
|
||||||
if (info.value) {
|
if (info.value) {
|
||||||
|
pageTitle(info.value?.Name, '节点详情');
|
||||||
handleWorldMapWidth();
|
handleWorldMapWidth();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -145,6 +147,7 @@ watch(() => dataInit.value, () => {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (info.value) {
|
if (info.value) {
|
||||||
|
pageTitle(info.value?.Name, '节点详情');
|
||||||
handleWorldMapWidth();
|
handleWorldMapWidth();
|
||||||
}
|
}
|
||||||
window.addEventListener('resize', handleWorldMapWidth);
|
window.addEventListener('resize', handleWorldMapWidth);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user