xiongzhu il y a 2 ans
Parent
commit
ef4673b5ed
1 fichiers modifiés avec 20 ajouts et 21 suppressions
  1. 20 21
      src/views/HomeView.vue

+ 20 - 21
src/views/HomeView.vue

@@ -10,35 +10,35 @@
                     :on-success="onSuccess"
                     :on-error="onError"
                 >
-                    <template v-if="model.appInfo.url">
+                    <template v-if="model.value.appInfo.url">
                         <br />
-                        <ElLink :href="model.appInfo.url" target="_blank">{{ model.appInfo.url }}</ElLink>
+                        <ElLink :href="model.value.appInfo.url" target="_blank">{{ model.value.appInfo.url }}</ElLink>
                     </template>
                     <template #trigger>
                         <ElButton :loading="uploading">上传</ElButton>
                     </template>
                 </ElUpload>
             </ElFormItem>
-            <ElFormItem label="版本号">
-                <ElInput v-model="model.appInfo.package" disabled />
+            <ElFormItem label="包名">
+                <ElInput v-model="model.value.appInfo.packageName" disabled />
             </ElFormItem>
             <ElFormItem label="版本名">
-                <ElInput v-model="model.appInfo.versionName" disabled />
+                <ElInput v-model="model.value.appInfo.versionName" disabled />
             </ElFormItem>
             <ElFormItem label="版本号">
-                <ElInput v-model="model.appInfo.versionCode" disabled />
+                <ElInput v-model="model.value.appInfo.versionCode" disabled />
             </ElFormItem>
             <ElFormItem label="开屏广告">
-                <SingleUpload v-model="model.splash.imageUrl" />
+                <SingleUpload v-model="model.value.splash.imageUrl" />
             </ElFormItem>
             <ElFormItem label="跳转地址">
-                <ElInput v-model="model.splash.url" />
+                <ElInput v-model="model.value.splash.url" />
             </ElFormItem>
             <ElFormItem label="列表广告">
-                <SingleUpload v-model="model.banner.imageUrl" />
+                <SingleUpload v-model="model.value.banner.imageUrl" />
             </ElFormItem>
             <ElFormItem label="跳转地址">
-                <ElInput v-model="model.banner.url" />
+                <ElInput v-model="model.value.banner.url" />
             </ElFormItem>
             <ElButton @click="save" type="primary" :loading="loading">保存</ElButton>
         </ElForm>
@@ -52,24 +52,24 @@ import SingleUpload from '@/components/SingleUpload.vue'
 import { http } from '@/plugins/http'
 import { ElMessage } from 'element-plus'
 const uploadUrl = resolveUrl(import.meta.env.VITE_API_BASE_URL, '/api/file/upload')
-const model = ref({ appInfo: {}, splash: {}, banner: {} })
-const uploading = ref(false)
-const loading = ref(false)
-const record = ref({
+const model = ref({
     type: 'object',
-    name: 'app'
+    name: 'app',
+    value: { appInfo: {}, splash: {}, banner: {} }
 })
+const uploading = ref(false)
+const loading = ref(false)
+
 http.get('/sys-config/app').then((res) => {
-    model.value = JSON.parse(res.value)
-    record.value = res
+    model.value = res
 })
 async function beforeUpload(file) {
     const parser = new AppInfoParser(file)
     try {
         const info = await parser.parse()
         console.log(info)
-        model.value.appInfo = {
-            package: info.package,
+        model.value.value.appInfo = {
+            package: info.packageName,
             versionCode: info.versionCode,
             versionName: info.versionName
         }
@@ -90,8 +90,7 @@ function onError(e) {
 }
 function save() {
     loading.value = true
-    record.value.value = JSON.stringify(model.value)
-    http.put('/admin/sys-config', record.value).then((res) => {
+    http.put('/admin/sys-config', model.value).then((res) => {
         loading.value = false
         ElMessage.success('保存成功')
     })