fix(系统设置): 调整位置和去掉localStorage

This commit is contained in:
xinxin.wu 2023-08-18 15:55:25 +08:00 committed by rubylliu
parent 75797d1f6e
commit d0e86a48d2
3 changed files with 19 additions and 28 deletions

View File

@ -14,10 +14,12 @@
import { saveBaseInfo, getBaseInfo } from '@/api/modules/setting/config'; import { saveBaseInfo, getBaseInfo } from '@/api/modules/setting/config';
import { getLocalStorage, setLocalStorage } from '@/utils/local-storage'; import { getLocalStorage, setLocalStorage } from '@/utils/local-storage';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import useLicenseStore from '@/store/modules/setting/license';
import { watchStyle, watchTheme, setFavicon } from '@/utils/theme'; import { watchStyle, watchTheme, setFavicon } from '@/utils/theme';
import { GetPlatformIconUrl } from '@/api/requrls/setting/config'; import { GetPlatformIconUrl } from '@/api/requrls/setting/config';
const appStore = useAppStore(); const appStore = useAppStore();
const licenseStore = useLicenseStore();
const { currentLocale } = useLocale(); const { currentLocale } = useLocale();
const locale = computed(() => { const locale = computed(() => {
@ -41,6 +43,7 @@
try { try {
appStore.initSystemversion(); // appStore.initSystemversion(); //
appStore.initPageConfig(); // appStore.initPageConfig(); //
licenseStore.getValidateLicense(); // license
// url url // url url
const isInitUrl = getLocalStorage('isInitUrl'); // url const isInitUrl = getLocalStorage('isInitUrl'); // url
if (isInitUrl === 'true') return; if (isInitUrl === 'true') return;

View File

@ -1,27 +1,33 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { getLicenseInfo } from '@/api/modules/setting/authorizedManagement';
const LicenseKey = 'License_Key';
const useLicenseStore = defineStore('userGroup', { const useLicenseStore = defineStore('userGroup', {
persist: true,
state: (): { status: string | null } => ({ state: (): { status: string | null } => ({
status: '', status: '',
}), }),
actions: { actions: {
setLicenseStatus(status: string) { setLicenseStatus(status: string) {
this.$state.status = status; this.status = status;
localStorage.setItem(LicenseKey, status);
}, },
removeLicenseStatus() { removeLicenseStatus() {
localStorage.removeItem(LicenseKey); this.status = null;
},
getLicenseStatus() {
this.status = localStorage.getItem(LicenseKey);
return this.status;
}, },
hasLicense() { hasLicense() {
this.getLicenseStatus();
return this.status && this.status === 'valid'; return this.status && this.status === 'valid';
}, },
// license校验
async getValidateLicense() {
try {
const result = await getLicenseInfo();
if (!result || !result.status || !result.license || !result.license.count) {
return;
}
this.setLicenseStatus(result.status);
} catch (error) {
console.log(error);
}
},
}, },
}); });

View File

@ -1,6 +1,5 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { login as userLogin, logout as userLogout } from '@/api/modules/user'; import { login as userLogin, logout as userLogout } from '@/api/modules/user';
import { getLicenseInfo } from '@/api/modules/setting/authorizedManagement';
import { setToken, clearToken } from '@/utils/auth'; import { setToken, clearToken } from '@/utils/auth';
import { removeRouteListener } from '@/utils/route-listener'; import { removeRouteListener } from '@/utils/route-listener';
import useAppStore from '../app'; import useAppStore from '../app';
@ -66,7 +65,6 @@ const useUserStore = defineStore('user', {
appStore.setCurrentOrgId(res.lastOrganizationId || ''); appStore.setCurrentOrgId(res.lastOrganizationId || '');
} }
this.setInfo(res); this.setInfo(res);
this.getValidateLicense();
} catch (err) { } catch (err) {
clearToken(); clearToken();
throw err; throw err;
@ -94,22 +92,6 @@ const useUserStore = defineStore('user', {
this.logoutCallBack(); this.logoutCallBack();
} }
}, },
// license校验
async getValidateLicense() {
try {
const licenseStore = useLicenseStore();
const result = await getLicenseInfo();
if (!result || !result.status || !result.license || !result.license.count) {
return;
}
licenseStore.setLicenseStatus(result.status);
if (result.status !== 'valid') {
localStorage.setItem('setShowLicenseCountWarning', 'false');
}
} catch (error) {
console.log(error);
}
},
}, },
}); });