feat: ✨ 新增字典和字典展示功能
新增字典和字典展示功能
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
const TOKEN_KEY = "app-token";
|
||||
const USER_INFO_KEY = "user-info";
|
||||
const DICT_KEY = "dict";
|
||||
import { type DictData } from "@/api/system/dict";
|
||||
|
||||
// 设置 token
|
||||
export function setToken(token: string) {
|
||||
@@ -31,8 +33,24 @@ export function clearUserInfo() {
|
||||
uni.removeStorageSync(USER_INFO_KEY);
|
||||
}
|
||||
|
||||
// 设置字典缓存
|
||||
export function setDictCache(dict: Record<string, DictData[]>) {
|
||||
uni.setStorageSync(DICT_KEY, dict);
|
||||
}
|
||||
|
||||
// 获取字典缓存
|
||||
export function getDictCache(): Record<string, DictData[]> {
|
||||
return uni.getStorageSync(DICT_KEY) || {};
|
||||
}
|
||||
|
||||
// 清除字典缓存
|
||||
export function clearDictCache() {
|
||||
uni.removeStorageSync(DICT_KEY);
|
||||
}
|
||||
|
||||
// 清除所有缓存信息
|
||||
export function clearAll() {
|
||||
clearToken();
|
||||
clearUserInfo();
|
||||
clearDictCache();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ export default function request<T>(options: UniApp.RequestOptions): Promise<T> {
|
||||
...options.header,
|
||||
Authorization: getToken() ? `Bearer ${getToken()}` : "",
|
||||
},
|
||||
data: handleData(options.data, options.method),
|
||||
data: handleData(options.data, options.method || "GET"),
|
||||
success: (response) => {
|
||||
console.log("success response", response);
|
||||
const resData = response.data as ResponseData<T>;
|
||||
|
||||
Reference in New Issue
Block a user