Procházet zdrojové kódy

增加options页面的hotfix.json逻辑

zxlie před 4 měsíci
rodič
revize
5c4cb7b758
3 změnil soubory, kde provedl 71 přidání a 38 odebrání
  1. 33 0
      apps/options/index.js
  2. 0 38
      website/static/js/hotfix.js
  3. 38 0
      website/static/js/hotfix.json

+ 33 - 0
apps/options/index.js

@@ -118,6 +118,9 @@ new Vue({
         // 检查版本更新
         this.checkVersionUpdate();
         
+        // 加载远程推荐卡片配置
+        this.loadRemoteRecommendationCards();
+        
         // 检查URL中是否有donate_from参数
         this.checkDonateParam();
 
@@ -1198,6 +1201,35 @@ new Vue({
                 this.installTool(card.toolKey);
             }
         },
+
+        // 加载远程推荐卡片配置
+        async loadRemoteRecommendationCards() {
+            try {
+                // 使用fetch获取远程配置
+                const response = await fetch('https://baidufe.com/fehelper/static/js/hotfix.json?v=' + Date.now());
+                if (!response.ok) {
+                    throw new Error(`获取远程配置失败: ${response.status}`);
+                }
+                
+                // 获取脚本内容
+                const scriptContent = await response.text();
+                
+                // 解析脚本内容,提取GlobalRecommendationCards变量
+                let remoteCards = null;
+                try {
+                    remoteCards = JSON.parse(scriptContent);
+                } catch (parseError) {
+                    console.error('解析远程推荐卡片配置失败:', parseError);
+                }
+                
+                // 如果成功解析到配置,则更新本地配置
+                if (remoteCards && Array.isArray(remoteCards) && remoteCards.length > 0) {
+                    this.recommendationCards = remoteCards;
+                }
+            } catch (error) {
+                console.error('获取远程推荐卡片配置失败:', error);
+            }
+        },
     },
 
     watch: {
@@ -1243,3 +1275,4 @@ window.addEventListener('scroll', () => {
 if (window.chrome && chrome.runtime && chrome.runtime.sendMessage) {
     Awesome.collectAndSendClientInfo();
 } 
+

+ 0 - 38
website/static/js/hotfix.js

@@ -1,38 +0,0 @@
-const GlobalRecommendationCards = [
-    {
-        toolKey: 'qr-code',
-        icon: '📱',
-        title: '二维码工具',
-        desc: '快速生成和识别二维码,支持自定义样式',
-        tag: '必装',
-        tagClass: 'must-tag',
-        isAd: false
-    },
-    {
-        toolKey: 'chart-maker',
-        icon: '📊',
-        title: '图表制作工具',
-        desc: '支持多种数据可视化图表,快速生成专业图表',
-        tag: '最新',
-        tagClass: 'new-tag',
-        isAd: false
-    },
-    {
-        toolKey: 'poster-maker',
-        icon: '🖼️',
-        title: '海报快速生成',
-        desc: '快速生成和识别二维码,支持自定义样式',
-        tag: '推荐',
-        tagClass: 'recommend-tag',
-        isAd: false
-    },
-    {
-        icon: '🔔',
-        title: '推广位',
-        desc: '广告位招租,欢迎流量主联系,开放合作,流量主请到github联系',
-        tag: '广告',
-        tagClass: 'ad-tag',
-        isAd: true,
-        url: 'https://github.com/zxlie/FeHelper'
-    }
-];

+ 38 - 0
website/static/js/hotfix.json

@@ -0,0 +1,38 @@
+[
+    {
+        "toolKey": "qr-code",
+        "icon": "📱",
+        "title": "二维码工具",
+        "desc": "快速生成和识别二维码,支持自定义样式",
+        "tag": "必装",
+        "tagClass": "must-tag",
+        "isAd": false
+    },
+    {
+        "toolKey": "chart-maker",
+        "icon": "📊",
+        "title": "图表制作工具",
+        "desc": "支持多种数据可视化图表,快速生成专业图表",
+        "tag": "最新",
+        "tagClass": "new-tag",
+        "isAd": false
+    },
+    {
+        "toolKey": "poster-maker",
+        "icon": "🖼️",
+        "title": "海报快速生成",
+        "desc": "快速生成和识别二维码,支持自定义样式",
+        "tag": "推荐",
+        "tagClass": "recommend-tag",
+        "isAd": false
+    },
+    {
+        "icon": "🔔",
+        "title": "推广位",
+        "desc": "广告位招租,欢迎流量主联系,开放合作,流量主请到github联系",
+        "tag": "广告",
+        "tagClass": "ad-tag",
+        "isAd": true,
+        "url": "https://github.com/zxlie/FeHelper/issues/412"
+    }
+]