zxlie 5 mesiacov pred
rodič
commit
73b019f069

+ 1 - 1
apps/background/background.js

@@ -436,7 +436,7 @@ let BgPageInstance = (function () {
                                 if (['MAX_JSON_KEYS_NUMBER', 'JSON_FORMAT_THEME'].includes(key)) {
                                     result[key] = parseInt(result[key]);
                                 } else {
-                                    result[key] = (result[key] !== 'false');
+                                    result[key] = (""+result[key] !== 'false');
                                 }
                             });
                             callback && callback(result);

+ 1 - 1
apps/image-base64/index.html

@@ -19,7 +19,7 @@
                         </span>
                         <span class="x-switch" ref="btnSwitch" @click="trans">切换为{{toolName[nextType]}}&gt;&gt;</span>
                         <a class="x-other-tools" @click="openOptionsPage($event)"><i class="icon-plus-circle"></i> 探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>
-                        <span class="x-donate-link" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>打赏鼓励</a></span>
+                        <span class="x-donate-link" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>&nbsp;打赏鼓励</a></span>
                     </h3>
                 </div>
             </div>

+ 1 - 1
apps/json-diff/index.html

@@ -17,7 +17,7 @@
                             <img src="../static/img/fe-16.png" alt="fehelper"/> FeHelper</a>:JSON比对工具
                             
                         <a class="x-other-tools" @click="openOptionsPage($event)"><i class="icon-plus-circle"></i> 探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>
-                        <span class="x-donate-link" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>打赏鼓励</a></span>
+                        <span class="x-donate-link" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>&nbsp;打赏鼓励</a></span>
                     </h3>
                 </div>
             </div>

+ 36 - 9
apps/json-format/content-script.css

