Browse Source

feat: update

gemercheung 6 months ago
parent
commit
9773a13463
2 changed files with 17 additions and 20 deletions
  1. 1 1
      src/setSystem.ts
  2. 16 19
      src/view/setting/index.vue

+ 1 - 1
src/setSystem.ts

@@ -28,7 +28,7 @@ axios.get(getSysSetting, {
 }).then((data) => {
   systemData.value.name = data.data.title;
   systemData.value.color = data.data.themeColour;
-  console.log('获取当前色',data.data.themeColour)
+  console.log('获取后台当前色',data.data.themeColour)
   localStorage.setItem('f-themeColour', data.data.themeColour)
   refresh();
 });

+ 16 - 19
src/view/setting/index.vue

@@ -5,26 +5,13 @@
   <div class="body-layer" style="padding: 24px" v-loading="loading">
     <el-form :model="form" label-width="auto" style="max-width: 600px">
       <el-form-item label="系统标题">
-        <el-input
-          v-model="form.name"
-          placeholder="请输入系统标题"
-          :maxlength="100"
-          show-word-limit
-        />
+        <el-input v-model="form.name" placeholder="请输入系统标题" :maxlength="100" show-word-limit />
       </el-form-item>
       <el-form-item label="系统主题色">
-      当前:  {{ form.color }}
+
         <el-radio-group v-model="form.color">
-          <el-radio
-            :value="color"
-            :label="color"
-            size="large"
-            v-for="color in themeColors"
-          >
-            <span
-              class="radio-box"
-              :style="{ 'background-color': '#' + color }"
-            ></span>
+          <el-radio :value="color" :label="color" size="large" v-for="color in themeColors">
+            <span class="radio-box" :style="{ 'background-color': '#' + color }"></span>
           </el-radio>
         </el-radio-group>
       </el-form-item>
@@ -38,14 +25,24 @@
 <script setup lang="ts">
 import comHead from "@/components/head/index.vue";
 import { setTheme, setTitle, systemData, themeColors } from "@/setSystem";
+import { watchEffect } from "vue";
 
-import { reactive, ref } from "vue";
+import { reactive, ref, watch } from "vue";
 
 // do not use same name with ref
 const form = reactive({
-  ...systemData.value,
+  name: "",
+  color: ""
 });
 
+watchEffect(() => {
+  if (systemData.value) {
+    console.log('前台更新', systemData.value)
+    form.color = systemData.value.color
+    form.name = systemData.value.name
+  }
+})
+
 const loading = ref(false);
 const onSubmit = async () => {
   loading.value = true;