人生啊人生 3 tygodni temu
rodzic
commit
83494f93f9

BIN
exe/logo.ico


BIN
exe/logo_demo.ico


+ 1 - 1
exe/new_src/ServerPort.txt

@@ -1 +1 @@
-6789
+6890

+ 19 - 0
exe/src/main/index.js

@@ -268,6 +268,7 @@ function createMainWindow() {
     // mainWindow.webContents.openDevTools();
     
     mainLoadUrl();
+    mainToMaxEvent();
     mainLoadUrlBrowser();
     
 }
@@ -292,6 +293,24 @@ function mainLoadUrl() {
     }, 1000)
   
 }
+
+// 监听窗口最大化
+function mainToMaxEvent() {
+  
+    setInterval(function() {
+      
+        let mainToMax = CommonVar.find().cacheGetOrUpdate('get', 'mainToMax');
+    
+        if (mainToMax === null) {
+            return;
+        }
+    
+        CommonVar.find().cacheGetOrUpdate('set', 'mainToMax', null);
+        mainWindow.maximize();
+  
+    }, 1000)
+  
+}
   
 /**
  * 弹出新的窗口

+ 16 - 0
exe/src/myWebServerRote/main.js

@@ -110,6 +110,22 @@ objRouter.post('/mainLoadUrlBrowser', function (req, res) {
 
 });
 
+/**
+ * 首页-窗口最大化
+ * 地址:http://127.0.0.1:6789/mainToMax
+ */
+objRouter.get('/mainToMax', function (req, res) {
+
+    var get = req.query;
+    var post = req.body;
+    
+    CommonVar.find().cacheGetOrUpdate('set', 'mainToMax', 'yes');
+
+    return CommonVar.find().retOk(res, "正在弹出")
+
+});
+
+
 /**
  * 唯一name值参数记录
  * 地址:http://127.0.0.1:6789/nameOnlyAdd

+ 4 - 0
user_web/index.html

@@ -8,6 +8,10 @@
   </head>
   <body>
     <div id="app"></div>
+    <script>
+      // 配置全局变量
+      window["mainToMaxPort"] = 6890;
+    </script>
     <script type="module" src="/src/main.ts"></script>
   </body>
 </html>

+ 52 - 10
user_web/src/view/LogInExe.vue

@@ -159,22 +159,64 @@ const loginEvent = () => {
             getCurrentUser().then((res) => {
                 userInfo.dataFill(Object.assign({ userType: userType }, res.data.data));
 
-                // 老师
-                if (userType == 0) router.push({ path: '/TaskMng' });
-                // 学生
-                else if (userType == 1) router.push({ path: '/studentMain' });
-                else {
-                    ElNotification({
-                        message: '无效用户',
-                        type: 'info',
-                    });
-                }
+                // // 老师
+                // if (userType == 0) router.push({ path: '/TaskMng' });
+                // // 学生
+                // else if (userType == 1) router.push({ path: '/studentMain' });
+                // else {
+                //     ElNotification({
+                //         message: '无效用户',
+                //         type: 'info',
+                //     });
+                // }
+
+                mainToMaxEvent(function() {
+                    
+                    // 老师
+                    if (userType == 0) router.push({ path: '/TaskMng' });
+                    // 学生
+                    else if (userType == 1) router.push({ path: '/studentMain' });
+                    else {
+                        ElNotification({
+                            message: '无效用户',
+                            type: 'info',
+                        });
+                    }
+
+                });
+
             });
         }
     });
     
 }
 
+
+/**
+ * 桌面应用窗口最大化
+ * callback
+ */
+const mainToMaxEvent = (callback : any) => {
+
+    fetch('http://127.0.0.1:' + window["mainToMaxPort"] + '/mainToMax')
+    .then(response => {
+        if (!response.ok) {
+            throw new Error(`请求失败:${response.status} ${response.statusText}`);
+        }
+        return response.json(); // 若返回文本,用 response.text()
+    })
+    .then(data => {
+        // console.log('获取到的数据:', data);
+        // 这里写业务逻辑(如渲染页面)
+        callback('yes');
+    })
+    .catch(error => {
+        // console.error('请求出错:', error.message);
+        callback('yes');
+    });
+}
+
+
 const regularPassword = (val: string) => {
     if (/^[a-zA-Z0-9_@]{6,32}$/.test(val)) return true;
     return false;