From c75027743ea7c3ecc2d0885f01d11d2ad78679a3 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期五, 23 十月 2026 14:23:26 +0800
Subject: [PATCH] Merge branch 'yxh' of http://116.62.18.175:6699/r/~yxh/opo-web

---
 src/components/ThemePicker/index.vue |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue
index 1714e1f..83e030e 100644
--- a/src/components/ThemePicker/index.vue
+++ b/src/components/ThemePicker/index.vue
@@ -1,7 +1,7 @@
 <template>
   <el-color-picker
     v-model="theme"
-    :predefine="['#409EFF', '#1890ff', '#304156','#212121','#11a983', '#13c2c2', '#6959CD', '#f5222d', ]"
+    :predefine="['#0E768F', '#CD1D4E', '#409EFF', '#1B8E70', '#7B61FF', '#E6843C', '#304156', '#212121']"
     class="theme-picker"
     popper-class="theme-picker-dropdown"
   />
@@ -42,8 +42,12 @@
 
   methods: {
     async setTheme(val) {
-      const oldVal = this.chalk ? this.theme : ORIGINAL_THEME
       if (typeof val !== 'string') return
+      // 鍏堥�氱煡澶栧眰锛氫富棰樿壊鐢� CSS 鍙橀噺灞傦紙utils/theme.js锛夌珛鍗崇敓鏁堛��
+      // 鍘熸潵鐨勫疄鐜拌绛� CDN 鎷夊彇 theme-chalk 瀹屾垚鍚庢墠 emit锛屽唴缃戞媺涓嶅埌 unpkg
+      // 鏃� Promise 姘镐笉 resolve锛屽鑷�"鏀逛富棰樻病鏈変换浣曞弽搴�"銆�
+      this.$emit('change', val)
+      const oldVal = this.chalk ? this.theme : ORIGINAL_THEME
       const themeCluster = this.getThemeCluster(val.replace('#', ''))
       const originalCluster = this.getThemeCluster(oldVal.replace('#', ''))
 
@@ -81,8 +85,6 @@
         if (typeof innerText !== 'string') return
         style.innerText = this.updateStyle(innerText, originalCluster, themeCluster)
       })
-
-      this.$emit('change', val)
     },
 
     updateStyle(style, oldCluster, newCluster) {
@@ -96,12 +98,19 @@
     getCSSString(url, variable) {
       return new Promise(resolve => {
         const xhr = new XMLHttpRequest()
+        const done = () => resolve()
         xhr.onreadystatechange = () => {
-          if (xhr.readyState === 4 && xhr.status === 200) {
-            this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '')
+          if (xhr.readyState === 4) {
+            if (xhr.status === 200) {
+              this[variable] = xhr.responseText.replace(/@font-face{[^}]+}/, '')
+            }
             resolve()
           }
         }
+        // 鍐呯綉/鏃犲缃戞椂蹇�熷け璐ワ紝閬垮厤 Promise 鎮寕瀵艰嚧鎹㈣偆鍗′綇
+        xhr.onerror = done
+        xhr.ontimeout = done
+        xhr.timeout = 4000
         xhr.open('GET', url)
         xhr.send()
       })

--
Gitblit v1.9.3