fix
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {defineStore} from 'pinia';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
/**
|
||||
* 创建并导出字典存储的 Vue3 store 对象
|
||||
@@ -6,55 +6,55 @@ import {defineStore} from 'pinia';
|
||||
* @returns {DictionaryStore} - 返回创建的字典存储对象
|
||||
*/
|
||||
export const dict = defineStore('dict', {
|
||||
state: () => ({
|
||||
dict: [] as any[],
|
||||
}),
|
||||
actions: {
|
||||
/**
|
||||
* 获取指定键的值
|
||||
* @function
|
||||
* @param {string} key - 需要获取的键
|
||||
* @returns {Object|null} - 返回指定键对应的值,如果找不到则返回 null
|
||||
*/
|
||||
getDict(key: String) {
|
||||
try {
|
||||
const item = this.dict.find((item) => item.key === key);
|
||||
return item ? item.value : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
state: () => ({
|
||||
dict: [] as any[],
|
||||
}),
|
||||
actions: {
|
||||
/**
|
||||
* 获取指定键的值
|
||||
* @function
|
||||
* @param {string} key - 需要获取的键
|
||||
* @returns {Object|null} - 返回指定键对应的值,如果找不到则返回 null
|
||||
*/
|
||||
getDict(key: String) {
|
||||
try {
|
||||
const item = this.dict.find((item) => item.key === key);
|
||||
return item ? item.value : null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置一个键值对
|
||||
* @function
|
||||
* @param {string} key - 需要设置的键
|
||||
* @param {Object} value - 需要设置的值
|
||||
*/
|
||||
setDict(key: String, value: Object) {
|
||||
if (!key || typeof key !== 'string') {
|
||||
return;
|
||||
}
|
||||
this.dict.push({key, value});
|
||||
},
|
||||
/**
|
||||
* 设置一个键值对
|
||||
* @function
|
||||
* @param {string} key - 需要设置的键
|
||||
* @param {Object} value - 需要设置的值
|
||||
*/
|
||||
setDict(key: String, value: Object) {
|
||||
if (!key || typeof key !== 'string') {
|
||||
return;
|
||||
}
|
||||
this.dict.push({ key, value });
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除指定键值对
|
||||
* @function
|
||||
* @param {string} key - 需要删除的键
|
||||
* @returns {boolean} - 返回删除操作是否成功
|
||||
*/
|
||||
removeDict(key: String) {
|
||||
try {
|
||||
const index = this.dict.findIndex((item) => item.key === key);
|
||||
if (index !== -1) {
|
||||
this.dict.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
/**
|
||||
* 删除指定键值对
|
||||
* @function
|
||||
* @param {string} key - 需要删除的键
|
||||
* @returns {boolean} - 返回删除操作是否成功
|
||||
*/
|
||||
removeDict(key: String) {
|
||||
try {
|
||||
const index = this.dict.findIndex((item) => item.key === key);
|
||||
if (index !== -1) {
|
||||
this.dict.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {defineStore} from 'pinia';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
/**
|
||||
* 创建并导出字典存储的 Vue3 store 对象
|
||||
@@ -6,55 +6,55 @@ import {defineStore} from 'pinia';
|
||||
* @returns {DictionaryStore} - 返回创建的字典存储对象
|
||||
*/
|
||||
export const param = defineStore('param', {
|
||||
state: () => ({
|
||||
param: [] as any[],
|
||||
}),
|
||||
actions: {
|
||||
/**
|
||||
* 获取指定键的值
|
||||
* @function
|
||||
* @param {string} key - 需要获取的键
|
||||
* @returns {Object|null} - 返回指定键对应的值,如果找不到则返回 null
|
||||
*/
|
||||
getParam(key: String) {
|
||||
try {
|
||||
const item = this.param.find((item) => item.key === key);
|
||||
return item ? item.value : undefined;
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
state: () => ({
|
||||
param: [] as any[],
|
||||
}),
|
||||
actions: {
|
||||
/**
|
||||
* 获取指定键的值
|
||||
* @function
|
||||
* @param {string} key - 需要获取的键
|
||||
* @returns {Object|null} - 返回指定键对应的值,如果找不到则返回 null
|
||||
*/
|
||||
getParam(key: String) {
|
||||
try {
|
||||
const item = this.param.find((item) => item.key === key);
|
||||
return item ? item.value : undefined;
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置一个键值对
|
||||
* @function
|
||||
* @param {string} key - 需要设置的键
|
||||
* @param {Object} value - 需要设置的值
|
||||
*/
|
||||
setParam(key: String, value: Object) {
|
||||
if (!key || typeof key !== 'string') {
|
||||
return;
|
||||
}
|
||||
this.param.push({key, value});
|
||||
},
|
||||
/**
|
||||
* 设置一个键值对
|
||||
* @function
|
||||
* @param {string} key - 需要设置的键
|
||||
* @param {Object} value - 需要设置的值
|
||||
*/
|
||||
setParam(key: String, value: Object) {
|
||||
if (!key || typeof key !== 'string') {
|
||||
return;
|
||||
}
|
||||
this.param.push({ key, value });
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除指定键值对
|
||||
* @function
|
||||
* @param {string} key - 需要删除的键
|
||||
* @returns {boolean} - 返回删除操作是否成功
|
||||
*/
|
||||
removeParam(key: String) {
|
||||
try {
|
||||
const index = this.param.findIndex((item) => item.key === key);
|
||||
if (index !== -1) {
|
||||
this.param.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
/**
|
||||
* 删除指定键值对
|
||||
* @function
|
||||
* @param {string} key - 需要删除的键
|
||||
* @returns {boolean} - 返回删除操作是否成功
|
||||
*/
|
||||
removeParam(key: String) {
|
||||
try {
|
||||
const index = this.param.findIndex((item) => item.key === key);
|
||||
if (index !== -1) {
|
||||
this.param.splice(index, 1);
|
||||
return true;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -28,8 +28,8 @@ export const useTagsViewRoutes = defineStore('tagsViewRoutes', {
|
||||
const { themeConfig } = storeToRefs(storesThemeConfig);
|
||||
// 判断已经存储的长度,如果超过主题设置则警告
|
||||
if (this.favoriteRoutes.length > themeConfig.value.quickLinkNum) {
|
||||
useMessage().error(i18n.global.t('tagsView.favoriteMax'))
|
||||
return
|
||||
useMessage().error(i18n.global.t('tagsView.favoriteMax'));
|
||||
return;
|
||||
}
|
||||
this.favoriteRoutes.unshift(item);
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import {Local, Session} from '/@/utils/storage';
|
||||
import { Local, Session } from '/@/utils/storage';
|
||||
import { getUserInfo, login, loginByMobile, loginBySocial, refreshTokenApi } from '/@/api/login/index';
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { initUserTableConfigs } from '/@/api/admin/usertable';
|
||||
@@ -40,7 +40,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
* @param {Object} data - 登录数据
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async login(data:any) {
|
||||
async login(data: any) {
|
||||
data.grant_type = 'password';
|
||||
data.scope = 'server';
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -138,7 +138,7 @@ export const useUserInfo = defineStore('userInfo', {
|
||||
authBtnList: res.data.permissions,
|
||||
};
|
||||
this.userInfos = userInfo;
|
||||
|
||||
|
||||
// 初始化用户表格配置(登录后获取一次所有配置并保存到本地)
|
||||
initUserTableConfigs().catch((err) => {
|
||||
console.error('初始化用户表格配置失败:', err);
|
||||
|
||||
Reference in New Issue
Block a user