mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 用户管理优化头像上传
This commit is contained in:
@@ -185,7 +185,8 @@ function install(app: App, options: any = {}) {
|
||||
defaultType: "form",
|
||||
form: {
|
||||
keepName: true,
|
||||
action: "http://www.docmirror.cn:7070/api/upload/form/upload",
|
||||
type: "form",
|
||||
action: "/basic/file/upload",
|
||||
name: "file",
|
||||
withCredentials: false,
|
||||
uploadRequest: async ({ action, file, onProgress }: any) => {
|
||||
@@ -205,12 +206,8 @@ function install(app: App, options: any = {}) {
|
||||
}
|
||||
});
|
||||
},
|
||||
successHandle(ret: any) {
|
||||
// 上传完成后的结果处理, 此处应返回格式为{url:xxx}
|
||||
return {
|
||||
url: "http://www.docmirror.cn:7070" + ret,
|
||||
key: ret.replace("/api/upload/form/download?key=", "")
|
||||
};
|
||||
successHandle(res: any) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as api from "./api";
|
||||
import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud";
|
||||
import { useUserStore } from "/@/store/modules/user";
|
||||
|
||||
export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
||||
const pageRequest = async (query: UserPageQuery): Promise<UserPageRes> => {
|
||||
@@ -17,6 +18,8 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
return await api.AddObj(form);
|
||||
};
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
||||
return {
|
||||
crudOptions: {
|
||||
request: {
|
||||
@@ -114,6 +117,35 @@ export default function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOpti
|
||||
style: {
|
||||
height: "30px",
|
||||
width: "auto"
|
||||
},
|
||||
buildUrl(key: string) {
|
||||
return `/api/basic/file/download?&key=` + key;
|
||||
}
|
||||
}
|
||||
},
|
||||
form: {
|
||||
component: {
|
||||
vModel: "modelValue",
|
||||
valueType: "key",
|
||||
cropper: {
|
||||
aspectRatio: 1,
|
||||
autoCropArea: 1,
|
||||
viewMode: 0
|
||||
},
|
||||
onReady: null,
|
||||
uploader: {
|
||||
type: "form",
|
||||
action: "/basic/file/upload",
|
||||
name: "file",
|
||||
headers: {
|
||||
Authorization: "Bearer " + userStore.getToken
|
||||
},
|
||||
successHandle(res: any) {
|
||||
return res;
|
||||
}
|
||||
},
|
||||
buildUrl(key: string) {
|
||||
return `/api/basic/file/download?&key=` + key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user