设置网页title为固定值
This commit is contained in:
parent
ad7b421eff
commit
8588aabf1c
@ -1,8 +1,8 @@
|
|||||||
import { useNavigationBarTitleStore } from '@/stores/navigationBarTitle'
|
import { useNavigationBarTitleStore } from "@/stores/navigationBarTitle";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
onShow() {
|
onShow() {
|
||||||
const navigationBarTitleStore = useNavigationBarTitleStore()
|
const navigationBarTitleStore = useNavigationBarTitleStore();
|
||||||
navigationBarTitleStore.setTitle()
|
navigationBarTitleStore.setTitle();
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|||||||
@ -336,7 +336,7 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/create/create",
|
"path": "pages/create/create",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "创作"
|
"navigationBarTitleText": "信广龙AI智能体"
|
||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"auth": true,
|
"auth": true,
|
||||||
|
|||||||
@ -1,38 +1,38 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from "pinia";
|
||||||
import router from '@/router'
|
import router from "@/router";
|
||||||
interface routeObject {
|
interface routeObject {
|
||||||
path: string
|
path: string;
|
||||||
title: string
|
title: string;
|
||||||
}
|
}
|
||||||
interface NavigationBarTitleState {
|
interface NavigationBarTitleState {
|
||||||
pathToTitleMap: Map<string, string | undefined>
|
pathToTitleMap: Map<string, string | undefined>;
|
||||||
}
|
}
|
||||||
export const useNavigationBarTitleStore = defineStore({
|
export const useNavigationBarTitleStore = defineStore({
|
||||||
id: 'navigationBarTitleStore',
|
id: "navigationBarTitleStore",
|
||||||
state: (): NavigationBarTitleState => ({
|
state: (): NavigationBarTitleState => ({
|
||||||
pathToTitleMap: new Map()
|
pathToTitleMap: new Map(),
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getTitle(): string | undefined {
|
getTitle(): string | undefined {
|
||||||
try {
|
try {
|
||||||
const realRoute = router.resolve(router.currentRoute.value.path)
|
const realRoute = router.resolve(router.currentRoute.value.path);
|
||||||
return this.pathToTitleMap.get(realRoute?.path!)
|
return this.pathToTitleMap.get(realRoute?.path!);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('getTitle Error => ', error)
|
console.log("getTitle Error => ", error);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
},
|
||||||
actions: {
|
actions: {
|
||||||
add({ path, title }: routeObject) {
|
add({ path, title }: routeObject) {
|
||||||
this.pathToTitleMap.set(path, title)
|
this.pathToTitleMap.set(path, title);
|
||||||
},
|
},
|
||||||
setTitle() {
|
setTitle() {
|
||||||
const title = this.getTitle
|
const title = this.getTitle;
|
||||||
if (title) {
|
if (title) {
|
||||||
uni.setNavigationBarTitle({
|
uni.setNavigationBarTitle({
|
||||||
title
|
title: "信广龙AI智能体", // title
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user