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

View File

@ -1,27 +1,33 @@
import { defineStore } from 'pinia';
const LicenseKey = 'License_Key';
import { getLicenseInfo } from '@/api/modules/setting/authorizedManagement';
const useLicenseStore = defineStore('userGroup', {
persist: true,
state: (): { status: string | null } => ({
status: '',
}),
actions: {
setLicenseStatus(status: string) {
this.$state.status = status;
localStorage.setItem(LicenseKey, status);
this.status = status;
},
removeLicenseStatus() {
localStorage.removeItem(LicenseKey);
},
getLicenseStatus() {
this.status = localStorage.getItem(LicenseKey);
return this.status;
this.status = null;
},
hasLicense() {
this.getLicenseStatus();
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 { login as userLogin, logout as userLogout } from '@/api/modules/user';
import { getLicenseInfo } from '@/api/modules/setting/authorizedManagement';
import { setToken, clearToken } from '@/utils/auth';
import { removeRouteListener } from '@/utils/route-listener';
import useAppStore from '../app';
@ -66,7 +65,6 @@ const useUserStore = defineStore('user', {
appStore.setCurrentOrgId(res.lastOrganizationId || '');
}
this.setInfo(res);
this.getValidateLicense();
} catch (err) {
clearToken();
throw err;
@ -94,22 +92,6 @@ const useUserStore = defineStore('user', {
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);
}
},
},
});