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