Просмотр исходного кода

refactor: enhance SystemSetting submission logic and handle empty WorkerUrl

CaIon 10 месяцев назад
Родитель
Сommit
79c6dd08c9
2 измененных файлов с 7 добавлено и 3 удалено
  1. 6 3
      web/src/components/SystemSetting.js
  2. 1 0
      web/src/helpers/utils.js

+ 6 - 3
web/src/components/SystemSetting.js

@@ -203,10 +203,13 @@ const SystemSetting = () => {
 
 
   const submitWorker = async () => {
   const submitWorker = async () => {
     let WorkerUrl = removeTrailingSlash(inputs.WorkerUrl);
     let WorkerUrl = removeTrailingSlash(inputs.WorkerUrl);
-    await updateOptions([
+    const options = [
       { key: 'WorkerUrl', value: WorkerUrl },
       { key: 'WorkerUrl', value: WorkerUrl },
-      { key: 'WorkerValidKey', value: inputs.WorkerValidKey },
-    ]);
+    ]
+    if (inputs.WorkerValidKey !== '' || WorkerUrl === '') {
+      options.push({ key: 'WorkerValidKey', value: inputs.WorkerValidKey });
+    }
+    await updateOptions(options);
   };
   };
 
 
   const submitPayAddress = async () => {
   const submitPayAddress = async () => {

+ 1 - 0
web/src/helpers/utils.js

@@ -143,6 +143,7 @@ export function openPage(url) {
 }
 }
 
 
 export function removeTrailingSlash(url) {
 export function removeTrailingSlash(url) {
+  if (!url) return '';
   if (url.endsWith('/')) {
   if (url.endsWith('/')) {
     return url.slice(0, -1);
     return url.slice(0, -1);
   } else {
   } else {