This commit is contained in:
Apcallover
2025-12-19 16:10:39 +08:00
10 changed files with 1658 additions and 1506 deletions

View File

@@ -82,6 +82,7 @@ const { userInfo } = storeToRefs(useUserStore());
const { getUserResume } = useUserStore();
const { dictLabel, oneDictData } = useDictStore();
const openSelectPopup = inject('openSelectPopup');
import { FileValidator } from '@/static/js/fileValidator.js'; //文件校验
const percent = ref('0%');
const state = reactive({
@@ -278,15 +279,26 @@ function selectAvatar() {
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
count: 1,
success: ({ tempFilePaths, tempFiles }) => {
$api.uploadFile(tempFilePaths[0], true)
.then((res) => {
res = JSON.parse(res);
if (res.msg) fromValue.avatar = res.msg;
})
.catch((err) => {
$api.msg('上传失败');
});
success: async (res) => {
const tempFilePaths = res.tempFilePaths;
const file = res.tempFiles[0];
const imageValidator = new FileValidator();
try {
await imageValidator.validate(file);
$api.uploadFile(tempFilePaths[0], true)
.then((res) => {
res = JSON.parse(res);
if (res.msg) fromValue.avatar = res.msg;
})
.catch((err) => {
$api.msg('上传失败');
});
} catch (error) {
$api.msg(error);
}
},
fail: (error) => {},
});