@@ -94,7 +94,8 @@ html.fh-jf .item .kv-list {
     margin-left: 2px
 }
 html.fh-jf .item .string {
-    word-wrap: break-word
+    word-wrap: break-word;
+    white-space: pre-wrap;
 }
 
 html.fh-jf .item .string a {
@@ -459,6 +460,8 @@ html.fh-jf .fe-feedback {
     float: right;
     cursor: pointer;
     font-weight: bold;
+    position: relative;
+    top: -2px;
 }
 
 .fe-feedback a {
@@ -578,29 +581,53 @@ html.fh-jf svg:not(:root) {
     color: #333;
     float: right;
     background-color: #f5f8ff;
-    padding: 5px 10px;
+    padding: 3px 10px;
     border-radius: 15px;
     border: 1px solid #d0d9ff;
     transition: all 0.3s ease;
     display: flex;
     align-items: center;
     position: relative;
-    top: -8px;
-    right: -10px;
+    top: -2px;
 }
 .fe-feedback>a.x-other-tools-us {
     display: none;
 }
-.x-toolbar>.x-donate-link {
-    margin-left: 20px;
+.fe-feedback>.x-donate-link {
+    line-height: 18px;
+    color: #2563eb;
+    cursor: pointer;
+    text-decoration: none;
+    border: none;
+    white-space: nowrap;
+    margin-right: auto;
+    border-radius: 20px;
+    background-color: #eff6ff;
+    transition: all 0.2s ease;
+    display: inline-flex;
+    align-items: center;
+    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.1);
+    padding: 4px 12px;
+    margin: 0 10px;
+    font-size: 12px;
+    font-weight: normal;
 }
-.x-toolbar>.x-donate-link-us {
+.fe-feedback>.x-donate-link-us {
     display: none;
 }
-.x-toolbar>.x-donate-link a:hover {
-    color: #f00;
+.fe-feedback>.x-donate-link a{
+    color: #333;
+    text-decoration: none;
+}
+.fe-feedback>.x-donate-link:hover {
+    background-color: #dbeafe;
+    color: #1d4ed8;
+    text-decoration: none;
+    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.15);
+    transform: translateY(-1px);
 }
 
+
 .fe-feedback>a.x-other-tools .icon-plus-circle {
     display: inline-block;
     width: 16px;

+ 20 - 20
apps/json-format/content-script.js

@@ -141,13 +141,13 @@ window.JsonAutoFormat = (() => {
             '    </span>' +
             '    <span class="x-fix-encoding"><span class="x-split">|</span><button class="xjf-btn" id="jsonGetCorrectCnt">乱码修正</button></span>' +
             '    <span id="optionBar"></span>' +
-            '    <span class="x-donate-link' + (isInUSA() ? ' x-donate-link-us' : '') + '"><a href="#" id="donateLink"><i class="nav-icon">❤</i>打赏鼓励</a></span>' +
             '    <span class="fe-feedback">' +
             '       <span class="x-settings"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 14 16" width="14">' +
             '           <path fill-rule="evenodd" d="M14 8.77v-1.6l-1.94-.64-.45-1.09.88-1.84-1.13-1.13-1.81.91-1.09-.45-.69-1.92h-1.6l-.63 1.94-1.11.45-1.84-.88-1.13 1.13.91 1.81-.45 1.09L0 7.23v1.59l1.94.64.45 1.09-.88 1.84 1.13 1.13 1.81-.91 1.09.45.69 1.92h1.59l.63-1.94 1.11-.45 1.84.88 1.13-1.13-.92-1.81.47-1.09L14 8.75v.02zM7 11c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3z"></path>' +
             '       </svg>高级定制</span>' +
-            '       <a class="x-other-tools' + (isInUSA() ? ' x-other-tools-us' : '') + '" style="cursor:pointer"><i class="icon-plus-circle">+</i>探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>' +
             '       <a id="toggleBtn" title="展开或收起工具栏">隐藏&gt;&gt;</a>' +
+            '       <span class="x-donate-link' + (isInUSA() ? ' x-donate-link-us' : '') + '"><a href="#" id="donateLink"><i class="nav-icon">❤</i>&nbsp;打赏鼓励</a></span>' +
+            '       <a class="x-other-tools' + (isInUSA() ? ' x-other-tools-us' : '') + '" style="cursor:pointer"><i class="icon-plus-circle">+</i>探索 <span class="tool-market-badge">工具市场</span></a>' +
             '    </span>' +
             '</div>',
             '<div id="formattingMsg"><span class="x-loading"></span>格式化中...</div>',
@@ -590,22 +590,25 @@ window.JsonAutoFormat = (() => {
 
         // 下面校验给定字符串是否为一个合法的json
         try {
-
             // 再看看是不是jsonp的格式
-            let reg = /^([\w\.]+)\(\s*([\s\S]*)\s*\)$/gm;
-            let reTry = /^(try\s*\{\s*)?/g;
-            let reCatch = /([;\s]*\}\s*catch\s*\(\s*\S+\s*\)\s*\{([\s\S])*\})?[;\s]*$/g;
-
-            // 检测是否有try-catch包裹
-            let sourceReplaced = source.replace(reTry, function () {
-                fnTry = fnTry ? fnTry : arguments[1];
-                return '';
-            }).replace(reCatch, function () {
-                fnCatch = fnCatch ? fnCatch : arguments[1];
-                return '';
-            }).trim();
-
-            let matches = reg.exec(sourceReplaced);
+            let reg = /^([\w\.]+)\(\s*([\s\S]*)\s*\)$/m;
+            // 优化后的 try/catch 包裹处理
+            fnTry = null;
+            fnCatch = null;
+            // 处理开头
+            if (source.startsWith('try {')) {
+                fnTry = 'try {';
+                source = source.slice(5).trimStart();
+            }
+            // 处理结尾
+            let catchIdx = source.lastIndexOf('} catch');
+            if (catchIdx !== -1) {
+                // 找到最后一个 } catch,截取到末尾
+                fnCatch = source.slice(catchIdx);
+                source = source.slice(0, catchIdx).trimEnd();
+            }
+            // 只做一次正则匹配
+            let matches = reg.exec(source);
             if (matches != null && (fnTry && fnCatch || !fnTry && !fnCatch)) {
                 funcName = matches[1];
                 source = matches[2];
@@ -615,11 +618,9 @@ window.JsonAutoFormat = (() => {
                     return;
                 }
             }
-
             // 这里可能会throw exception
             jsonObj = JSON.parse(source);
         } catch (ex) {
-
             // new Function的方式,能自动给key补全双引号,但是不支持bigint,所以是下下策,放在try-catch里搞
             try {
                 jsonObj = new Function("return " + source)();
@@ -641,7 +642,6 @@ window.JsonAutoFormat = (() => {
                 }
             }
         }
-
         try {
             // 要尽量保证格式化的东西一定是一个json,所以需要把内容进行JSON.stringify处理
             source = JSON.stringify(jsonObj);

+ 1 - 1
apps/json-format/index.html

@@ -21,7 +21,7 @@
                             <button id="btnLeftRight" ref="btnLeftRight" class="selected" @click="changeLayout('left-right')">左右布局</button><button id="btnUpDown" ref="btnUpDown" @click="changeLayout('up-down')">上下布局</button>
                         </span>
                         <a class="x-other-tools" v-if="!isInUSAFlag" @click="openOptionsPage($event)"><i class="icon-plus-circle"></i> 探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>
-                        <span class="x-donate-link" v-if="!isInUSAFlag" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>打赏鼓励</a></span>
+                        <span class="x-donate-link" v-if="!isInUSAFlag" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>&nbsp;打赏鼓励</a></span>
                     </h3>
                 </div>
             </div>

+ 1 - 1
apps/qr-code/index.html

@@ -20,7 +20,7 @@
                     </span>
                     <span class="x-switch" ref="btnSwitch" @click="trans">切换为{{!qrEncodeMode? ' 二维码生成器 ' : ' 解码/扫码 '}}模式&gt;&gt;</span>
                     <a class="x-other-tools" @click="openOptionsPage($event)"><i class="icon-plus-circle"></i> 探索更多实用工具 <span class="tool-market-badge">工具市场</span></a>
-                    <span class="x-donate-link" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>打赏鼓励</a></span>
+                    <span class="x-donate-link" @click="openDonateModal($event)"><a href="#" id="donateLink"><i class="nav-icon">❤</i>&nbsp;打赏鼓励</a></span>
                 </h3>
             </div>
         </div>

+ 2 - 5
apps/static/css/bootstrap.min.css

@@ -380,12 +380,9 @@ html.fh-jf input[type=radio], input[type=checkbox] {
 }
 
 .x-donate-link>a {
-    font-size: 12px;
-    color: blue;
-    cursor: pointer;
-    text-decoration: underline;
+    color: #333;
+    text-decoration: none;
 }
 .x-donate-link>a:hover {
-    text-decoration: underline;
     color: #f00;
 }