diff --git a/api/app.ts b/api/app.ts index b7938e4..06741f9 100644 --- a/api/app.ts +++ b/api/app.ts @@ -1,17 +1,4 @@ -import Request from "lib/utils/requests"; - +import { uploadApi } from "./common"; export default { - upload(data: any) { - return Request({ - url: "/admin/cmp_upload", - method: "post", - data, - params: { - expire: 24 * 30 * 12 * 10, - }, - headers: { - "Content-Type": "multipart/form-data", - }, - }).then(res => ({ data: {url: res.data} })) - }, + upload: uploadApi.upload }; diff --git a/api/common.ts b/api/common.ts index d4137a1..a0dde03 100644 --- a/api/common.ts +++ b/api/common.ts @@ -57,6 +57,8 @@ export const uploadApi = { headers: { "Content-Type": "multipart/form-data", }, + }).then(res => { + return {data: {url: res.data}} }) }, } diff --git a/api/config/list.ts b/api/config/list.ts index bbff9f1..3320c54 100644 --- a/api/config/list.ts +++ b/api/config/list.ts @@ -1,4 +1,5 @@ import Request from "lib/utils/requests"; +import { uploadApi } from "../common"; export default { getDataList(params: any) { return Request({ @@ -28,5 +29,6 @@ export default { data: params }) }, + upload: uploadApi.upload, } diff --git a/components/In18FormDialog.vue b/components/In18FormDialog.vue index d066b18..9e29f0c 100644 --- a/components/In18FormDialog.vue +++ b/components/In18FormDialog.vue @@ -19,8 +19,8 @@ - +
@@ -39,26 +39,26 @@
图片
-
视频
-
- + @updateValue="(val: any) => { formData[item.key] = val[0]?.url || '' }" />
@@ -87,11 +87,22 @@ v-model="formData.translations[primaryLocaleKey][item.key]" :placeholder="`请输入${item.name}`" /> + v-model="formData.translations[primaryLocaleKey][item.key]" type="textarea" :rows="4" + :placeholder="`请输入${item.name}`" /> + + + v-model="formData.translations[primaryLocaleKey][item.key]" :placeholder="`请选择${item.name}`" + clearable style="width: 100%"> @@ -109,11 +120,29 @@ {{ item.name }}
- + :rows="item.type === 'textarea' ? 4 : undefined" :placeholder="`请输入${item.name}`" /> + + + + + +
+
+ + @@ -146,11 +175,12 @@ import type { FormInstance, FormRules } from 'element-plus' import { ElMessage } from 'element-plus' import { Close, Promotion, FullScreen, CopyDocument } from '@element-plus/icons-vue' import UploadInput from "lib/components/UploadInput.vue"; - +import WangEditor from "lib/components/WangEditor.vue"; type FormItemType = | 'input' | 'select' | 'textarea' + | 'richtext' | 'upload:images,video' | 'upload:image,video' | 'upload:file' @@ -176,6 +206,7 @@ type LocaleItem = { const props = withDefaults( defineProps<{ + fullscreen: boolean show: boolean id: string | number title?: string @@ -186,6 +217,7 @@ const props = withDefaults( uploadFun?: (formData: FormData) => Promise }>(), { + fullscreen: false, show: false, id: '', title: '详情', @@ -245,9 +277,14 @@ const formData = reactive<{ const translating = ref(false) const translatingFieldKey = ref('') -const isFullscreen = ref(false) +const isFullscreen = ref(props.fullscreen || false) const detailLoading = ref(false) +const forceUpdateKey = ref(0) +function forceUpdate() { + forceUpdateKey.value++ +} + function toggleFullscreen() { isFullscreen.value = !isFullscreen.value } @@ -309,6 +346,7 @@ watch( detailLoading.value = true try { const data = await props.detailApi(Number(props.id)) + console.log('data', data) if (data) { const pKey = primaryLocaleKey.value Object.keys(data).forEach((localeKey) => { @@ -330,7 +368,9 @@ watch( console.error('Failed to load detail:', e) ElMessage.error('加载详情失败') } finally { - detailLoading.value = false + detailLoading.value = false; + // 强制刷新 + forceUpdate() } } } diff --git a/components/JsonFormDialog.vue b/components/JsonFormDialog.vue index 0158b9d..dab6536 100644 --- a/components/JsonFormDialog.vue +++ b/components/JsonFormDialog.vue @@ -1,3 +1,23 @@ + - +
+ :field-key="sKey" :field-map="fieldMap" :depth="0" :lang="lang" + :zh-parent="lang === 'EN' ? formData['ZH'] : undefined" />
@@ -34,6 +57,8 @@ @@ -42,22 +67,26 @@