style: 统一代码格式和类型定义,测试eslint --fix, 还是有报错

This commit is contained in:
feige996
2025-06-21 16:56:24 +08:00
parent 9cf0c212bf
commit 227f19a93c
40 changed files with 396 additions and 367 deletions

View File

@@ -21,7 +21,7 @@ import { toast } from './toast'
*/
export const uploadFileUrl = {
/** 用户头像上传地址 */
USER_AVATAR: import.meta.env.VITE_SERVER_BASEURL + '/user/avatar',
USER_AVATAR: `${import.meta.env.VITE_SERVER_BASEURL}/user/avatar`,
}
/**
@@ -31,12 +31,7 @@ export const uploadFileUrl = {
* @param formData 额外表单数据
* @param options 上传选项
*/
export const useFileUpload = <T = string>(
url: string,
filePath: string,
formData: Record<string, any> = {},
options: Omit<UploadOptions, 'sourceType' | 'sizeType' | 'count'> = {},
) => {
export function useFileUpload<T = string>(url: string, filePath: string, formData: Record<string, any> = {}, options: Omit<UploadOptions, 'sourceType' | 'sizeType' | 'count'> = {}) {
return useUpload<T>(
url,
formData,
@@ -76,13 +71,9 @@ export interface UploadOptions {
* @param options 上传选项
* @returns 上传状态和控制对象
*/
export const useUpload = <T = string>(
url: string,
formData: Record<string, any> = {},
options: UploadOptions = {},
export function useUpload<T = string>(url: string, formData: Record<string, any> = {}, options: UploadOptions = {},
/** 直接传入文件路径,跳过选择器 */
directFilePath?: string,
) => {
directFilePath?: string) {
/** 上传中状态 */
const loading = ref(false)
/** 上传错误状态 */
@@ -161,7 +152,8 @@ export const useUpload = <T = string>(
success: (res) => {
const file = res.tempFiles[0]
// 检查文件大小是否符合限制
if (!checkFileSize(file.size)) return
if (!checkFileSize(file.size))
return
// 开始上传
loading.value = true
@@ -295,7 +287,8 @@ function uploadFile<T>({
// 上传成功
data.value = _data as T
onSuccess?.(_data)
} catch (err) {
}
catch (err) {
// 响应解析错误
console.error('解析上传响应失败:', err)
error.value = true
@@ -320,7 +313,8 @@ function uploadFile<T>({
progress.value = res.progress
onProgress?.(res.progress)
})
} catch (err) {
}
catch (err) {
// 创建上传任务失败
console.error('创建上传任务失败:', err)
error.value = true