Browse Source

修改Error组件 1️⃣ 移除了 "Report This Error" 按钮:删除了整个 <a> 标签和 IconButton 组件 不再链接到 GitHub Issues 页面;2️⃣点击 "Clear All Data" → 触发 showConfirm(Locale.Settings.Danger.Reset.Confirm) 的逻辑:移除了确认弹窗:不再调用 showConfirm() 函数,直接执行清除:点击按钮后直接调用 clearAndSaveData() 方法,简化了事件处理:从 async 函数改为普通函数,清理了导入:移除了不再使用的 showConfirm 导入

Ryuiso 3 months ago
parent
commit
e38935b712
1 changed files with 7 additions and 22 deletions
  1. 7 22
      app/components/error.tsx

+ 7 - 22
app/components/error.tsx

@@ -2,12 +2,9 @@
 
 import React from "react";
 import { IconButton } from "./button";
-import GithubIcon from "../icons/github.svg";
 import ResetIcon from "../icons/reload.svg";
-import { ISSUE_URL } from "../constant";
 import Locale from "../locales";
-import { showConfirm } from "./ui-lib";
-import { useSyncStore } from "../store/sync";
+
 
 interface IErrorBoundaryState {
   hasError: boolean;
@@ -27,12 +24,9 @@ export class ErrorBoundary extends React.Component<any, IErrorBoundaryState> {
   }
 
   clearAndSaveData() {
-    try {
-      useSyncStore.getState().export();
-    } finally {
-      localStorage.clear();
-      location.reload();
-    }
+    // 直接清除数据,不下载备份
+    localStorage.clear();
+    location.reload();
   }
 
   render() {
@@ -46,21 +40,12 @@ export class ErrorBoundary extends React.Component<any, IErrorBoundaryState> {
             <code>{this.state.info?.componentStack}</code>
           </pre>
 
-          <div style={{ display: "flex", justifyContent: "space-between" }}>
-            <a href={ISSUE_URL} className="report">
-              <IconButton
-                text="Report This Error"
-                icon={<GithubIcon />}
-                bordered
-              />
-            </a>
+          <div style={{ display: "flex", justifyContent: "center" }}>
             <IconButton
               icon={<ResetIcon />}
               text="Clear All Data"
-              onClick={async () => {
-                if (await showConfirm(Locale.Settings.Danger.Reset.Confirm)) {
-                  this.clearAndSaveData();
-                }
+              onClick={() => {
+                this.clearAndSaveData();
               }}
               bordered
             />