perf: 视频批量上传处理
This commit is contained in:
@ -264,17 +264,19 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getCommentName = (item) => {
|
const getCommentName = (item) => {
|
||||||
if (item.commenter_id === 0) {
|
|
||||||
return '佚名';
|
|
||||||
}
|
|
||||||
// 姓名脱敏:保留首尾字符,中间拼接6个****
|
// 姓名脱敏:保留首尾字符,中间拼接6个****
|
||||||
const maskName = (name) => {
|
const maskName = (name) => {
|
||||||
if (!name || name.length <= 1) return name; // 单字符不脱敏
|
if (!name || name.length <= 1) return name; // 单字符不脱敏
|
||||||
return name[0] + '****' + name[name.length - 1];
|
return name[0] + '****' + name[name.length - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
// 手机号脱敏:保留前3位和后4位,中间4位替换为****
|
// 手机号脱敏:保留前3位和后4位,中间4位替换为****
|
||||||
const maskMobile = (mobile) => mobile?.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2');
|
const maskMobile = (mobile) => mobile?.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2');
|
||||||
|
|
||||||
|
if (item.commenter_id === 0) {
|
||||||
|
return item.commenter?.name ? maskName(item.commenter?.name) : '佚名';
|
||||||
|
}
|
||||||
|
|
||||||
const maskedName = maskName(item.commenter?.name);
|
const maskedName = maskName(item.commenter?.name);
|
||||||
const maskedMobile = maskMobile(item.commenter?.mobile);
|
const maskedMobile = maskMobile(item.commenter?.mobile);
|
||||||
return maskedName || maskedMobile;
|
return maskedName || maskedMobile;
|
||||||
|
|||||||
@ -55,6 +55,8 @@ export default {
|
|||||||
const taskStatus = ref(TASK_STATUS.DEFAULT);
|
const taskStatus = ref(TASK_STATUS.DEFAULT);
|
||||||
const form = ref(cloneDeep(INITIAL_FORM));
|
const form = ref(cloneDeep(INITIAL_FORM));
|
||||||
const works = ref([]);
|
const works = ref([]);
|
||||||
|
const uploadingFiles = ref([]); // 上传中
|
||||||
|
const uploadSuccessFiles = ref([]); // 上传成功
|
||||||
|
|
||||||
// 生成自增 id(基于当前列表中最大的 id)
|
// 生成自增 id(基于当前列表中最大的 id)
|
||||||
const getNextWorkId = () => {
|
const getNextWorkId = () => {
|
||||||
@ -65,8 +67,6 @@ export default {
|
|||||||
return currentMax + 1;
|
return currentMax + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 剪贴板功能
|
|
||||||
|
|
||||||
const isLink = computed(() => uploadType.value === UPLOAD_TYPE.LINK);
|
const isLink = computed(() => uploadType.value === UPLOAD_TYPE.LINK);
|
||||||
const isLocal = computed(() => uploadType.value === UPLOAD_TYPE.LOCAL);
|
const isLocal = computed(() => uploadType.value === UPLOAD_TYPE.LOCAL);
|
||||||
const isDefault = computed(() => taskStatus.value === TASK_STATUS.DEFAULT);
|
const isDefault = computed(() => taskStatus.value === TASK_STATUS.DEFAULT);
|
||||||
@ -90,6 +90,8 @@ export default {
|
|||||||
taskStatus.value = TASK_STATUS.DEFAULT;
|
taskStatus.value = TASK_STATUS.DEFAULT;
|
||||||
form.value = cloneDeep(INITIAL_FORM);
|
form.value = cloneDeep(INITIAL_FORM);
|
||||||
works.value = [];
|
works.value = [];
|
||||||
|
uploadingFiles.value = [];
|
||||||
|
uploadSuccessFiles.value = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const open = () => {
|
const open = () => {
|
||||||
@ -137,6 +139,8 @@ export default {
|
|||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
uploadingFiles.value.push(file);
|
||||||
|
|
||||||
const { code, data } = await postWorksByFileWriter(formData, {
|
const { code, data } = await postWorksByFileWriter(formData, {
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
headers: {
|
headers: {
|
||||||
@ -145,10 +149,15 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
taskStatus.value = TASK_STATUS.SUCCESS;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const id = data.id ?? getNextWorkId();
|
const id = data.id ?? getNextWorkId();
|
||||||
works.value.push({ ...data, id });
|
const _data = { ...data, id };
|
||||||
|
works.value.push(_data);
|
||||||
|
uploadSuccessFiles.value.push(_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uploadingFiles.value.length === uploadSuccessFiles.value.length) {
|
||||||
|
taskStatus.value = TASK_STATUS.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,6 +50,8 @@ export default {
|
|||||||
const uploadType = ref(UPLOAD_TYPE.LINK);
|
const uploadType = ref(UPLOAD_TYPE.LINK);
|
||||||
const taskStatus = ref(TASK_STATUS.DEFAULT);
|
const taskStatus = ref(TASK_STATUS.DEFAULT);
|
||||||
const form = ref(cloneDeep(INITIAL_FORM));
|
const form = ref(cloneDeep(INITIAL_FORM));
|
||||||
|
const uploadingFiles = ref([]); // 上传中
|
||||||
|
const uploadSuccessFiles = ref([]); // 上传成功
|
||||||
const works = ref([]);
|
const works = ref([]);
|
||||||
|
|
||||||
// 生成自增 id(基于当前列表中最大的 id)
|
// 生成自增 id(基于当前列表中最大的 id)
|
||||||
@ -87,6 +89,8 @@ export default {
|
|||||||
taskStatus.value = TASK_STATUS.DEFAULT;
|
taskStatus.value = TASK_STATUS.DEFAULT;
|
||||||
form.value = cloneDeep(INITIAL_FORM);
|
form.value = cloneDeep(INITIAL_FORM);
|
||||||
works.value = [];
|
works.value = [];
|
||||||
|
uploadingFiles.value = [];
|
||||||
|
uploadSuccessFiles.value = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWriterLink = async () => {
|
const getWriterLink = async () => {
|
||||||
@ -160,6 +164,8 @@ export default {
|
|||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
|
uploadingFiles.value.push(file);
|
||||||
|
|
||||||
const { code, data } = await postWorksByFile(formData, {
|
const { code, data } = await postWorksByFile(formData, {
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
headers: {
|
headers: {
|
||||||
@ -167,10 +173,15 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (code === 200) {
|
if (code === 200) {
|
||||||
taskStatus.value = TASK_STATUS.SUCCESS;
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const id = data.id ?? getNextWorkId();
|
const id = data.id ?? getNextWorkId();
|
||||||
works.value.push({ ...data, id });
|
const _data = { ...data, id };
|
||||||
|
works.value.push(_data);
|
||||||
|
uploadSuccessFiles.value.push(_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uploadingFiles.value.length === uploadSuccessFiles.value.length) {
|
||||||
|
taskStatus.value = TASK_STATUS.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user