From f96ff24eb66dd8c5af34ec3ee955b1f66547da16 Mon Sep 17 00:00:00 2001
From: wuhao930406 <1148547900@qq.com>
Date: Thu, 15 Jun 2023 17:13:42 +0800
Subject: [PATCH] adsr

---
 .gitignore                        | 12 +++++++++++-
 data/system.json                  |  6 +++---
 electron/config/config.default.js |  6 +++---
 frontend/src/pages/user/login.jsx |  3 +++
 frontend/src/utils/ipcRenderer.js | 28 ++++++++++++++++++++++++++++
 logs/ee-20230615.log              |  8 ++++++++
 logs/ee-core-20230615.log         |  5 +++++
 logs/ee-error-20230615.log        |  1 +
 8 files changed, 62 insertions(+), 7 deletions(-)
 create mode 100644 frontend/src/utils/ipcRenderer.js

diff --git a/.gitignore b/.gitignore
index 2d36461..feaef7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,14 @@ node_modules
 /src/.umi-test
 dist
 .swc
-.history
\ No newline at end of file
+.history
+
+out/
+logs/
+run/
+.idea/
+package-lock.json
+data/
+.vscode/launch.json
+public/electron/
+pnpm-lock.yaml
diff --git a/data/system.json b/data/system.json
index a97dc36..68ec546 100644
--- a/data/system.json
+++ b/data/system.json
@@ -57,17 +57,17 @@
         }
       },
       "developmentMode": {
-        "default": "vue",
+        "default": "react",
         "mode": {
           "vue": {
             "protocol": "http://",
             "hostname": "localhost",
-            "port": 8080
+            "port": 4399
           },
           "react": {
             "protocol": "http://",
             "hostname": "localhost",
-            "port": 3000
+            "port": 8000
           },
           "html": {
             "protocol": "http://",
diff --git a/electron/config/config.default.js b/electron/config/config.default.js
index 7ccdeb2..b55ac6f 100644
--- a/electron/config/config.default.js
+++ b/electron/config/config.default.js
@@ -13,15 +13,15 @@ module.exports = (appInfo) => {
    * 应用模式配置
    */
   config.developmentMode = {
-    default: 'vue',
+    default: 'react',
     mode: {
       vue: {
         hostname: 'localhost',
-        port: 8080
+        port: 4399
       },
       react: {
         hostname: 'localhost',
-        port: 3000
+        port: 8000
       },
       html: {
         hostname: 'localhost',
diff --git a/frontend/src/pages/user/login.jsx b/frontend/src/pages/user/login.jsx
index b3d75e3..dbeeb76 100644
--- a/frontend/src/pages/user/login.jsx
+++ b/frontend/src/pages/user/login.jsx
@@ -9,6 +9,8 @@ import {
 import { history, useModel,useOutletContext } from "umi";
 import { Card, Dropdown, message, Tabs, QRCode } from "antd";
 import { useState } from "react";
+import { ipc } from "@/utils/ipcRenderer";
+
 
 const Login = () => {
   const {
@@ -16,6 +18,7 @@ const Login = () => {
     setInitialState,
   } = useModel("@@initialState");
   const { mode } = useOutletContext();
+  console.log(ipc);
 
   const handleSubmit = async (values) => {
     if (loginType === "account") {
diff --git a/frontend/src/utils/ipcRenderer.js b/frontend/src/utils/ipcRenderer.js
new file mode 100644
index 0000000..6dd0388
--- /dev/null
+++ b/frontend/src/utils/ipcRenderer.js
@@ -0,0 +1,28 @@
+const { ipcRenderer: ipc } = (window.require && window.require('electron')) || window.electron || {};
+
+/**
+ * ipc
+ * 官方api说明:https://www.electronjs.org/zh/docs/latest/api/ipc-renderer
+ * 
+ * 属性/方法
+ * ipc.invoke(channel, param) - 发送异步消息(invoke/handle 模型)
+ * ipc.sendSync(channel, param) - 发送同步消息(send/on 模型)
+ * ipc.on(channel, listener) - 监听 channel, 当新消息到达,调用 listener
+ * ipc.once(channel, listener) - 添加一次性 listener 函数
+ * ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者
+ * ipc.removeAllListeners(channel) - 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
+ * ipc.send(channel, ...args) - 通过channel向主进程发送异步消息
+ * ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程
+ * ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口
+ * ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 <webview> 元素
+ */
+
+/**
+ * 是否为EE环境
+ */
+const isEE = ipc ? true : false;
+
+export {
+  ipc,
+  isEE
+}
diff --git a/logs/ee-20230615.log b/logs/ee-20230615.log
index e499db5..38351cc 100644
--- a/logs/ee-20230615.log
+++ b/logs/ee-20230615.log
@@ -6,3 +6,11 @@
 2023-06-15 13:35:39,867 INFO 9788 [addon:security] load
 2023-06-15 13:35:39,868 INFO 9788 [addon:awaken] load
 2023-06-15 13:35:39,870 INFO 9788 [addon:autoUpdater] load
+2023-06-15 15:51:15,745 INFO 11081 [addon:tray] load
+2023-06-15 15:51:15,758 INFO 11081 [addon:security] load
+2023-06-15 15:51:15,758 INFO 11081 [addon:awaken] load
+2023-06-15 15:51:15,761 INFO 11081 [addon:autoUpdater] load
+2023-06-15 16:11:40,938 INFO 11439 [addon:tray] load
+2023-06-15 16:11:40,950 INFO 11439 [addon:security] load
+2023-06-15 16:11:40,950 INFO 11439 [addon:awaken] load
+2023-06-15 16:11:40,952 INFO 11439 [addon:autoUpdater] load
diff --git a/logs/ee-core-20230615.log b/logs/ee-core-20230615.log
index 3f0dd4e..2c1461b 100644
--- a/logs/ee-core-20230615.log
+++ b/logs/ee-core-20230615.log
@@ -4,3 +4,8 @@
 2023-06-15 13:35:39,873 INFO 9788 [ee-core] Env: local, Type: spa
 2023-06-15 13:35:39,874 INFO 9788 [ee-core] App running at: http://localhost:8080
 2023-06-15 13:35:39,950 ERROR 9788 [ee-core] Please check the http://localhost:8080 are running OR modify config file !
+2023-06-15 15:51:15,765 INFO 11081 [ee-core] Env: local, Type: spa
+2023-06-15 15:51:15,765 INFO 11081 [ee-core] App running at: http://localhost:8000
+2023-06-15 15:51:15,878 ERROR 11081 [ee-core] Please check the http://localhost:8000 are running OR modify config file !
+2023-06-15 16:11:40,956 INFO 11439 [ee-core] Env: local, Type: spa
+2023-06-15 16:11:40,956 INFO 11439 [ee-core] App running at: http://localhost:8000
diff --git a/logs/ee-error-20230615.log b/logs/ee-error-20230615.log
index 2542d87..0699609 100644
--- a/logs/ee-error-20230615.log
+++ b/logs/ee-error-20230615.log
@@ -1,2 +1,3 @@
 2023-06-15 13:35:12,119 ERROR 9746 [ee-core] Please check the http://localhost:8080 are running OR modify config file !
 2023-06-15 13:35:39,950 ERROR 9788 [ee-core] Please check the http://localhost:8080 are running OR modify config file !
+2023-06-15 15:51:15,878 ERROR 11081 [ee-core] Please check the http://localhost:8000 are running OR modify config file !
-- 
2.21.0