fix watchTitle
This commit is contained in:
parent
91f3f71d8d
commit
4590b7b8aa
6 changed files with 34 additions and 47 deletions
|
@ -13,6 +13,6 @@ export const useInstanceStore = defineStore("instance", {
|
|||
},
|
||||
},
|
||||
getters: {
|
||||
instanceName: (state) => state.instance?.title || "Akkoma",
|
||||
instanceName: (state) => state.instance?.title || "vulpine-fe",
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { watch } from "vue";
|
||||
import { useInstanceStore } from "./instance";
|
||||
|
||||
export default function watchTitle<T extends object | undefined>(
|
||||
callback: (obj: T | undefined) => string | undefined,
|
||||
obj: T | undefined = undefined,
|
||||
) {
|
||||
const instanceStore = useInstanceStore();
|
||||
watch(
|
||||
() => ({ obj, instanceName: instanceStore.instanceName }),
|
||||
({ obj, instanceName }) => {
|
||||
const text = callback(obj);
|
||||
document.title = text ? `${text} - ${instanceName}` : instanceName;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue