更新字典获取方式

This commit is contained in:
linxd
2025-07-29 13:52:51 +08:00
parent 747cceeb18
commit 49105505fa
4 changed files with 37 additions and 3 deletions

15
src/app.tsx Normal file
View File

@ -0,0 +1,15 @@
// src/app.ts
import { message } from 'antd';
import { refreshDictCache } from './servers/api';
export async function getInitialState() {
try {
const res = await refreshDictCache();
if (res.code == 200) {
sessionStorage.setItem('dict', JSON.stringify(res.data));
}
} catch (e) {
message.error('初始化失败');
return {};
}
}

View File

@ -146,6 +146,7 @@ const IndexPage: React.FC<any> = ({ user }) => {
}).then((res) => {
setNoticeList(res.data.records);
});
}, []);
const toSystem = (type: string) => {

View File

@ -42,7 +42,17 @@ export type DictItem = {
* @returns 字典列表
*/
export async function getDictList(code: string): Promise<DictResponse> {
return request(`/cosco/dictProject/getAllList/${code}`, {
method: 'GET',
});
const data: string | null = sessionStorage.getItem('dict');
if (data) {
const dictData = JSON.parse(data);
const codeType = `${code.trim()}=supplier_manage_type`;
return Promise.resolve({
code: 200,
data: dictData[codeType],
message: 'success',
success: true,
})
} else {
return Promise.reject(new Error('请先请求字典数据'));
}
}

View File

@ -14,3 +14,11 @@ export async function getCoscoPortalsLinksFriendshipConnections() {
method: 'get',
});
}
/**
* 字典缓存接口
*/
export async function refreshDictCache() {
return request('/v1/dictProject/refreshDictCache', {
method: 'GET'
});
}