fix(系统设置): 调整位置和去掉localStorage
This commit is contained in:
parent
75797d1f6e
commit
d0e86a48d2
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue