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