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