|
@@ -173,27 +173,44 @@ const open = async (id?: number) => {
|
|
|
}
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
+const imageUrls = ref<string[]>([]);
|
|
|
/** 提交表单 */
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
const submitForm = async () => {
|
|
|
// 校验表单
|
|
|
- console.log(formData.value,'提交的表单');
|
|
|
if (!formRef) return
|
|
|
const valid = await formRef.value.validate()
|
|
|
if (!valid) return
|
|
|
// 提交请求
|
|
|
formLoading.value = true
|
|
|
try {
|
|
|
- const data = formData.value as unknown as UserProfileUpdateReqVO
|
|
|
- await updateUserProfile(data)
|
|
|
+ const content = formData.value.remark; // 获取富文本内容
|
|
|
+ imageUrls.value = extractImages(content);
|
|
|
+ const data = {
|
|
|
+ ...formData.value,
|
|
|
+ remark: content,
|
|
|
+ } as unknown as UserProfileUpdateReqVO
|
|
|
+ await updateUserProfile(data)
|
|
|
+ message.success(t('common.updateSuccess'));
|
|
|
dialogVisible.value = false
|
|
|
- // 发送操作成功的事件
|
|
|
- emit('success')
|
|
|
+ emit('success' , imageUrls.value)
|
|
|
} finally {
|
|
|
formLoading.value = false
|
|
|
}
|
|
|
+ console.log(formData.value,'提交的表单');
|
|
|
}
|
|
|
|
|
|
+const extractImages = (htmlContent: string): string[] => {
|
|
|
+ const imgRegex = /<img[^>]+src="([^">]+)"/g;
|
|
|
+ let images: string[] = []; // 明确声明 images 数组的类型为 string[]
|
|
|
+ let match;
|
|
|
+ while ((match = imgRegex.exec(htmlContent)) !== null) {
|
|
|
+ images.push(match[1]); // match[1] 是图片URL
|
|
|
+ }
|
|
|
+ return images;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
/** 重置表单 */
|
|
|
const resetForm = () => {
|
|
|
formData.value = {
|