Forráskód Böngészése

fix: 修复部分bug

banxia 1 hónapja
szülő
commit
419904378c

+ 17 - 15
electron/main/express.ts

@@ -21,16 +21,16 @@ export const initExpress = () => {
       log.error("缺少path参数" + new Date());
       return;
     }
-    mainWindow!.webContents.loadURL(decodeURIComponent(url));
+    mainWindow!.webContents.send("iframe", {
+      type: "iframe",
+      data: path,
+    });
+    // mainWindow!.webContents.loadURL(decodeURIComponent(url));
     const isFocusOpenWin: number = handeGet("isFocusOpenWin");
     if (isFocusOpenWin == 1) {
       mainWindow!.show();
       mainWindow!.setAlwaysOnTop(true);
     }
-    // mainWindow!.webContents.send("iframe", {
-    //   type: "iframe",
-    //   data: path,
-    // });
     res.send({
       code: 200,
       msg: "成功" + new Date(),
@@ -47,16 +47,17 @@ export const initExpress = () => {
       log.error("缺少path参数" + new Date());
       return;
     }
-    mainWindow!.webContents.loadURL(decodeURIComponent(path));
+    mainWindow!.webContents.send("iframe", {
+      type: "iframe",
+      data: path,
+    });
+    // mainWindow!.webContents.loadURL(decodeURIComponent(path));
     const isFocusOpenWin: number = handeGet("isFocusOpenWin");
     if (isFocusOpenWin == 1) {
       mainWindow!.show();
       mainWindow!.setAlwaysOnTop(true);
     }
-    // mainWindow!.webContents.send("iframe", {
-    //   type: "iframe",
-    //   data: path,
-    // });
+
     res.send({
       code: 200,
       msg: "成功" + new Date(),
@@ -75,16 +76,17 @@ export const initExpress = () => {
       log.error("缺少path参数" + new Date());
       return;
     }
-    mainWindow!.webContents.loadURL(decodeURIComponent(path));
+    mainWindow!.webContents.send("iframe", {
+      type: "iframe",
+      data: path,
+    });
+    // mainWindow!.webContents.loadURL(decodeURIComponent(path));
     const isFocusOpenWin: number = handeGet("isFocusOpenWin");
     if (isFocusOpenWin == 1) {
       mainWindow!.show();
       mainWindow!.setAlwaysOnTop(true);
     }
-    // mainWindow!.webContents.send("iframe", {
-    //   type: "iframe",
-    //   data: path,
-    // });
+
     res.send({
       code: 200,
       msg: "成功" + new Date(),

+ 6 - 0
package.json

@@ -3,6 +3,12 @@
   "private": true,
   "version": "0.0.2",
   "main": "dist-electron/main/index.js",
+  "pnpm": {
+    "onlyBuiltDependencies": [
+      "electron",
+      "esbuild"
+    ]
+  },
   "scripts": {
     "dev": "vite",
     "build": "rimraf dist-electron && vite build && electron-builder",

+ 16 - 13
src/components/MessageModal/MessageModal.tsx

@@ -6,6 +6,7 @@ import { MESSAGE_TAB } from "@/constants";
 import { useNotificationStore } from "@/store/NotificationStore";
 import { Eraser, FileText } from "lucide-react";
 import dayjs from "dayjs";
+import { renderNoticeLength } from "@/utils/utils";
 
 interface MessageModalProps {
   visible: boolean;
@@ -20,7 +21,9 @@ const MessageModal: React.FC<MessageModalProps> = ({
 }) => {
   const [activeKey, setActiveKey] = useState(MESSAGE_TAB.UNREAD);
   const { notifications } = useNotificationStore();
-  console.log("notifications", notifications);
+  const unreadNotifications = notifications.filter(
+    (notification) => notification.status === MESSAGE_TAB.UNREAD
+  );
 
   const tabItems: TabsProps["items"] = [
     {
@@ -32,15 +35,11 @@ const MessageModal: React.FC<MessageModalProps> = ({
       label: (
         <span className="flex">
           未读{" "}
-          <span className="text-xs text-white bg-red-500 rounded-full w-5 h-5 flex justify-center items-center">
-            {notifications.filter(
-              (notification) => notification.status === MESSAGE_TAB.UNREAD
-            ).length > 9
-              ? "9+"
-              : notifications.filter(
-                  (notification) => notification.status === MESSAGE_TAB.UNREAD
-                ).length}
-          </span>
+          {!!unreadNotifications.length && (
+            <span className="ml-1 text-xs text-white bg-red-500 rounded-full w-5 h-5 flex justify-center items-center">
+              {renderNoticeLength(unreadNotifications)}
+            </span>
+          )}
         </span>
       ),
     },
@@ -54,7 +53,11 @@ const MessageModal: React.FC<MessageModalProps> = ({
     <Modal
       title={
         <div className="flex items-center">
-          <span>消息中心 (1)</span>
+          <span>
+            消息中心{" "}
+            {!!renderNoticeLength(notifications) &&
+              `(${renderNoticeLength(notifications)})`}
+          </span>
           <div className="cursor-pointer hover:bg-gray-100 rounded-md px-2 py-1 ml-2 text-xs flex justify-center items-center gap-1">
             <Eraser size={12} />
             清除消息
@@ -111,10 +114,10 @@ const MessageModal: React.FC<MessageModalProps> = ({
                       {message.footer || "祝您工作顺利!"}
                     </p>
                     <div className="mt-2 flex space-x-2 justify-end">
-                      <Button size="middle">知道了</Button>
                       <Button type="primary" size="middle">
-                        去查看
+                        知道了
                       </Button>
+                      <Button size="middle">去查看</Button>
                     </div>
                   </div>
                 </div>

+ 2 - 2
src/layouts/index.tsx

@@ -1,14 +1,14 @@
 import "./index.scss";
 import { Layout, Menu } from "antd";
 import { Outlet } from "react-router-dom";
-import LayoutHeader from "./Header";
+// import LayoutHeader from "./Header";
 
 const { Content } = Layout;
 
 const MainPage = () => {
   return (
     <Layout className="ant-layout">
-      <LayoutHeader />
+      {/* <LayoutHeader /> */}
       <Content className="layout-content">
         <Outlet></Outlet>
       </Content>

+ 7 - 1
src/router/beforeEnter.tsx

@@ -1,6 +1,7 @@
 import { useLocation, useNavigate, useRoutes } from "react-router-dom";
 import { useState, useEffect } from "react";
 import storage from "@/utils/storage";
+import LayoutHeader from "@/layouts/Header";
 
 const BeforeEnter = ({ routers }) => {
   //1.在路由数组中找当前页面路由的对应路由项
@@ -44,6 +45,11 @@ const BeforeEnter = ({ routers }) => {
     //路由守卫判断
     judgeRouter(location, navigate);
   }, [navigate, location]);
-  return router;
+  return (
+    <>
+      <LayoutHeader />
+      {router}
+    </>
+  );
 };
 export default BeforeEnter;

+ 10 - 0
src/utils/utils.ts

@@ -141,3 +141,13 @@ export const getNonDuplicateID = (length = 8) => {
 export const firstToUpperCase = (str = "") => {
   return str.toLowerCase().replace(/( |^)[a-z]/g, ($1) => $1.toUpperCase());
 };
+
+export const renderNoticeLength = (notifications: any[]) => {
+  if (notifications.length > 0 && notifications.length <= 9) {
+    return notifications.length;
+  } else if (notifications.length > 9) {
+    return "9+";
+  } else {
+    return null;
+  }
+};