- 新增产品管理相关路由和页面(dashboard、list、requirement、setting) - 实现产品基础信息编辑弹窗组件(base-info-dialog.vue) - 添加运行时字典功能(dict-select、dict-text、dict-tag组件) - 集成字典管理store和API调用 - 规范ID类型定义为string避免精度丢失问题 - 完善国际化资源文件支持中英文对照 - 新增对象上下文业务域入口页导航实现说明 - 添加Vue DevTools浮动入口注释说明 - 统一权限控制支持全局和对象作用域区分 - 规范分页查询参数类型定义与使用方式
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
import { safeJsonTransformResponse } from '../request/json';
|
|
|
|
export type ServiceRequestResult<T> =
|
|
| {
|
|
data: T;
|
|
error: null;
|
|
response: AxiosResponse<App.Service.Response<unknown>>;
|
|
}
|
|
| {
|
|
data: null;
|
|
error: AxiosError<App.Service.Response<unknown>>;
|
|
response: AxiosResponse<App.Service.Response<unknown>> | undefined;
|
|
};
|
|
|
|
export const safeJsonRequestConfig: Pick<AxiosRequestConfig, 'transformResponse'> = {
|
|
transformResponse: [safeJsonTransformResponse]
|
|
};
|
|
|
|
export function normalizeStringId(id: string | number) {
|
|
return String(id);
|
|
}
|
|
|
|
export function normalizeNullableStringId(id: string | number | null | undefined) {
|
|
if (id === null || id === undefined || id === '') {
|
|
return null;
|
|
}
|
|
|
|
return String(id);
|
|
}
|
|
|
|
export function mapServiceResult<TInput, TOutput>(
|
|
result: ServiceRequestResult<TInput>,
|
|
mapper: (data: TInput) => TOutput
|
|
): ServiceRequestResult<TOutput> {
|
|
if (result.error || result.data === null) {
|
|
return result as ServiceRequestResult<TOutput>;
|
|
}
|
|
|
|
return {
|
|
...result,
|
|
data: mapper(result.data)
|
|
};
|
|
}
|