Files
fe.ems.vue3/src/store/modules/app.ts
2023-10-20 10:07:34 +08:00

39 lines
880 B
TypeScript

import { defineStore } from 'pinia';
/**应用参数类型 */
type AppStore = {
/**应用名称 */
appName: string;
/**应用标识 */
appCode: string;
/**应用版本 */
appVersion: string;
/**应用版权声明 */
copyright: string;
};
const useAppStore = defineStore('app', {
state: (): AppStore => ({
appName: import.meta.env.VITE_APP_NAME,
appCode: import.meta.env.VITE_APP_CODE,
appVersion: import.meta.env.VITE_APP_VERSION,
copyright: 'Copyright ©2023 For AGrand 千通科技',
}),
actions: {
/**设置网页标题 */
setTitle(title?: string) {
if (title) {
document.title = `${title} - ${this.appName}`;
} else {
document.title = this.appName;
}
},
/**设置版权声明 */
setCopyright(text: string) {
this.copyright = text;
},
},
});
export default useAppStore;