diff --git a/.gitignore b/.gitignore
index 0b3569a..1e72070 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
*.swp
node_modules
app/data.json
+
+OutApp*
+*OutApp
\ No newline at end of file
diff --git a/app/main/assets/big.png b/app/main/assets/big.png
new file mode 100644
index 0000000..81eb223
Binary files /dev/null and b/app/main/assets/big.png differ
diff --git a/app/main/assets/close-new.png b/app/main/assets/close-new.png
new file mode 100644
index 0000000..c52dd64
Binary files /dev/null and b/app/main/assets/close-new.png differ
diff --git a/app/main/assets/mainphoto.png b/app/main/assets/mainphoto.png
new file mode 100644
index 0000000..6c72db7
Binary files /dev/null and b/app/main/assets/mainphoto.png differ
diff --git a/app/main/assets/small.png b/app/main/assets/small.png
new file mode 100644
index 0000000..26ad13f
Binary files /dev/null and b/app/main/assets/small.png differ
diff --git a/app/main/assets/test1.pdf b/app/main/assets/test1.pdf
new file mode 100644
index 0000000..e688541
Binary files /dev/null and b/app/main/assets/test1.pdf differ
diff --git a/app/main/constant.js b/app/main/constant.js
index 98a81ac..466ff8e 100644
--- a/app/main/constant.js
+++ b/app/main/constant.js
@@ -23,7 +23,8 @@ switch (schema) {
url = 'http://localhost:8080/';
break;
case 'QB':
- url = 'http://localhost:8080/TIS_PLATFORM/';
+ url = 'http://localhost:3806/TIS_PLATFORM/';
+ // url = "file://" + path.resolve(__dirname, './index.html');
break;
default:
url = 'http://localhost:8080/TIS_PLATFORM/';
diff --git a/app/main/index.html b/app/main/index.html
new file mode 100644
index 0000000..2a821b2
--- /dev/null
+++ b/app/main/index.html
@@ -0,0 +1,152 @@
+
+
+
+
+
+ 系统运行监控
+
+
+
+
+
+
+
+
+
+

+
系统运行监控
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/main/windows/application.js b/app/main/windows/application.js
index d7930fb..6264ee6 100644
--- a/app/main/windows/application.js
+++ b/app/main/windows/application.js
@@ -1,8 +1,8 @@
-const { BrowserWindow } = require('electron')
+const { BrowserWindow } = require('electron')
const { createWindow } = require('./lib/common')
// props: { id: 'TIS_APP_TEMPLATE_KT', entry: '' }
-const create = props => {
+const create = (props,options) => {
const windows = BrowserWindow.getAllWindows()
const found = windows.find(w => w[props.id])
if (found) {
@@ -12,9 +12,10 @@ const create = props => {
}
const win = createWindow(props.entry, {
- show: true
+ show: true,
+ ...options,
})
- win[props.id] = true
+ win[props.id] = Symbol(props.id);
return win
}
diff --git a/app/main/windows/lib/common.js b/app/main/windows/lib/common.js
index 4067492..e0c0f58 100644
--- a/app/main/windows/lib/common.js
+++ b/app/main/windows/lib/common.js
@@ -1,10 +1,12 @@
-const { BrowserWindow } = require('electron')
+const { BrowserWindow,Menu,globalShortcut } = require('electron')
const path = require('path')
-
const { MANUAL_CREATED_FLAG } = require('../../constant')
+// 引入初始化remote模块
+const remote = require('@electron/remote/main')
+remote.initialize()
function createWindow(url,options,node=false) {
- // let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize
+ Menu.setApplicationMenu(null);
const window = new BrowserWindow({
// width: 870,
// height: 530,
@@ -22,6 +24,22 @@ function createWindow(url,options,node=false) {
console.log('openWindow', url)
window.loadURL(url)
+
+ // 清除缓存
+ const ses = window.webContents.session
+ ses.clearCache()
+
+ // 启用remote模块
+ remote.enable(window.webContents)
+ // 注册快捷键
+ window.on('focus', () => {
+ globalShortcut.register('CommandOrControl+Alt+F', function () {
+ window && window.webContents.toggleDevTools();
+ })
+ });
+ window.on('blur', () => {
+ globalShortcut.unregisterAll() // 注销键盘事件
+ })
// window.webContents.openDevTools() // Open the DevTools.
return window
}
diff --git a/app/main/windows/lib/data.json b/app/main/windows/lib/data.json
index 2eb6c2e..685f42d 100644
--- a/app/main/windows/lib/data.json
+++ b/app/main/windows/lib/data.json
@@ -1 +1 @@
-{"test":{"a":1},"test2":{"name":"我是你爹"}}
\ No newline at end of file
+{"firstInstall":false,"position":{"x":1155,"y":775}}
\ No newline at end of file
diff --git a/app/main/windows/lib/preload.js b/app/main/windows/lib/preload.js
index b2bfe66..442a87f 100644
--- a/app/main/windows/lib/preload.js
+++ b/app/main/windows/lib/preload.js
@@ -1,7 +1,7 @@
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const {ipcRenderer} = require('electron')
-
+window.currentFrame ="platform";
window.api = [
"showSuspensionWindow",
"resizeWindow",
@@ -28,11 +28,11 @@ window.api = [
ipcRenderer.on('getUnReadMessage', (e, args) => {
window.getUnReadMessage(args[0]);
});
-window.addEventListener("keydown", e => {
- const {altKey, ctrlKey, keyCode} = e;
- if (altKey && ctrlKey && keyCode === 70) {
- const currentWindow = require('electron').remote.getCurrentWindow();
- currentWindow && currentWindow.toggleDevTools();
- e.preventDefault();
- }
-})
+// window.addEventListener("keydown", e => {
+// const {altKey, ctrlKey, keyCode} = e;
+// if (altKey && ctrlKey && keyCode === 70) {
+// const currentWindow = require('electron').remote.getCurrentWindow();
+// currentWindow && currentWindow.toggleDevTools();
+// e.preventDefault();
+// }
+// })
diff --git a/app/main/windows/lib/store.js b/app/main/windows/lib/store.js
index bafd209..d839f71 100644
--- a/app/main/windows/lib/store.js
+++ b/app/main/windows/lib/store.js
@@ -1,28 +1,28 @@
// const Store = require('electron-store');
// const store = new Store();//
-
-const data_path = "./data.json";
+const path = require("path")
+const data_path = path.join(__dirname, './data.json');
const fs = require("fs")
class Store {
constructor(){
- fs.writeFileSync(data_path,JSON.stringify({}))
+ // fs.writeFileSync(data_path,JSON.stringify({}))
}
set(key, param) {
// let saveData = {key:param};
- console.log("------",key,param);
- let oldData = require('./data.json');
+ // console.log("------",key,param);
+ let oldData = require(data_path);
oldData[key] = param;
- // console.log('======',oldData);
+ // console.log('======',JSON.stringify(oldData),data_path);
fs.writeFileSync(data_path,JSON.stringify(oldData))
}
get(key){
const data = JSON.parse(fs.readFileSync(data_path,'utf-8'));
- // console.log('get>>>>>>>>>',data[key])
+ // console.log('get>>>>>>>>>',data[key],data_path)
return data[key];
}
delete(key){
- let oldData = require('./data.json');
+ let oldData = require(data_path);
delete oldData[key];
fs.writeFileSync(data_path,JSON.stringify(oldData))
}
diff --git a/app/main/windows/main.js b/app/main/windows/main.js
index cbe9642..747736e 100644
--- a/app/main/windows/main.js
+++ b/app/main/windows/main.js
@@ -1,37 +1,52 @@
-const { MAIN_WINDOW_FLAG, MAIN_WINDOW_URL } = require("../constant")
-const { createWindow } = require('./lib/common')
-const { BrowserWindow } = require('electron')
-const { create: createSuspensionWindow } = require('./suspension');
-
+const {MAIN_WINDOW_FLAG, MAIN_WINDOW_URL} = require("../constant")
+const {createWindow} = require('./lib/common')
+const {BrowserWindow} = require('electron')
+const {create: createSuspensionWindow} = require('./suspension');
+const screen = require("./screen.json");
const create = () => {
- const windows = BrowserWindow.getAllWindows()
- const found = windows.find((window) => {
- return window[MAIN_WINDOW_FLAG]
- })
-
- if (found) {
- found.show();
- found.center();
- found.maximize();
- return found;
- } else {
- const win = createWindow(MAIN_WINDOW_URL,{
- fullscreen:true,
- offScreen:false,
- frame: false, //要创建无边框窗口
- show:true
+ const windows = BrowserWindow.getAllWindows()
+ const found = windows.find((window) => {
+ return window[MAIN_WINDOW_FLAG]
})
- win[MAIN_WINDOW_FLAG] = true
- // win.on('ready-to-show', () => {
- // win.show();
- // });
- win.on('hide', () => {
- createSuspensionWindow();
- });
- return create();
- }
+ if (found) {
+ found.show();
+ found.center();
+ found.maximize();
+ return found;
+ } else {
+ let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize;
+ let width = areaSize.width;
+ let height = areaSize.height;
+ let resizable = true;
+ if (screen.width > 0 && screen.height > 0) {
+ const ratios = screen.width / screen.height;
+ height = areaSize.height;
+ width = Math.floor(areaSize.height * ratios);
+ resizable = false;
+ }
+ const win = createWindow(MAIN_WINDOW_URL, {
+ //alwaysOnTop: true, //窗口是否总是显示在其他窗口之前
+ fullscreen: true,
+ offScreen: false,
+ frame: false, //要创建无边框窗口
+ width: width, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框
+ height: height, //悬浮窗口的高度 比实际DIV的高度要多2px 因为有1px的边框
+ resizable: resizable, //禁止窗口大小缩放
+ show: false, //先不让窗口显示
+ backgroundColor: "#0a0a0a"
+ })
+ win[MAIN_WINDOW_FLAG] = true
+
+ win.on('ready-to-show', () => {
+ win.show();
+ });
+ win.on('hide', () => {
+ createSuspensionWindow();
+ });
+ return create();
+ }
}
-module.exports = { create }
\ No newline at end of file
+module.exports = {create}
\ No newline at end of file
diff --git a/app/main/windows/screen.json b/app/main/windows/screen.json
new file mode 100644
index 0000000..2e2d8c1
--- /dev/null
+++ b/app/main/windows/screen.json
@@ -0,0 +1,4 @@
+{
+ "width":0,
+ "height":0
+}
diff --git a/app/main/windows/suspension.js b/app/main/windows/suspension.js
index 1ca63f2..c40af65 100644
--- a/app/main/windows/suspension.js
+++ b/app/main/windows/suspension.js
@@ -24,7 +24,7 @@ const create = () => {
// maximizable: false,
// resizable: false,
// focusable: true
- width: 427, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框
+ width: 310, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框
height: 130, //悬浮窗口的高度 比实际DIV的高度要多2px 因为有1px的边框
// width: 500,
// height: 500,
diff --git a/app/package.json b/app/package.json
index bb56d76..e62d2de 100644
--- a/app/package.json
+++ b/app/package.json
@@ -33,12 +33,13 @@
"devDependencies": {
"asar": "^3.0.3",
"cross-env": "^5.2.0",
- "electron": "4.1.2",
+ "electron": "15.5.7",
"electron-builder": "^22.6.1",
"electron-packager": "^13.1.1",
"electron-store": "^8.0.0"
},
"dependencies": {
+ "@electron/remote": "^2.0.8",
"redis": "^4.0.1"
}
}
diff --git a/app/renderer/pages/suspension/index.html b/app/renderer/pages/suspension/index.html
index 1e8c6ce..b31f102 100644
--- a/app/renderer/pages/suspension/index.html
+++ b/app/renderer/pages/suspension/index.html
@@ -125,7 +125,7 @@