update prettier 替换为 oxfmt 格式化整个项目的代码结构

This commit is contained in:
疯狂的狮子Li
2026-04-01 17:03:20 +08:00
parent 199771997d
commit 16d9e1e7fe
131 changed files with 3750 additions and 1571 deletions

View File

@@ -9,7 +9,7 @@ const CryptoJS = ('default' in CryptoJSModule ? CryptoJSModule.default : CryptoJ
const generateRandomString = (): string => {
const array = new Uint8Array(32);
crypto.getRandomValues(array);
return Array.from(array, (b) => b.toString(16).padStart(2, '0'))
return Array.from(array, b => b.toString(16).padStart(2, '0'))
.join('')
.slice(0, 32);
};

View File

@@ -8,15 +8,20 @@ export const useDict = (...args: string[]): { [key: string]: DictDataOption[] }
[key: string]: DictDataOption[];
}>({});
args.forEach(async (dictType) => {
args.forEach(async dictType => {
res.value[dictType] = [];
const dicts = useDictStore().getDict(dictType);
if (dicts) {
res.value[dictType] = dicts;
} else {
await getDicts(dictType).then((resp) => {
await getDicts(dictType).then(resp => {
res.value[dictType] = resp.data.map(
(p): DictDataOption => ({ label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass })
(p): DictDataOption => ({
label: p.dictLabel,
value: p.dictValue,
elTagType: p.listClass,
elTagClass: p.cssClass
})
);
useDictStore().setDict(dictType, res.value[dictType]);
});

View File

@@ -105,7 +105,7 @@ export const cleanArray = (actual: Array<any>) => {
export const param = (json: any) => {
if (!json) return '';
return cleanArray(
Object.keys(json).map((key) => {
Object.keys(json).map(key => {
if (json[key] === undefined) return '';
return encodeURIComponent(key) + '=' + encodeURIComponent(json[key]);
})
@@ -123,7 +123,7 @@ export const param2Obj = (url: string) => {
}
const obj: any = {};
const searchArr = search.split('&');
searchArr.forEach((v) => {
searchArr.forEach(v => {
const index = v.indexOf('=');
if (index !== -1) {
const name = v.substring(0, index);
@@ -157,7 +157,7 @@ export const objectMerge = (target: any, source: any | any[]) => {
if (Array.isArray(source)) {
return source.slice();
}
Object.keys(source).forEach((property) => {
Object.keys(source).forEach(property => {
const sourceProperty = source[property];
if (typeof sourceProperty === 'object') {
target[property] = objectMerge(target[property], sourceProperty);
@@ -250,7 +250,7 @@ export const deepClone = (source: any) => {
throw new Error('error arguments', 'deepClone' as any);
}
const targetObj: any = source.constructor === Array ? [] : {};
Object.keys(source).forEach((keys) => {
Object.keys(source).forEach(keys => {
if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = deepClone(source[keys]);
} else {

View File

@@ -6,9 +6,7 @@ const MAX_READ_IDS = 300;
const buildCacheKey = (userId: string | number) => `${MESSAGE_READ_KEY}:${userId}`;
const normalizeIds = (ids: Array<string | number>) => {
const values = ids
.map((item) => String(item))
.filter((item) => !!item);
const values = ids.map(item => String(item)).filter(item => !!item);
return Array.from(new Set(values)).slice(0, MAX_READ_IDS);
};

View File

@@ -11,7 +11,7 @@ export const checkPermi = (value: any) => {
const permissionDatas = value;
const all_permission = '*:*:*';
const hasPermission = permissions.some((permission) => {
const hasPermission = permissions.some(permission => {
return all_permission === permission || permissionDatas.includes(permission);
});
@@ -36,7 +36,7 @@ export const checkRole = (value: any): boolean => {
const permissionRoles = value;
const super_admin = 'admin';
const hasRole = roles.some((role) => {
const hasRole = roles.some(role => {
return super_admin === role || permissionRoles.includes(role);
});

View File

@@ -145,7 +145,9 @@ export const initMessageBox = async () => {
return;
}
const { data } = await getMessageBox();
const notices = [...(data?.systemList ?? []), ...(data?.noticeList ?? []), ...(data?.workflowList ?? [])].map(toNoticeItem);
const notices = [...(data?.systemList ?? []), ...(data?.noticeList ?? []), ...(data?.workflowList ?? [])].map(
toNoticeItem
);
useNoticeStore().setNotices(notices);
};

View File

@@ -145,7 +145,10 @@ service.interceptors.request.use(
// 生成一个 AES 密钥
const aesKey = generateAesKey();
config.headers[encryptHeader] = encrypt(encryptBase64(aesKey));
config.data = typeof config.data === 'object' ? encryptWithAes(JSON.stringify(config.data), aesKey) : encryptWithAes(config.data, aesKey);
config.data =
typeof config.data === 'object'
? encryptWithAes(JSON.stringify(config.data), aesKey)
: encryptWithAes(config.data, aesKey);
}
}
// FormData数据去请求头Content-Type
@@ -223,14 +226,17 @@ service.interceptors.response.use(
}
},
async (error: any) => {
const message = await extractErrorMessage(error) || errorCode['default'];
const message = (await extractErrorMessage(error)) || errorCode['default'];
ElMessage({ message: message, type: 'error', duration: 5 * 1000 });
return Promise.reject(error);
}
);
// 通用下载方法
export function download(url: string, params: any, fileName: string) {
downloadLoadingInstance = ElLoading.service({ text: '正在下载数据,请稍候', background: 'rgba(0, 0, 0, 0.7)' });
downloadLoadingInstance = ElLoading.service({
text: '正在下载数据,请稍候',
background: 'rgba(0, 0, 0, 0.7)'
});
// prettier-ignore
return service.post(url, params, {
transformRequest: [

View File

@@ -51,7 +51,8 @@ export function parseTime(time: any, pattern?: string) {
*/
export const addDateRange = (params: any, dateRange: any[], propName?: string) => {
const search = params;
search.params = typeof search.params === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {};
search.params =
typeof search.params === 'object' && search.params !== null && !Array.isArray(search.params) ? search.params : {};
dateRange = Array.isArray(dateRange) ? dateRange : [];
if (typeof propName === 'undefined') {
search.params['beginTime'] = dateRange[0];
@@ -69,7 +70,7 @@ export const selectDictLabel = (datas: any, value: number | string) => {
return '';
}
const actions: Array<string | number> = [];
Object.keys(datas).some((key) => {
Object.keys(datas).some(key => {
if (datas[key].value == '' + value) {
actions.push(datas[key].label);
return true;
@@ -92,9 +93,9 @@ export const selectDictLabels = (datas: any, value: any, separator: any) => {
const actions: any[] = [];
const currentSeparator = undefined === separator ? ',' : separator;
const temp = value.split(currentSeparator);
Object.keys(value.split(currentSeparator)).some((val) => {
Object.keys(value.split(currentSeparator)).some(val => {
let match = false;
Object.keys(datas).some((key) => {
Object.keys(datas).some(key => {
if (datas[key].value == '' + temp[val]) {
actions.push(datas[key].label + currentSeparator);
match = true;

View File

@@ -57,7 +57,24 @@ const TAG_ALLOWED_ATTRS: Record<string, Set<string>> = {
colgroup: new Set(['span'])
};
const DANGEROUS_TAGS = new Set(['script', 'style', 'iframe', 'object', 'embed', 'link', 'meta', 'base', 'form', 'input', 'button', 'textarea', 'select', 'option', 'svg', 'math']);
const DANGEROUS_TAGS = new Set([
'script',
'style',
'iframe',
'object',
'embed',
'link',
'meta',
'base',
'form',
'input',
'button',
'textarea',
'select',
'option',
'svg',
'math'
]);
const SAFE_URL_PATTERN = /^(https?:|mailto:|tel:|\/|#|data:image\/(?:png|jpeg|jpg|gif|webp);base64,)/i;
const ALLOWED_STYLE_PROPS = new Set([
'background-color',
@@ -93,10 +110,10 @@ const sanitizeUrl = (value: string) => {
const sanitizeStyle = (value: string) => {
const declarations = value
.split(';')
.map((item) => item.trim())
.map(item => item.trim())
.filter(Boolean);
const safeDeclarations = declarations.flatMap((declaration) => {
const safeDeclarations = declarations.flatMap(declaration => {
const separatorIndex = declaration.indexOf(':');
if (separatorIndex <= 0) {
return [];
@@ -146,7 +163,7 @@ const sanitizeElement = (element: Element) => {
return;
}
Array.from(element.attributes).forEach((attr) => {
Array.from(element.attributes).forEach(attr => {
const attrName = attr.name.toLowerCase();
if (!shouldKeepAttr(tagName, attrName)) {
element.removeAttribute(attr.name);

View File

@@ -30,7 +30,9 @@ const move = (amount: number) => {
};
const position = () => {
return document.documentElement.scrollTop || (document.body.parentNode as HTMLElement).scrollTop || document.body.scrollTop;
return (
document.documentElement.scrollTop || (document.body.parentNode as HTMLElement).scrollTop || document.body.scrollTop
);
};
/**