添加不再提醒功能.
This commit is contained in:
@@ -4,6 +4,7 @@ import useMenuStore from './modules/menu';
|
||||
import useUserStore from './modules/user';
|
||||
import useTabBarStore from './modules/tab-bar';
|
||||
import useCacheStore from './modules/cache';
|
||||
import useTipsStore from './modules/tips';
|
||||
|
||||
const pinia = createPinia();
|
||||
|
||||
@@ -13,6 +14,7 @@ export {
|
||||
useUserStore,
|
||||
useTabBarStore,
|
||||
useCacheStore,
|
||||
useTipsStore,
|
||||
};
|
||||
|
||||
export default pinia;
|
||||
|
||||
28
orion-ops-ui/src/store/modules/tips/index.ts
Normal file
28
orion-ops-ui/src/store/modules/tips/index.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { TipsState } from './types';
|
||||
import { setTipsTipped } from '@/api/user/tips';
|
||||
|
||||
export default defineStore('tips', {
|
||||
state: (): TipsState => ({
|
||||
tippedKeys: []
|
||||
}),
|
||||
|
||||
actions: {
|
||||
set(keys: Array<string>) {
|
||||
this.tippedKeys = keys;
|
||||
},
|
||||
isTipped(key: string): boolean {
|
||||
return this.tippedKeys.includes(key);
|
||||
},
|
||||
isNotTipped(key: string): boolean {
|
||||
return !this.tippedKeys.includes(key);
|
||||
},
|
||||
async setTipped(key: string) {
|
||||
try {
|
||||
await setTipsTipped(key);
|
||||
this.tippedKeys.push(key);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
3
orion-ops-ui/src/store/modules/tips/types.ts
Normal file
3
orion-ops-ui/src/store/modules/tips/types.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface TipsState {
|
||||
tippedKeys: Array<string>;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { clearToken, setToken } from '@/utils/auth';
|
||||
import { md5 } from '@/utils';
|
||||
import { removeRouteListener } from '@/utils/route-listener';
|
||||
import { UserState } from './types';
|
||||
import { useAppStore, useMenuStore, useTabBarStore } from '@/store';
|
||||
import { useAppStore, useMenuStore, useTabBarStore, useTipsStore } from '@/store';
|
||||
|
||||
export default defineStore('user', {
|
||||
state: (): UserState => ({
|
||||
@@ -43,6 +43,9 @@ export default defineStore('user', {
|
||||
// 设置用户偏好
|
||||
const appStore = useAppStore();
|
||||
appStore.updateSettings(data.user.systemPreference);
|
||||
// 设置已经提示的key
|
||||
const tipsStore = useTipsStore();
|
||||
tipsStore.set(data.user.tippedKeys);
|
||||
},
|
||||
|
||||
// 登录
|
||||
|
||||
Reference in New Issue
Block a user