Bläddra i källkod

Merge pull request #1870 from visuddhinanda/agile

notification 查询过程提取为 queryNotification函数
visuddhinanda 2 år sedan
förälder
incheckning
b835206225

+ 3 - 3
dashboard/src/components/export/ExportModal.tsx

@@ -70,16 +70,16 @@ const ExportModalWidget = ({
     filenameRef.current = filename;
   });
   const queryStatus = () => {
-    console.log("timer", filenameRef.current);
+    console.debug("timer", filenameRef.current);
     if (typeof filenameRef.current === "undefined") {
       return;
     }
     const url = `/v2/export/${filenameRef.current}`;
-    console.log("url", url);
+    console.info("export url", url);
     get<IExportStatusResponse>(url)
       .then((json) => {
         if (json.ok) {
-          console.log("filename", json);
+          console.info("filename", json);
           setExportStatus(json.data.status);
           if (json.data.status.progress === 1) {
             setFilename(undefined);

+ 50 - 52
dashboard/src/components/notification/NotificationIcon.tsx

@@ -11,65 +11,63 @@ const NotificationIconWidget = () => {
   const [count, setCount] = useState<number>();
   const user = useAppSelector(currentUser);
 
-  useEffect(() => {
-    let timer = setInterval(() => {
-      if (!user) {
-        console.debug("未登录 不查询 notification");
-        return;
-      }
-      const now = new Date();
-      const notificationUpdatedAt = localStorage.getItem(
-        "notification/updatedAt"
-      );
-      if (notificationUpdatedAt) {
-        if (now.getTime() - parseInt(notificationUpdatedAt) < 59000) {
-          const notificationCount = localStorage.getItem("notification/count");
-          if (notificationCount !== null) {
-            setCount(parseInt(notificationCount));
-            console.debug("has notification count");
-            return;
-          }
+  const queryNotification = () => {
+    if (!user) {
+      console.debug("未登录 不查询 notification");
+      return;
+    }
+    const now = new Date();
+    const notificationUpdatedAt = localStorage.getItem(
+      "notification/updatedAt"
+    );
+    if (notificationUpdatedAt) {
+      if (now.getTime() - parseInt(notificationUpdatedAt) < 59000) {
+        const notificationCount = localStorage.getItem("notification/count");
+        if (notificationCount !== null) {
+          setCount(parseInt(notificationCount));
+          console.debug("has notification count");
+          return;
         }
       }
+    }
 
-      const url = `/v2/notification?view=to&status=unread&limit=1`;
-      console.info("notification url", url);
-      get<INotificationListResponse>(url).then((json) => {
-        if (json.ok) {
-          localStorage.setItem(
-            "notification/updatedAt",
-            now.getTime().toString()
-          );
-          localStorage.setItem(
-            "notification/count",
-            json.data.count.toString()
-          );
-          setCount(json.data.count);
-          if (json.data.count > 0) {
-            const newMessageTime = json.data.rows[0].created_at;
-            const lastTime = localStorage.getItem("notification/new");
-            if (lastTime === null || lastTime !== newMessageTime) {
-              localStorage.setItem("notification/new", newMessageTime);
-              if (window.Notification && Notification.permission !== "denied") {
-                Notification.requestPermission(function (status) {
-                  const notification = new Notification("通知标题", {
-                    body: json.data.rows[0].content,
-                    icon:
-                      process.env.REACT_APP_API_HOST +
-                      "/assets/images/wikipali_logo.png",
-                    tag: json.data.rows[0].id,
-                  });
-                  notification.onclick = (event) => {
-                    event.preventDefault(); // 阻止浏览器聚焦于 Notification 的标签页
-                    window.open(json.data.rows[0].url, "_blank");
-                  };
+    const url = `/v2/notification?view=to&status=unread&limit=1`;
+    console.info("notification url", url);
+    get<INotificationListResponse>(url).then((json) => {
+      if (json.ok) {
+        localStorage.setItem(
+          "notification/updatedAt",
+          now.getTime().toString()
+        );
+        localStorage.setItem("notification/count", json.data.count.toString());
+        setCount(json.data.count);
+        if (json.data.count > 0) {
+          const newMessageTime = json.data.rows[0].created_at;
+          const lastTime = localStorage.getItem("notification/new");
+          if (lastTime === null || lastTime !== newMessageTime) {
+            localStorage.setItem("notification/new", newMessageTime);
+            if (window.Notification && Notification.permission !== "denied") {
+              Notification.requestPermission(function (status) {
+                const notification = new Notification("通知标题", {
+                  body: json.data.rows[0].content,
+                  icon:
+                    process.env.REACT_APP_API_HOST +
+                    "/assets/images/wikipali_logo.png",
+                  tag: json.data.rows[0].id,
                 });
-              }
+                notification.onclick = (event) => {
+                  event.preventDefault(); // 阻止浏览器聚焦于 Notification 的标签页
+                  window.open(json.data.rows[0].url, "_blank");
+                };
+              });
             }
           }
         }
-      });
-    }, 1000 * 60);
+      }
+    });
+  };
+  useEffect(() => {
+    let timer = setInterval(() => queryNotification(), 1000 * 60);
     return () => {
       clearInterval(timer);
     };

+ 4 - 2
dashboard/src/components/term/TermItem.tsx

@@ -12,7 +12,7 @@ import TimeShow from "../general/TimeShow";
 import TermModal from "./TermModal";
 import { useState } from "react";
 import StudioName from "../auth/StudioName";
-import { useNavigate } from "react-router-dom";
+import { Link, useNavigate } from "react-router-dom";
 
 const { Text } = Typography;
 
@@ -29,7 +29,9 @@ const TermItemWidget = ({ data }: IWidget) => {
         title={
           <Space direction="vertical" size={3}>
             <Space>
-              <Text strong>{data?.meaning}</Text>
+              <Link to={`/term/show/${data?.guid}`}>
+                <Text strong>{data?.meaning}</Text>
+              </Link>
               <Text type="secondary">{data?.other_meaning}</Text>
             </Space>
             <Space style={{ fontSize: "80%" }}>

+ 95 - 95
dashboard/src/locales/en-US/dict/index.ts

@@ -1,83 +1,83 @@
 const items = {
   dict: "字典",
-  "dict.fields.sn.label": "序号",
-  "dict.fields.word.label": "单词",
-  "dict.fields.type.label": "类型",
-  "dict.fields.grammar.label": "语法",
+  "dict.fields.sn.label": "serial",
+  "dict.fields.word.label": "word",
+  "dict.fields.type.label": "type",
+  "dict.fields.grammar.label": "grammar",
   "dict.fields.case.label": "格位",
-  "dict.fields.parent.label": "词干",
-  "dict.fields.meaning.label": "意思",
-  "dict.fields.factors.label": "组份",
+  "dict.fields.parent.label": "base",
+  "dict.fields.meaning.label": "meaning",
+  "dict.fields.factors.label": "factors",
   "dict.fields.factormeaning.label": "组份意思",
-  "dict.fields.note.label": "注释",
-  "dict.fields.confidence.label": "信心指数",
-  "dict.fields.dictname.label": "字典名称",
-  "dict.fields.type.n.label": "名词",
-  "dict.fields.type.n.short.label": "",
-  "dict.fields.type.ti.label": "三性",
-  "dict.fields.type.ti.short.label": "",
-  "dict.fields.type.v.label": "动词",
-  "dict.fields.type.v.short.label": "",
+  "dict.fields.note.label": "note",
+  "dict.fields.confidence.label": "confidence",
+  "dict.fields.dictname.label": "name",
+  "dict.fields.type.n.label": "noun",
+  "dict.fields.type.n.short.label": "n.",
+  "dict.fields.type.ti.label": "ti.",
+  "dict.fields.type.ti.short.label": "ti.",
+  "dict.fields.type.v.label": "verb",
+  "dict.fields.type.v.short.label": "v.",
   "dict.fields.type.v:ind.label": "动不变",
-  "dict.fields.type.v:ind.short.label": "动不变",
+  "dict.fields.type.v:ind.short.label": "v. ind.",
   "dict.fields.type.ind.label": "不变",
   "dict.fields.type.ind.short.label": "不",
-  "dict.fields.type.m.label": "阳性",
-  "dict.fields.type.m.short.label": "",
-  "dict.fields.type.nt.label": "中性",
-  "dict.fields.type.nt.short.label": "",
-  "dict.fields.type.f.label": "阴性",
-  "dict.fields.type.f.short.label": "",
-  "dict.fields.type.sg.label": "单数",
-  "dict.fields.type.sg.short.label": "",
-  "dict.fields.type.pl.label": "复数",
-  "dict.fields.type.pl.short.label": "",
-  "dict.fields.type.nom.label": "主格",
-  "dict.fields.type.nom.short.label": "",
-  "dict.fields.type.acc.label": "宾格",
-  "dict.fields.type.acc.short.label": "",
-  "dict.fields.type.gen.label": "属格",
-  "dict.fields.type.gen.short.label": "",
-  "dict.fields.type.dat.label": "为格",
-  "dict.fields.type.dat.short.label": "",
-  "dict.fields.type.inst.label": "工具格",
-  "dict.fields.type.inst.short.label": "",
-  "dict.fields.type.voc.label": "呼格",
-  "dict.fields.type.voc.short.label": "",
-  "dict.fields.type.abl.label": "来源格",
-  "dict.fields.type.abl.short.label": "",
-  "dict.fields.type.loc.label": "处格",
-  "dict.fields.type.loc.short.label": "",
-  "dict.fields.type.base.label": "词干",
-  "dict.fields.type.base.short.label": "",
-  "dict.fields.type.imp.label": "命令",
-  "dict.fields.type.imp.short.label": "命令",
-  "dict.fields.type.cond.label": "条件",
-  "dict.fields.type.cond.short.label": "条件",
-  "dict.fields.type.opt.label": "愿望",
-  "dict.fields.type.opt.short.label": "愿望",
-  "dict.fields.type.pres.label": "",
-  "dict.fields.type.pres.short.label": "",
-  "dict.fields.type.aor.label": "",
-  "dict.fields.type.aor.short.label": "",
-  "dict.fields.type.pf.label": "",
-  "dict.fields.type.pf.short.label": "",
-  "dict.fields.type.fut.label": "",
-  "dict.fields.type.fut.short.label": "",
-  "dict.fields.type.act.label": "主动",
-  "dict.fields.type.act.short.label": "主动",
-  "dict.fields.type.refl.label": "反照",
-  "dict.fields.type.refl.short.label": "",
-  "dict.fields.type.1p.label": "第一",
-  "dict.fields.type.1p.short.label": "",
-  "dict.fields.type.2p.label": "第二",
-  "dict.fields.type.2p.short.label": "",
-  "dict.fields.type.3p.label": "第三",
-  "dict.fields.type.3p.short.label": "",
-  "dict.fields.type.prp.label": "现在分词",
-  "dict.fields.type.prp.short.label": "现分",
-  "dict.fields.type.prpp.label": "被动现在分词",
-  "dict.fields.type.prpp.short.label": "被现分",
+  "dict.fields.type.m.label": "m.",
+  "dict.fields.type.m.short.label": "m.",
+  "dict.fields.type.nt.label": "nt.",
+  "dict.fields.type.nt.short.label": "nt.",
+  "dict.fields.type.f.label": "f.",
+  "dict.fields.type.f.short.label": "f.",
+  "dict.fields.type.sg.label": "sg.",
+  "dict.fields.type.sg.short.label": "sg.",
+  "dict.fields.type.pl.label": "pl.",
+  "dict.fields.type.pl.short.label": "pl.",
+  "dict.fields.type.nom.label": "nom.",
+  "dict.fields.type.nom.short.label": "nom.",
+  "dict.fields.type.acc.label": "acc.",
+  "dict.fields.type.acc.short.label": "acc.",
+  "dict.fields.type.gen.label": "gen.",
+  "dict.fields.type.gen.short.label": "gen.",
+  "dict.fields.type.dat.label": "dat.",
+  "dict.fields.type.dat.short.label": "dat.",
+  "dict.fields.type.inst.label": "inst.",
+  "dict.fields.type.inst.short.label": "inst.",
+  "dict.fields.type.voc.label": "voc.",
+  "dict.fields.type.voc.short.label": "voc.",
+  "dict.fields.type.abl.label": "abl.",
+  "dict.fields.type.abl.short.label": "abl.",
+  "dict.fields.type.loc.label": "loc.",
+  "dict.fields.type.loc.short.label": "loc.",
+  "dict.fields.type.base.label": "base.",
+  "dict.fields.type.base.short.label": "base.",
+  "dict.fields.type.imp.label": "imp.",
+  "dict.fields.type.imp.short.label": "imp.",
+  "dict.fields.type.cond.label": "cond.",
+  "dict.fields.type.cond.short.label": "cond.",
+  "dict.fields.type.opt.label": "opt.",
+  "dict.fields.type.opt.short.label": "opt.",
+  "dict.fields.type.pres.label": "pres.",
+  "dict.fields.type.pres.short.label": "pres.",
+  "dict.fields.type.aor.label": "aor.",
+  "dict.fields.type.aor.short.label": "aor.",
+  "dict.fields.type.pf.label": "pf.",
+  "dict.fields.type.pf.short.label": "pf.",
+  "dict.fields.type.fut.label": "fut.",
+  "dict.fields.type.fut.short.label": "fut.",
+  "dict.fields.type.act.label": "act.",
+  "dict.fields.type.act.short.label": "act.",
+  "dict.fields.type.refl.label": "refl.",
+  "dict.fields.type.refl.short.label": "refl.",
+  "dict.fields.type.1p.label": "1p.",
+  "dict.fields.type.1p.short.label": "1p.",
+  "dict.fields.type.2p.label": "2p.",
+  "dict.fields.type.2p.short.label": "2p.",
+  "dict.fields.type.3p.label": "3p.",
+  "dict.fields.type.3p.short.label": "3p.",
+  "dict.fields.type.prp.label": "pr.p.",
+  "dict.fields.type.prp.short.label": "pr.p.",
+  "dict.fields.type.prpp.label": "pr.pp.",
+  "dict.fields.type.prpp.short.label": "pr.pp.",
   "dict.fields.type.pp.label": "过去分词",
   "dict.fields.type.pp.short.label": "过分",
   "dict.fields.type.ppa.label": "主过分",
@@ -137,30 +137,30 @@ const items = {
   "dict.fields.type.null.short.label": "_",
   "dict.fields.type.?.label": "待定",
   "dict.fields.type.?.short.label": "待定",
-  "dict.fields.type.ti:base.label": "三性词干",
-  "dict.fields.type.ti:base.short.label": "三性词干",
-  "dict.fields.type.n:base.label": "名词干",
-  "dict.fields.type.n:base.short.label": "名词干",
-  "dict.fields.type.v:base.label": "动词干",
-  "dict.fields.type.v:base.short.label": "动词干",
-  "dict.fields.type.adj:base.label": "形词干",
-  "dict.fields.type.adj:base.short.label": "形词干",
-  "dict.fields.type.fpp.label": "未来被动分词",
-  "dict.fields.type.fpp.short.label": "未被分",
-  "dict.fields.type.cp.short.label": "",
-  "dict.fields.type.cp.label": "复合词组分",
-  "dict.fields.type.indconj.short.label": "",
-  "dict.fields.type.indconj.label": "连词",
-  "dict.fields.type.pron:base.short.label": "代干",
-  "dict.fields.type.pron:base.label": "代词词干",
-  "dict.fields.type.note.short.label": "注释",
-  "dict.fields.type.note.label": "注释",
-  "dict.fields.type.vind.short.label": "动不变",
-  "dict.fields.type.vind.label": "动不变",
+  "dict.fields.type.ti:base.label": "ti.base.",
+  "dict.fields.type.ti:base.short.label": "ti.base.",
+  "dict.fields.type.n:base.label": "n.base.",
+  "dict.fields.type.n:base.short.label": "n.base.",
+  "dict.fields.type.v:base.label": "v.base.",
+  "dict.fields.type.v:base.short.label": "v.base.",
+  "dict.fields.type.adj:base.label": "adj.base.",
+  "dict.fields.type.adj:base.short.label": "adj.base.",
+  "dict.fields.type.fpp.label": "fpp.",
+  "dict.fields.type.fpp.short.label": "fpp.",
+  "dict.fields.type.cp.short.label": "factor.",
+  "dict.fields.type.cp.label": "factor.",
+  "dict.fields.type.indconj.short.label": "conj.",
+  "dict.fields.type.indconj.label": "conj.",
+  "dict.fields.type.pron:base.short.label": "pron.base.",
+  "dict.fields.type.pron:base.label": "pron.base.",
+  "dict.fields.type.note.short.label": "note",
+  "dict.fields.type.note.label": "note",
+  "dict.fields.type.vind.short.label": "v.ind.",
+  "dict.fields.type.vind.label": "v.ind.",
   "dict.fields.type.vdn.label": "衍生动名词",
   "dict.fields.type.vdn.short.label": "动名",
-  "dict.fields.type.comp.label": "复合词",
-  "dict.fields.type.comp.short.label": "",
+  "dict.fields.type.comp.label": "comp.",
+  "dict.fields.type.comp.short.label": "comp.",
 };
 
 export default items;