-
39LICENSE.md
-
49README.md
-
BINapp.asar
-
36app/main/constant.js
-
45app/main/index.js
-
212app/main/ipc.js
-
19app/main/ipc/getApps.js
-
70app/main/ipc/installApp.js
-
8app/main/ipc/removeApp.js
-
9app/main/windows/app.js
-
29app/main/windows/lib/common.js
-
1app/main/windows/lib/data.json
-
37app/main/windows/lib/preload.js
-
33app/main/windows/lib/store.js
-
20app/main/windows/login.js
-
37app/main/windows/main.js
-
57app/main/windows/suspension.js
-
44app/package.json
-
1app/renderer/pages/main/css/app.3f3f7430.css
-
1app/renderer/pages/main/css/chunk-vendors.84bb20f7.css
-
BINapp/renderer/pages/main/favicon.ico
-
BINapp/renderer/pages/main/fonts/element-icons.535877f5.woff
-
BINapp/renderer/pages/main/fonts/element-icons.732389de.ttf
-
BINapp/renderer/pages/main/img/add.6b952039.png
-
23app/renderer/pages/main/index.html
-
2app/renderer/pages/main/js/app.e6242064.js
-
1app/renderer/pages/main/js/app.e6242064.js.map
-
34app/renderer/pages/main/js/chunk-vendors.679c79aa.js
-
1app/renderer/pages/main/js/chunk-vendors.679c79aa.js.map
-
BINapp/renderer/pages/main/widget-icons/widget-action-control.png
-
BINapp/renderer/pages/main/widget-icons/widget-add.png
-
BINapp/renderer/pages/main/widget-icons/widget-compass.png
-
BINapp/renderer/pages/main/widget-icons/widget-houqin.png
-
BINapp/renderer/pages/main/widget-icons/widget-logo-sample.png
-
BINapp/renderer/pages/main/widget-icons/widget-map.png
-
BINapp/renderer/pages/main/widget-icons/widget-monitor.png
-
BINapp/renderer/pages/main/widget-icons/widget-msg.png
-
BINapp/renderer/pages/main/widget-icons/widget-news.png
-
BINapp/renderer/pages/main/widget-icons/widget-radar.png
-
BINapp/renderer/pages/main/widget-icons/widget-settings.png
-
BINapp/renderer/pages/main/widget-icons/widget-tjxl.png
-
BINapp/renderer/pages/main/widget-icons/widget-user.png
-
BINapp/renderer/pages/main/widget-icons/widget-zhihui.png
-
BINapp/renderer/pages/suspension/img/back.png
-
BINapp/renderer/pages/suspension/img/logo-active.png
-
BINapp/renderer/pages/suspension/img/logo.png
-
210app/renderer/pages/suspension/index.html
-
11855app/renderer/pages/suspension/lib/vue.js
-
3app/renderer/src/main/.browserslistrc
-
14app/renderer/src/main/.eslintrc.js
-
24app/renderer/src/main/README.md
-
3app/renderer/src/main/babel.config.js
-
4app/renderer/src/main/build.js
-
44app/renderer/src/main/package.json
-
BINapp/renderer/src/main/public/favicon.ico
-
17app/renderer/src/main/public/index.html
-
BINapp/renderer/src/main/public/widget-icons/widget-action-control.png
-
BINapp/renderer/src/main/public/widget-icons/widget-add.png
-
BINapp/renderer/src/main/public/widget-icons/widget-compass.png
-
BINapp/renderer/src/main/public/widget-icons/widget-houqin.png
-
BINapp/renderer/src/main/public/widget-icons/widget-logo-sample.png
-
BINapp/renderer/src/main/public/widget-icons/widget-map.png
-
BINapp/renderer/src/main/public/widget-icons/widget-monitor.png
-
BINapp/renderer/src/main/public/widget-icons/widget-msg.png
-
BINapp/renderer/src/main/public/widget-icons/widget-news.png
-
BINapp/renderer/src/main/public/widget-icons/widget-radar.png
-
BINapp/renderer/src/main/public/widget-icons/widget-settings.png
-
BINapp/renderer/src/main/public/widget-icons/widget-tjxl.png
-
BINapp/renderer/src/main/public/widget-icons/widget-user.png
-
BINapp/renderer/src/main/public/widget-icons/widget-zhihui.png
-
43app/renderer/src/main/src/App.vue
-
BINapp/renderer/src/main/src/assets/add.png
-
BINapp/renderer/src/main/src/assets/logo.png
-
84app/renderer/src/main/src/components/ApiDoc.vue
-
144app/renderer/src/main/src/components/AppList.vue
-
102app/renderer/src/main/src/components/AppTabs.vue
-
58app/renderer/src/main/src/components/AppWindow.vue
-
67app/renderer/src/main/src/components/GlobalHeader.vue
-
100app/renderer/src/main/src/components/LoginDialog.vue
-
45app/renderer/src/main/src/components/NativeApiExample.vue
-
70app/renderer/src/main/src/components/Widget.vue
-
13app/renderer/src/main/src/lib/index.js
-
17app/renderer/src/main/src/lib/mixins/index.js
-
38app/renderer/src/main/src/main.js
-
39app/renderer/src/main/src/router/index.js
-
57app/renderer/src/main/src/store/index.js
-
89app/renderer/src/main/src/views/Application.vue
-
89app/renderer/src/main/src/views/Home.vue
-
81app/renderer/src/main/src/views/Login.vue
-
6app/renderer/src/main/vue.config.js
-
9009app/renderer/src/main/yarn.lock
-
BINappicon.ico
-
BINasserts/l_bg.jpg
-
BINasserts/login_bg.png
-
10config/config.json
-
1data.json
-
16data/method.json
-
22js/api.js
-
9js/axios.min.js
-
85js/preload.js
@ -0,0 +1,39 @@ |
|||||
|
CC0 1.0 Universal |
||||
|
================== |
||||
|
|
||||
|
Statement of Purpose |
||||
|
--------------------- |
||||
|
|
||||
|
The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner") of an original work of authorship and/or a database (each, a "Work"). |
||||
|
|
||||
|
Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and without fear of later claims of infringement build upon, modify, incorporate in other works, reuse and redistribute as freely as possible in any form whatsoever and for any purposes, including without limitation commercial purposes. These owners may contribute to the Commons to promote the ideal of a free culture and the further production of creative, cultural and scientific works, or to gain reputation or greater distribution for their Work in part through the use and efforts of others. |
||||
|
|
||||
|
For these and/or other purposes and motivations, and without any expectation of additional consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those rights. |
||||
|
|
||||
|
1. Copyright and Related Rights. |
||||
|
-------------------------------- |
||||
|
A Work made available under CC0 may be protected by copyright and related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights include, but are not limited to, the following: |
||||
|
|
||||
|
i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work; |
||||
|
ii. moral rights retained by the original author(s) and/or performer(s); |
||||
|
iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work; |
||||
|
iv. rights protecting against unfair competition in regards to a Work, subject to the limitations in paragraph 4(a), below; |
||||
|
v. rights protecting the extraction, dissemination, use and reuse of data in a Work; |
||||
|
vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, and under any national implementation thereof, including any amended or successor version of such directive); and |
||||
|
vii. other similar, equivalent or corresponding rights throughout the world based on applicable law or treaty, and any national implementations thereof. |
||||
|
|
||||
|
2. Waiver. |
||||
|
----------- |
||||
|
To the greatest extent permitted by, but not in contravention of, applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons, and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of action, whether now known or unknown (including existing as well as future claims and causes of action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's heirs and successors, fully intending that such Waiver shall not be subject to revocation, rescission, cancellation, termination, or any other legal or equitable action to disrupt the quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of Purpose. |
||||
|
|
||||
|
3. Public License Fallback. |
||||
|
---------------------------- |
||||
|
Should any part of the Waiver for any reason be judged legally invalid or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by applicable law or treaty (including future time extensions), (iii) in any current or future medium and for any number of copies, and (iv) for any purpose whatsoever, including without limitation commercial, advertising or promotional purposes (the "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to the Work. Should any part of the License for any reason be judged legally invalid or ineffective under applicable law, such partial invalidity or ineffectiveness shall not invalidate the remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i) exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any associated claims and causes of action with respect to the Work, in either case contrary to Affirmer's express Statement of Purpose. |
||||
|
|
||||
|
4. Limitations and Disclaimers. |
||||
|
-------------------------------- |
||||
|
|
||||
|
a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or otherwise affected by this document. |
||||
|
b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning the Work, express, implied, statutory or otherwise, including without limitation warranties of title, merchantability, fitness for a particular purpose, non infringement, or the absence of latent or other defects, accuracy, or the present or absence of errors, whether or not discoverable, all to the greatest extent permissible under applicable law. |
||||
|
c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work or any use thereof, including without limitation any person's Copyright and Related Rights in the Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents, permissions or other rights required for any use of the Work. |
||||
|
d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and has no duty or obligation with respect to this CC0 or use of the Work. |
@ -0,0 +1,49 @@ |
|||||
|
# electron-quick-start |
||||
|
|
||||
|
**Clone and run for a quick way to see Electron in action.** |
||||
|
|
||||
|
This is a minimal Electron application based on the [Quick Start Guide](https://electronjs.org/docs/tutorial/quick-start) within the Electron documentation. |
||||
|
|
||||
|
**Use this app along with the [Electron API Demos](https://electronjs.org/#get-started) app for API code examples to help you get started.** |
||||
|
|
||||
|
A basic Electron application needs just these files: |
||||
|
|
||||
|
- `package.json` - Points to the app's main file and lists its details and dependencies. |
||||
|
- `main.js` - Starts the app and creates a browser window to render HTML. This is the app's **main process**. |
||||
|
- `index.html` - A web page to render. This is the app's **renderer process**. |
||||
|
|
||||
|
You can learn more about each of these components within the [Quick Start Guide](https://electronjs.org/docs/tutorial/quick-start). |
||||
|
|
||||
|
## To Use |
||||
|
|
||||
|
To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line: |
||||
|
|
||||
|
```bash |
||||
|
# Clone this repository |
||||
|
git clone https://github.com/electron/electron-quick-start |
||||
|
# Go into the repository |
||||
|
cd electron-quick-start |
||||
|
# Install dependencies |
||||
|
npm install |
||||
|
# Run the app |
||||
|
npm start |
||||
|
``` |
||||
|
|
||||
|
Note: If you're using Linux Bash for Windows, [see this guide](https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/) or use `node` from the command prompt. |
||||
|
|
||||
|
## Resources for Learning Electron |
||||
|
|
||||
|
- [electronjs.org/docs](https://electronjs.org/docs) - all of Electron's documentation |
||||
|
- [electronjs.org/community#boilerplates](https://electronjs.org/community#boilerplates) - sample starter apps created by the community |
||||
|
- [electron/electron-quick-start](https://github.com/electron/electron-quick-start) - a very basic starter Electron app |
||||
|
- [electron/simple-samples](https://github.com/electron/simple-samples) - small applications with ideas for taking them further |
||||
|
- [electron/electron-api-demos](https://github.com/electron/electron-api-demos) - an Electron app that teaches you how to use Electron |
||||
|
- [hokein/electron-sample-apps](https://github.com/hokein/electron-sample-apps) - small demo apps for the various Electron APIs |
||||
|
|
||||
|
## License |
||||
|
|
||||
|
[CC0 1.0 (Public Domain)](LICENSE.md) |
||||
|
|
||||
|
打包文件通过 |
||||
|
|
||||
|
asar pack app app.asar 命令执行 |
@ -0,0 +1,36 @@ |
|||||
|
const path = require('path'); |
||||
|
const data_path = "/home/kylin/tcop/TIS_ZDFWGK_CPP/data/app/xmlx.json"; |
||||
|
const fs = require("fs"); |
||||
|
let data = null; |
||||
|
exports.MANUAL_CREATED_FLAG = Symbol("MANUAL_CREATED"); |
||||
|
exports.MAIN_WINDOW_FLAG = Symbol("MAIN_WINDOW"); |
||||
|
|
||||
|
exports.SUSPENSION_WINDOW_FLAG = Symbol("SUSPENSION_WINDOW_FLAG"); |
||||
|
|
||||
|
// exports.MAIN_WINDOW_URL = "file://" + path.resolve(__dirname, '../renderer/pages/main/index.html')
|
||||
|
// exports.APP_WINDOW_URL = "file://" + path.resolve(__dirname, '../renderer/pages/main/index.html?view=application')
|
||||
|
// exports.LOGIN_WINDOW_URL = "file://" + path.resolve(__dirname, '../renderer/pages/main/index.html?view=login')
|
||||
|
|
||||
|
try { |
||||
|
data = JSON.parse(fs.readFileSync(data_path,'utf-8')); |
||||
|
}catch (e) { |
||||
|
data = {schema:"QB"} |
||||
|
} |
||||
|
const schema = data.schema; |
||||
|
let url = ""; |
||||
|
switch (schema) { |
||||
|
case 'KT': |
||||
|
url = 'http://localhost:3806/'; |
||||
|
break; |
||||
|
case 'QB': |
||||
|
url = 'http://localhost:3806/TIS_PLATFORM/'; |
||||
|
break; |
||||
|
default: |
||||
|
url = 'http://localhost:3806/TIS_PLATFORM/'; |
||||
|
break; |
||||
|
} |
||||
|
exports.MAIN_WINDOW_URL = url; |
||||
|
exports.SUSPENSION_WINDOW_URL = "file://" + path.resolve(__dirname, '../renderer/pages/suspension/index.html') |
||||
|
|
||||
|
// exports.APP_WINDOW_URL = 'http://localhost:8080/?view=application'
|
||||
|
// exports.LOGIN_WINDOW_URL = 'http://localhost:8080/?view=login'
|
@ -0,0 +1,45 @@ |
|||||
|
const { app, BrowserWindow, dialog, protocol } = require('electron') |
||||
|
const { create: createMainWindow } = require('./windows/main') |
||||
|
const { MANUAL_CREATED_FLAG } = require('./constant') |
||||
|
const handleIPC = require('./ipc') |
||||
|
|
||||
|
app.commandLine.appendSwitch("--disable-http-cache"); |
||||
|
app.whenReady().then(() => { |
||||
|
protocol.registerFileProtocol('file', (request, callback) => { |
||||
|
const pathname = decodeURI(request.url.replace('file:///', '')); |
||||
|
callback(pathname); |
||||
|
}); |
||||
|
handleIPC(); |
||||
|
createMainWindow() |
||||
|
app.on('browser-window-created', (event, window) => { |
||||
|
setTimeout(() => { |
||||
|
if (window[MANUAL_CREATED_FLAG]) { // allow safe created manually
|
||||
|
return |
||||
|
} |
||||
|
dialog.showMessageBox({ |
||||
|
type: "warning", |
||||
|
title: "提示", |
||||
|
message: "新开窗口必须使用内置openWindow接口", |
||||
|
}) |
||||
|
try { |
||||
|
window.destroy() |
||||
|
} catch (e) { |
||||
|
console.error(e) |
||||
|
} |
||||
|
}, 100) |
||||
|
}) |
||||
|
|
||||
|
app.on('activate', () => { |
||||
|
// On macOS it's common to re-create a window in the app when the
|
||||
|
// dock icon is clicked and there are no other windows open.
|
||||
|
if (BrowserWindow.getAllWindows().length === 0) { |
||||
|
createMainWindow() |
||||
|
} |
||||
|
}) |
||||
|
}) |
||||
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
|
// for applications and their menu bar to stay active until the user quits
|
||||
|
// explicitly with Cmd + Q.
|
||||
|
app.on('window-all-closed', function () { |
||||
|
if (process.platform !== 'darwin') app.quit() |
||||
|
}) |
@ -0,0 +1,212 @@ |
|||||
|
const {BrowserWindow} = require('electron'); |
||||
|
const ipc = require('electron').ipcMain; |
||||
|
// const screen = require('electron').screen;
|
||||
|
const store = require('./windows/lib/store'); |
||||
|
const {create: createMainWindow} = require('./windows/main') |
||||
|
// const { create: createLoginWindow } = require('./windows/login')
|
||||
|
// const { create: createAppWindow } = require('./windows/app')
|
||||
|
|
||||
|
const {MAIN_WINDOW_FLAG, SUSPENSION_WINDOW_FLAG} = require('./constant'); |
||||
|
// const installApp = require('./ipc/installApp');
|
||||
|
// const getApps = require('./ipc/getApps');
|
||||
|
// const removeApp = require('./ipc/removeApp');
|
||||
|
|
||||
|
|
||||
|
module.exports = () => { |
||||
|
let winStartPostion = {x: 0, y: 0}; |
||||
|
let mouseStartPosition = {x: 0, y: 0}; |
||||
|
let movingInterVal = null; |
||||
|
ipc.on('getUnReadMessage', (events, callback) => { |
||||
|
const msg = store.get('unReadMessage'); |
||||
|
// console.log('msg', msg);
|
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const found = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
found.webContents.send("getUnReadMessage", [msg]) |
||||
|
}); |
||||
|
ipc.on('setUnReadMessage', (events, message) => { |
||||
|
// console.log('set', message);
|
||||
|
store.set('unReadMessage', message); |
||||
|
// 消息需要实时同步
|
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const win = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
if (win) { |
||||
|
// let winWidth = win.getSize()[0];
|
||||
|
let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize; |
||||
|
const x = win.getPosition()[0]; |
||||
|
const y = win.getPosition()[1]; |
||||
|
let sWidth = areaSize.width; |
||||
|
// console.log(sWidth - x);
|
||||
|
if (sWidth - x === 130) { |
||||
|
win.setSize(640, 130, true); |
||||
|
win.setPosition(sWidth - 660, y, true); |
||||
|
} |
||||
|
win.webContents.send("getUnReadMessage", [message]) |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
ipc.on("showSuspensionWindow",()=>{ |
||||
|
let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize; |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const win = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
console.log('恢复原始大小') |
||||
|
win.setSize(640, 130, true); |
||||
|
const y = win.getPosition()[1]; |
||||
|
win.setPosition(areaSize.width - win.getSize()[0], y, true); |
||||
|
win.webContents.send("winResize", [win.getSize()]) |
||||
|
|
||||
|
}) |
||||
|
ipc.on('resizeWindow', () => { |
||||
|
let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize; |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const win = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
const startWidth = win.getSize()[0]; |
||||
|
if(startWidth < 640){ |
||||
|
const x = win.getPosition()[0]; |
||||
|
const y = win.getPosition()[1]; |
||||
|
win.setSize(640, 130, true); |
||||
|
if(x > areaSize.width - win.getSize()[0] ){ |
||||
|
win.setPosition(areaSize.width - win.getSize()[0] - 50, y, true); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
ipc.on('windowMoveHandle', (events, canMoving) => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const win = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
const screen = require('electron').screen; |
||||
|
/** |
||||
|
* 窗口移动事件 |
||||
|
*/ |
||||
|
if (canMoving) { |
||||
|
if (!win) return; |
||||
|
//读取原位置
|
||||
|
const winPosition = win.getPosition(); |
||||
|
winStartPostion = {x: winPosition[0], y: winPosition[1]}; |
||||
|
mouseStartPosition = screen.getCursorScreenPoint(); |
||||
|
//清除
|
||||
|
if (movingInterVal) { |
||||
|
clearInterval(movingInterVal); |
||||
|
} |
||||
|
//新开
|
||||
|
movingInterVal = setInterval(() => { |
||||
|
const cursorPosition = screen.getCursorScreenPoint(); |
||||
|
const x = winStartPostion.x + cursorPosition.x - mouseStartPosition.x; |
||||
|
const y = winStartPostion.y + cursorPosition.y - mouseStartPosition.y; |
||||
|
|
||||
|
win.setPosition(x, y, true) |
||||
|
}, 20) |
||||
|
} else { |
||||
|
clearInterval(movingInterVal); |
||||
|
let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize; |
||||
|
const x = win.getPosition()[0]; |
||||
|
const y = win.getPosition()[1]; |
||||
|
store.set("position",{x,y}); |
||||
|
let sWidth = areaSize.width; |
||||
|
let winWidth = win.getSize()[0]; |
||||
|
// console.log(x + winWidth >= sWidth, sWidth - x - winWidth);
|
||||
|
// 靠边吸附效果
|
||||
|
console.log("0000000",x + winWidth >= sWidth,sWidth - x - winWidth <= 20) |
||||
|
if (x + winWidth >= sWidth || sWidth - x - winWidth <= 20) { |
||||
|
win.setResizable(true); |
||||
|
win.setSize(130,130,true) |
||||
|
|
||||
|
win.setPosition(sWidth - 130, y, true); |
||||
|
win.setResizable(false); |
||||
|
console.log("靠边吸附",win.getSize(),win.getPosition()) |
||||
|
//通知渲染进程大小发生改变
|
||||
|
}else{ |
||||
|
win.setSize(650,130,true) |
||||
|
} |
||||
|
win.webContents.send("winResize", [win.getSize()]) |
||||
|
movingInterVal = null; |
||||
|
} |
||||
|
}); |
||||
|
ipc.on('showMainWindow', (event, arg) => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const found = windows.find((window) => { |
||||
|
return window[MAIN_WINDOW_FLAG] |
||||
|
}) |
||||
|
if (found) { |
||||
|
found.restore(); |
||||
|
found.show(); |
||||
|
} else { |
||||
|
createMainWindow() |
||||
|
} |
||||
|
return true |
||||
|
}); |
||||
|
ipc.on('hideMainWindow', () => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const found = windows.find((window) => { |
||||
|
return window[MAIN_WINDOW_FLAG] |
||||
|
}) |
||||
|
if (found) { |
||||
|
found.hide(); |
||||
|
} |
||||
|
return true |
||||
|
}); |
||||
|
ipc.on('minimize', () => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const found = windows.find((window) => { |
||||
|
return window[MAIN_WINDOW_FLAG] |
||||
|
}) |
||||
|
if (found) { |
||||
|
found.minimize(); |
||||
|
} |
||||
|
return true |
||||
|
}); |
||||
|
|
||||
|
ipc.on('hideSuspensionWindow', (event, arg) => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const found = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
if (found) { |
||||
|
found.close() |
||||
|
} |
||||
|
return true |
||||
|
}); |
||||
|
|
||||
|
ipc.on('openDevTools', (event, arg) => { |
||||
|
event.sender.webContents.openDevTools() |
||||
|
return true |
||||
|
}); |
||||
|
|
||||
|
ipc.on('exitSystem', () => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
const mainWindow = windows.find((window) => { |
||||
|
return window[MAIN_WINDOW_FLAG] |
||||
|
}) |
||||
|
const suspWindow = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
store.delete("unReadMessage"); |
||||
|
mainWindow && mainWindow.close(); |
||||
|
suspWindow && suspWindow.close(); |
||||
|
}); |
||||
|
// ipcMain.handle('openWidget', (event, widget = {}) => {
|
||||
|
// createAppWindow(widget)
|
||||
|
// return true
|
||||
|
// });
|
||||
|
//
|
||||
|
// ipcMain.handle('openDevTools', (event, arg) => {
|
||||
|
// event.sender.webContents.openDevTools()
|
||||
|
// return true
|
||||
|
// });
|
||||
|
|
||||
|
// ipcMain.handle('installApp', installApp);
|
||||
|
//
|
||||
|
// ipcMain.handle('getApps', getApps);
|
||||
|
//
|
||||
|
// ipcMain.handle('removeApp', removeApp);
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
const fse = require('fs-extra') |
||||
|
const path = require('path') |
||||
|
const { app } = require('electron') |
||||
|
|
||||
|
module.exports = async (event, arg) => { |
||||
|
const appsDir = path.resolve(app.getPath('home'), `./s207/apps`) |
||||
|
let apps = await fse.readdirSync(appsDir) |
||||
|
|
||||
|
apps = await Promise.all(apps.map((id) => { |
||||
|
const appDir = path.resolve(appsDir, `./${id}`) |
||||
|
const appJson = fse.readJsonSync(path.resolve(appDir, `./app.json`)) |
||||
|
return { |
||||
|
...appJson, |
||||
|
appDir |
||||
|
} |
||||
|
})) |
||||
|
|
||||
|
return apps |
||||
|
} |
@ -0,0 +1,70 @@ |
|||||
|
const { app } = require('electron') |
||||
|
const fs = require('fs') |
||||
|
const path = require('path') |
||||
|
// const unzipper = require('unzipper')
|
||||
|
const fse = require('fs-extra'); |
||||
|
|
||||
|
// function unzip(source, dest) {
|
||||
|
// return new Promise((resolve, reject) => {
|
||||
|
// fs.createReadStream(source)
|
||||
|
// .pipe(unzipper.Extract({ path: dest }))
|
||||
|
// .promise()
|
||||
|
// .then(() => resolve(true), (e) => reject(e))
|
||||
|
// });
|
||||
|
// }
|
||||
|
|
||||
|
async function checkAppFolder(folderPath) { |
||||
|
// check index.html
|
||||
|
const htmlFilePath = path.resolve(folderPath, './index.html') |
||||
|
if (!await fs.existsSync(htmlFilePath)) { |
||||
|
throw new Error('软件包中缺少入口index.html文件') |
||||
|
} |
||||
|
const htmlStr = await fs.readFileSync(htmlFilePath).toString() |
||||
|
if (!htmlStr.includes('<html')) { |
||||
|
throw new Error("软件包中index.html不是合法的html文件") |
||||
|
} |
||||
|
|
||||
|
// check logo.png
|
||||
|
const logoFilePath = path.resolve(folderPath, './logo.png') |
||||
|
if (!await fs.existsSync(logoFilePath)) { |
||||
|
throw new Error('软件包中缺少图标文件logo.png') |
||||
|
} |
||||
|
|
||||
|
// check app.json
|
||||
|
const appJsonFilePath = path.resolve(folderPath, './app.json') |
||||
|
if (!await fs.existsSync(appJsonFilePath)) { |
||||
|
throw new Error('软件包中缺少app.json') |
||||
|
} |
||||
|
const jsonStr = await fs.readFileSync(appJsonFilePath).toString() |
||||
|
let json = {} |
||||
|
try { |
||||
|
json = JSON.parse(jsonStr) |
||||
|
} catch (e) { |
||||
|
throw new Error('解析app.json失败') |
||||
|
} |
||||
|
['id', 'name'].forEach((k) => { |
||||
|
if (!(typeof json[k] === 'string' && json[k].length >= 2)) { |
||||
|
throw new Error(`app.json里${k}字段不合法,必须是长度为2以上的字符串`) |
||||
|
} |
||||
|
}) |
||||
|
return { |
||||
|
...json, |
||||
|
logoFilePath, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = async (event, zipPath) => { |
||||
|
const tempDir = path.resolve(app.getPath('temp'), `./s207/install_apps/${Date.now()}`) |
||||
|
|
||||
|
// await unzip(zipPath, tempDir)
|
||||
|
|
||||
|
const { id, name } = await checkAppFolder(tempDir) |
||||
|
|
||||
|
const targetDir = path.resolve(app.getPath('home'), `./s207/apps/${id}`) |
||||
|
if (fse.pathExistsSync(targetDir)) { |
||||
|
throw new Error(`【${name} id:${id}】应用已存在,请删除后重新安装`) |
||||
|
} |
||||
|
await fse.moveSync(tempDir, targetDir) |
||||
|
|
||||
|
return targetDir |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
const { app } = require('electron') |
||||
|
const path = require('path') |
||||
|
const fse = require('fs-extra') |
||||
|
|
||||
|
module.exports = async (event, appId) => { |
||||
|
const appDir = path.resolve(app.getPath('home'), `./s207/apps/${appId}`) |
||||
|
return fse.removeSync(appDir) |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
const { APP_WINDOW_URL } = require("../constant") |
||||
|
const { createWindow } = require('./lib/common') |
||||
|
|
||||
|
const create = (widget) => { |
||||
|
const win = createWindow(APP_WINDOW_URL + `&widget=${JSON.stringify(widget)}`) |
||||
|
return win |
||||
|
} |
||||
|
|
||||
|
module.exports = { create } |
@ -0,0 +1,29 @@ |
|||||
|
const { BrowserWindow } = require('electron') |
||||
|
const path = require('path') |
||||
|
|
||||
|
const { MANUAL_CREATED_FLAG } = require('../../constant') |
||||
|
|
||||
|
function createWindow(url,options,node=false) { |
||||
|
// let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize
|
||||
|
const window = new BrowserWindow({ |
||||
|
// width: 870,
|
||||
|
// height: 530,
|
||||
|
webPreferences: { |
||||
|
webSecurity: false, |
||||
|
contextIsolation: false, |
||||
|
enableRemoteModule:true, |
||||
|
nodeIntegration: node, |
||||
|
preload: path.join(__dirname, 'preload.js') |
||||
|
}, |
||||
|
...options |
||||
|
}) |
||||
|
|
||||
|
window[MANUAL_CREATED_FLAG] = true |
||||
|
|
||||
|
console.log('openWindow', url) |
||||
|
window.loadURL(url) |
||||
|
// window.webContents.openDevTools() // Open the DevTools.
|
||||
|
return window |
||||
|
} |
||||
|
|
||||
|
module.exports = { createWindow } |
@ -0,0 +1 @@ |
|||||
|
{"test":{"a":1},"test2":{"name":"我是你爹"}} |
@ -0,0 +1,37 @@ |
|||||
|
// 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.api = [ |
||||
|
"showSuspensionWindow", |
||||
|
"resizeWindow", |
||||
|
"setUnReadMessage", |
||||
|
"getUnReadMessage", |
||||
|
"windowMoveHandle", |
||||
|
"exitSystem", |
||||
|
"openDevTools", |
||||
|
"hideMainWindow", |
||||
|
"showMainWindow", |
||||
|
"minimize", |
||||
|
"hideSuspensionWindow" |
||||
|
].reduce((acc, apiName) => { |
||||
|
acc[apiName] = (...params) => { |
||||
|
return ipcRenderer.send(apiName, ...params) |
||||
|
} |
||||
|
return acc |
||||
|
}, { |
||||
|
on: ipcRenderer.on.bind(ipcRenderer), |
||||
|
removeListener: ipcRenderer.removeListener.bind(ipcRenderer) |
||||
|
}); |
||||
|
|
||||
|
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(); |
||||
|
} |
||||
|
}) |
@ -0,0 +1,33 @@ |
|||||
|
// const Store = require('electron-store');
|
||||
|
// const store = new Store();//
|
||||
|
|
||||
|
const data_path = "./data.json"; |
||||
|
const fs = require("fs") |
||||
|
|
||||
|
class Store { |
||||
|
constructor(){ |
||||
|
fs.writeFileSync(data_path,JSON.stringify({})) |
||||
|
} |
||||
|
set(key, param) { |
||||
|
// let saveData = {key:param};
|
||||
|
console.log("------",key,param); |
||||
|
let oldData = require('./data.json'); |
||||
|
oldData[key] = param; |
||||
|
// console.log('======',oldData);
|
||||
|
fs.writeFileSync(data_path,JSON.stringify(oldData)) |
||||
|
} |
||||
|
get(key){ |
||||
|
const data = JSON.parse(fs.readFileSync(data_path,'utf-8')); |
||||
|
// console.log('get>>>>>>>>>',data[key])
|
||||
|
return data[key]; |
||||
|
} |
||||
|
delete(key){ |
||||
|
let oldData = require('./data.json'); |
||||
|
delete oldData[key]; |
||||
|
fs.writeFileSync(data_path,JSON.stringify(oldData)) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const store = new Store(); |
||||
|
|
||||
|
module.exports = store |
@ -0,0 +1,20 @@ |
|||||
|
const { LOGIN_WINDOW_URL } = require("../constant") |
||||
|
const { createWindow } = require('./lib/common') |
||||
|
|
||||
|
const create = () => { |
||||
|
const win = createWindow(LOGIN_WINDOW_URL, { |
||||
|
width: 500, |
||||
|
height: 400, |
||||
|
alwaysOnTop: true, |
||||
|
// modal: true,
|
||||
|
// parent: event.sender,
|
||||
|
minimizable: false, |
||||
|
fullscreenable: false, |
||||
|
maximizable: false, |
||||
|
resizable: false, |
||||
|
focusable: true |
||||
|
}) |
||||
|
return win |
||||
|
} |
||||
|
|
||||
|
module.exports = { create } |
@ -0,0 +1,37 @@ |
|||||
|
const { MAIN_WINDOW_FLAG, MAIN_WINDOW_URL } = require("../constant") |
||||
|
const { createWindow } = require('./lib/common') |
||||
|
const { BrowserWindow } = require('electron') |
||||
|
const { create: createSuspensionWindow } = require('./suspension'); |
||||
|
|
||||
|
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 |
||||
|
}) |
||||
|
win[MAIN_WINDOW_FLAG] = true |
||||
|
|
||||
|
// win.on('ready-to-show', () => {
|
||||
|
// win.show();
|
||||
|
// });
|
||||
|
win.on('hide', () => { |
||||
|
createSuspensionWindow(); |
||||
|
}); |
||||
|
return create(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
module.exports = { create } |
@ -0,0 +1,57 @@ |
|||||
|
const { BrowserWindow } = require('electron') |
||||
|
const { createWindow } = require('./lib/common') |
||||
|
const { SUSPENSION_WINDOW_URL, SUSPENSION_WINDOW_FLAG } = require("../constant") |
||||
|
const store = require('./lib/store') |
||||
|
const create = () => { |
||||
|
const windows = BrowserWindow.getAllWindows() |
||||
|
let win = windows.find((window) => { |
||||
|
return window[SUSPENSION_WINDOW_FLAG] |
||||
|
}); |
||||
|
|
||||
|
if (win) { |
||||
|
win.show(); |
||||
|
return win; |
||||
|
} |
||||
|
let areaSize = require('electron').screen.getPrimaryDisplay().workAreaSize |
||||
|
win = createWindow(SUSPENSION_WINDOW_URL, { |
||||
|
// width: 500,
|
||||
|
// height: 400,
|
||||
|
// alwaysOnTop: true,
|
||||
|
// // modal: true,
|
||||
|
// // parent: event.sender,
|
||||
|
// minimizable: false,
|
||||
|
// fullscreenable: false,
|
||||
|
// maximizable: false,
|
||||
|
// resizable: false,
|
||||
|
// focusable: true
|
||||
|
width: 427, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框
|
||||
|
height: 130, //悬浮窗口的高度 比实际DIV的高度要多2px 因为有1px的边框
|
||||
|
// width: 500,
|
||||
|
// height: 500,
|
||||
|
type: 'toolbar', //创建的窗口类型为工具栏窗口
|
||||
|
frame: false, //要创建无边框窗口
|
||||
|
resizable: false, //禁止窗口大小缩放
|
||||
|
show: true, //先不让窗口显示
|
||||
|
transparent: true, //设置透明
|
||||
|
alwaysOnTop: true, //窗口是否总是显示在其他窗口之前
|
||||
|
},true) |
||||
|
|
||||
|
// const size = screen.getPrimaryDisplay().workAreaSize; //获取显示器的宽高
|
||||
|
const winSize = win.getSize(); //获取窗口宽高
|
||||
|
// //设置窗口的位置 注意x轴要桌面的宽度 - 窗口的宽度
|
||||
|
const pos = store.get("position"); |
||||
|
if(pos){ |
||||
|
console.log('aaaaaaaaaa',pos); |
||||
|
win.setPosition(pos.x, pos.y); |
||||
|
}else{ |
||||
|
win.setPosition(areaSize.width - winSize[0] - 50, areaSize.height - winSize[1] - 50); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
win[SUSPENSION_WINDOW_FLAG] = true; |
||||
|
|
||||
|
|
||||
|
return create(); |
||||
|
} |
||||
|
|
||||
|
module.exports = { create } |
@ -0,0 +1,44 @@ |
|||||
|
{ |
||||
|
"name": "esdesktop-launcher-electron", |
||||
|
"version": "4.0.0", |
||||
|
"description": "", |
||||
|
"#main": "main.js", |
||||
|
"main":"main/index.js", |
||||
|
"build": { |
||||
|
"appId": "com.rjjh.app", |
||||
|
"win": { |
||||
|
"target": [ |
||||
|
"nsis", |
||||
|
"zip" |
||||
|
] |
||||
|
} |
||||
|
}, |
||||
|
"scripts":{ |
||||
|
"start": "cross-env NODE_ENV=development electron . ", |
||||
|
"packager": "electron-packager ./app esdesktop-app --all --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"electron_win": "cross-env NODE_ENV=production electron-packager ./app launcher --platform=win32 --arch=x64 --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"electron_linux": "cross-env NODE_ENV=production electron-packager ./app launcher --platform=linux --arch=x64 --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"electron_arm64": "electron-packager ./app launcher --platform=linux --arch=arm64 --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"electron_mips64el": "electron-packager ./app launcher --platform=linux --arch=mips64el --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"electron_mips": "electron-packager ./app launcher --platform=linux --arch=mips --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"electron_yw_arm64": "electron-packager ./tisywkj tisywkj --platform=linux --arch=arm64 --out ./OutApp --app-version 1.4.0 --overwrite --icon=./tray/appicon.ico", |
||||
|
"test": "echo \"Error: no test specified\" && exit 1", |
||||
|
"dist": "electron-builder -w", |
||||
|
"dist_x64": "electron-builder --linux --x64", |
||||
|
"dist_arm64": "electron-builder --linux --arm64", |
||||
|
"electron_build": "electron-builder build --linux --x64" |
||||
|
}, |
||||
|
"author": "", |
||||
|
"license": "ISC", |
||||
|
"devDependencies": { |
||||
|
"asar": "^3.0.3", |
||||
|
"cross-env": "^5.2.0", |
||||
|
"electron": "4.1.2" |
||||
|
}, |
||||
|
"dependencies": { |
||||
|
"axios": "^0.18.1", |
||||
|
"electron-builder": "^22.6.1", |
||||
|
"electron-packager": "^13.1.1", |
||||
|
"electron-store": "^8.0.0" |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
.widget[data-v-96d0bcc0]{height:100%;display:flex;justify-content:center;align-items:center;flex-direction:column}.widget .image[data-v-96d0bcc0]{width:100%}.widget .icon[data-v-96d0bcc0]{width:55%;margin-bottom:10px}.widget .name[data-v-96d0bcc0]{margin:0;padding:0;text-align:center;font-size:2vw;color:#fff}.header[data-v-b29ccbe8]{padding:0 10px;display:flex;justify-content:space-between;align-items:center;background:#151515;height:48px}.header .title[data-v-b29ccbe8]{font-size:18px}.header .user[data-v-b29ccbe8]{color:#fff;cursor:pointer;display:flex;justify-content:space-between;align-items:center}.header .user .username[data-v-b29ccbe8]{margin:0 10px}.header .el-button--text[data-v-b29ccbe8]{color:#fff}.content[data-v-b29ccbe8]{padding:5px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.content .el-col[data-v-b29ccbe8]{padding:5px}.widget-item[data-v-b29ccbe8]{cursor:pointer;border-radius:4px;height:16vw;background:#2b2b2b;display:flex;justify-content:center;align-items:center;transition:all .3s ease-in-out}.widget-item[data-v-b29ccbe8]:hover{transform:scale(1.03)}.title[data-v-9f85a70a]{padding:20px;text-align:center}.content[data-v-9f85a70a]{padding:20px 50px}.content[data-v-9f85a70a] .el-input__inner{background-color:#2b2b2b!important;color:#fff}.header[data-v-00741276]{padding:0 10px;display:flex;justify-content:space-between;align-items:center;background:#151515;height:48px}.header .title[data-v-00741276]{font-size:18px}.header .user[data-v-00741276]{color:#fff;cursor:pointer;display:flex;justify-content:space-between;align-items:center}.header .user .username[data-v-00741276]{margin:0 10px}.content[data-v-00741276]{padding-top:30vh;width:50vw;margin:auto}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}*{margin:0;padding:0}.page{min-height:100vh;background:#0b0b0b;color:#fff} |
1
app/renderer/pages/main/css/chunk-vendors.84bb20f7.css
File diff suppressed because it is too large
View File
After Width: 278 | Height: 276 | Size: 5.8 KiB |
@ -0,0 +1,23 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width,initial-scale=1"> |
||||
|
<link rel="icon" href="favicon.ico"> |
||||
|
<title>s207-main</title> |
||||
|
<link href="css/app.3f3f7430.css" rel="preload" as="style"> |
||||
|
<link href="css/chunk-vendors.84bb20f7.css" rel="preload" as="style"> |
||||
|
<link href="js/app.e6242064.js" rel="preload" as="script"> |
||||
|
<link href="js/chunk-vendors.679c79aa.js" rel="preload" as="script"> |
||||
|
<link href="css/chunk-vendors.84bb20f7.css" rel="stylesheet"> |
||||
|
<link href="css/app.3f3f7430.css" rel="stylesheet"> |
||||
|
</head> |
||||
|
<body> |
||||
|
<noscript><strong>We're sorry but s207-main doesn't work properly without JavaScript enabled. Please enable it to |
||||
|
continue.</strong></noscript> |
||||
|
<div id="app"></div> |
||||
|
<script src="js/chunk-vendors.679c79aa.js"></script> |
||||
|
<script src="js/app.e6242064.js"></script> |
||||
|
</body> |
||||
|
</html> |
2
app/renderer/pages/main/js/app.e6242064.js
File diff suppressed because it is too large
View File
1
app/renderer/pages/main/js/app.e6242064.js.map
File diff suppressed because it is too large
View File
34
app/renderer/pages/main/js/chunk-vendors.679c79aa.js
File diff suppressed because it is too large
View File
1
app/renderer/pages/main/js/chunk-vendors.679c79aa.js.map
File diff suppressed because it is too large
View File
After Width: 154 | Height: 132 | Size: 9.4 KiB |
After Width: 278 | Height: 276 | Size: 5.8 KiB |
After Width: 282 | Height: 280 | Size: 15 KiB |
After Width: 590 | Height: 274 | Size: 20 KiB |
After Width: 238 | Height: 238 | Size: 23 KiB |
After Width: 1200 | Height: 576 | Size: 499 KiB |
After Width: 126 | Height: 126 | Size: 5.3 KiB |
After Width: 174 | Height: 174 | Size: 8.9 KiB |
After Width: 594 | Height: 276 | Size: 26 KiB |
After Width: 152 | Height: 156 | Size: 11 KiB |
After Width: 140 | Height: 134 | Size: 8.9 KiB |
After Width: 146 | Height: 156 | Size: 9.2 KiB |
After Width: 588 | Height: 276 | Size: 20 KiB |
After Width: 146 | Height: 140 | Size: 6.5 KiB |
After Width: 80 | Height: 80 | Size: 1.4 KiB |
After Width: 77 | Height: 77 | Size: 5.4 KiB |
After Width: 77 | Height: 77 | Size: 3.6 KiB |
@ -0,0 +1,210 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
|
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width,initial-scale=1"> |
||||
|
<script type="text/javascript" src="./lib/vue.js"></script> |
||||
|
</head> |
||||
|
<style scoped> |
||||
|
body { |
||||
|
/*-webkit-app-region: drag;*/ |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
width: 100%; |
||||
|
height: 100%; |
||||
|
overflow: hidden; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.sp-main { |
||||
|
/*width: 425px;*/ |
||||
|
height: 128px; |
||||
|
width: 100%; |
||||
|
/*height: 100%;*/ |
||||
|
display: flex; |
||||
|
overflow: hidden; |
||||
|
align-items: center; |
||||
|
} |
||||
|
|
||||
|
.logo-cover { |
||||
|
height: 128px; |
||||
|
width: 128px; |
||||
|
border-radius: 50%; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
background: #262522; |
||||
|
position: absolute; |
||||
|
} |
||||
|
|
||||
|
.logo { |
||||
|
height: 77px; |
||||
|
width: 77px; |
||||
|
background: #5daf34; |
||||
|
background: url("./img/logo.png") no-repeat; |
||||
|
background-size: 100% 100%; |
||||
|
} |
||||
|
.logo-active{ |
||||
|
height: 77px; |
||||
|
width: 77px; |
||||
|
background: #5daf34; |
||||
|
background: url("./img/logo-active.png") no-repeat; |
||||
|
background-size: 100% 100%; |
||||
|
} |
||||
|
.center-cover { |
||||
|
height: 100%; |
||||
|
width: auto; |
||||
|
display: flex; |
||||
|
align-items: center; |
||||
|
justify-content: space-around; |
||||
|
background: #262522; |
||||
|
flex: 1; |
||||
|
margin-left: 68px; |
||||
|
padding-left: 37px; |
||||
|
user-select: none; |
||||
|
} |
||||
|
|
||||
|
.center { |
||||
|
display: flex; |
||||
|
width: auto; |
||||
|
flex-direction: column; |
||||
|
justify-content: space-around; |
||||
|
height: 77px; |
||||
|
background: #262522; |
||||
|
} |
||||
|
|
||||
|
.text { |
||||
|
font-size: 28px; |
||||
|
color: #ffffff; |
||||
|
font-weight: 600; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.yellow { |
||||
|
color: #f7c829; |
||||
|
} |
||||
|
|
||||
|
.count { |
||||
|
color: #ffffff; |
||||
|
opacity: 0.52; |
||||
|
font-weight: 300; |
||||
|
} |
||||
|
|
||||
|
.back { |
||||
|
height: 80px; |
||||
|
width: 80px; |
||||
|
cursor: pointer; |
||||
|
/*-webkit-app-region: no-drag;*/ |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<body> |
||||
|
<!--<div style="-webkit-app-region: no-drag;height:100%;width: 100%;"></div>--> |
||||
|
<div class="sp-main" id="app" @mouseup="removeMoveListener" @contextmenu="showMenu"> |
||||
|
<div class="logo-cover" @dblclick="showSystem" @click="showSuspensionWin"> |
||||
|
<div :class="unMessage.length===0 ? 'logo':'logo-active'" id="logo"></div> |
||||
|
</div> |
||||
|
<div class="center-cover"> |
||||
|
|
||||
|
<div class="center" v-show="showText"> |
||||
|
<div v-if="unMessage.length===0" class="text">暂无新消息</div> |
||||
|
<div v-else class="text">你有一条来自<span class="yellow">{{unMessage[msgCount-1].type}}</span>的消息</div> |
||||
|
<div class="count">共{{msgCount}}条未读消息</div> |
||||
|
</div> |
||||
|
<img v-show="showText" @click="showSystem" id="back" class="back" src="./img/back.png"> |
||||
|
</div> |
||||
|
</div> |
||||
|
<!--<button id="logo">回复最大化</button>--> |
||||
|
<!--<img src='./img/logo.png' onclick="" alt="s207">--> |
||||
|
</body> |
||||
|
|
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
|
||||
|
const {Menu} = require("electron").remote; |
||||
|
const ipcRenderer = require('electron').ipcRenderer; |
||||
|
let template = [ |
||||
|
{ |
||||
|
label:'退出系统',accelerator:'alt+f4',click:()=>{ |
||||
|
window.api.exitSystem(); |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
let menu = Menu.buildFromTemplate(template); |
||||
|
new Vue({ |
||||
|
el: "#app", |
||||
|
data :{ |
||||
|
msgCount:0, |
||||
|
unMessage:[], |
||||
|
showText:true, |
||||
|
}, |
||||
|
methods:{ |
||||
|
showSystem(e){ |
||||
|
e.preventDefault(); |
||||
|
window.api.showMainWindow(); |
||||
|
window.api.hideSuspensionWindow(); |
||||
|
}, |
||||
|
removeMoveListener(){ |
||||
|
moveWindow(false) |
||||
|
logo.removeEventListener('mousemove', moveWindow) |
||||
|
}, |
||||
|
showMenu(e){ |
||||
|
e.preventDefault(); |
||||
|
menu.popup() |
||||
|
}, |
||||
|
showSuspensionWin(e){ |
||||
|
if(!this.showText && endTime - startTime <200){ |
||||
|
e.preventDefault(); |
||||
|
window.api.showSuspensionWindow(); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
created(){ |
||||
|
this.msgCount = 15; |
||||
|
window.getUnReadMessage = (message)=>{ |
||||
|
console.log('aaaaaaaa',message) |
||||
|
this.msgCount = message.length; |
||||
|
this.unMessage = message; |
||||
|
window.api.resizeWindow(); |
||||
|
}; |
||||
|
ipcRenderer.on("winResize",(e, args) => { |
||||
|
if(args[0][0]>130){ |
||||
|
this.showText = true |
||||
|
}else { |
||||
|
this.showText = false |
||||
|
} |
||||
|
}); |
||||
|
window.api.getUnReadMessage(); |
||||
|
}, |
||||
|
watch:{ |
||||
|
unMessage(){ |
||||
|
|
||||
|
} |
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
function moveWindow(flag = false) { |
||||
|
window.api.windowMoveHandle(flag) |
||||
|
} |
||||
|
let startTime = 0; |
||||
|
let endTime = 0; |
||||
|
|
||||
|
var logo = document.getElementById('logo'); |
||||
|
logo.addEventListener('mousedown', () => { |
||||
|
startTime = new Date().getTime(); |
||||
|
logo.addEventListener('mousemove', moveWindow(true)) |
||||
|
}) |
||||
|
logo.addEventListener('mouseup', () => { |
||||
|
endTime = new Date().getTime(); |
||||
|
|
||||
|
moveWindow(false); |
||||
|
logo.removeEventListener('mousemove', moveWindow) |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
</html> |
11855
app/renderer/pages/suspension/lib/vue.js
File diff suppressed because it is too large
View File
@ -0,0 +1,3 @@ |
|||||
|
> 1% |
||||
|
last 2 versions |
||||
|
not dead |
@ -0,0 +1,14 @@ |
|||||
|
module.exports = { |
||||
|
root: true, |
||||
|
env: { |
||||
|
node: true |
||||
|
}, |
||||
|
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"], |
||||
|
parserOptions: { |
||||
|
parser: "babel-eslint" |
||||
|
}, |
||||
|
rules: { |
||||
|
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off", |
||||
|
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off" |
||||
|
} |
||||
|
}; |
@ -0,0 +1,24 @@ |
|||||
|
# s207-main |
||||
|
|
||||
|
## Project setup |
||||
|
``` |
||||
|
yarn install |
||||
|
``` |
||||
|
|
||||
|
### Compiles and hot-reloads for development |
||||
|
``` |
||||
|
yarn serve |
||||
|
``` |
||||
|
|
||||
|
### Compiles and minifies for production |
||||
|
``` |
||||
|
yarn build |
||||
|
``` |
||||
|
|
||||
|
### Lints and fixes files |
||||
|
``` |
||||
|
yarn lint |
||||
|
``` |
||||
|
|
||||
|
### Customize configuration |
||||
|
See [Configuration Reference](https://cli.vuejs.org/config/). |
@ -0,0 +1,3 @@ |
|||||
|
module.exports = { |
||||
|
presets: ["@vue/cli-plugin-babel/preset"] |
||||
|
}; |
@ -0,0 +1,4 @@ |
|||||
|
const fs = require('fs-extra') |
||||
|
const dest = '../../pages/main' |
||||
|
fs.removeSync(dest) |
||||
|
fs.moveSync('./dist', dest) |
@ -0,0 +1,44 @@ |
|||||
|
{ |
||||
|
"name": "s207-main", |
||||
|
"version": "0.1.0", |
||||
|
"private": true, |
||||
|
"scripts": { |
||||
|
"serve": "vue-cli-service serve", |
||||
|
"build": "vue-cli-service build", |
||||
|
"postbuild": "node ./build.js", |
||||
|
"lint": "vue-cli-service lint" |
||||
|
}, |
||||
|
"dependencies": { |
||||
|
"core-js": "3", |
||||
|
"element-ui": "^2.14.1", |
||||
|
"vue": "^2.6.11", |
||||
|
"vue-router": "^3.2.0", |
||||
|
"vuex": "^3.4.0" |
||||
|
}, |
||||
|
"devDependencies": { |
||||
|
"@vue/cli-plugin-babel": "~4.5.0", |
||||
|
"@vue/cli-plugin-eslint": "~4.5.0", |
||||
|
"@vue/cli-plugin-router": "~4.5.0", |
||||
|
"@vue/cli-plugin-vuex": "~4.5.0", |
||||
|
"@vue/cli-service": "~4.5.0", |
||||
|
"@vue/eslint-config-prettier": "^6.0.0", |
||||
|
"babel-eslint": "^10.1.0", |
||||
|
"eslint": "^6.7.2", |
||||
|
"eslint-plugin-prettier": "^3.1.3", |
||||
|
"eslint-plugin-vue": "^6.2.2", |
||||
|
"lint-staged": "^9.5.0", |
||||
|
"prettier": "^1.19.1", |
||||
|
"sass": "^1.26.5", |
||||
|
"sass-loader": "^8.0.2", |
||||
|
"vue-template-compiler": "^2.6.11" |
||||
|
}, |
||||
|
"gitHooks": { |
||||
|
"pre-commit": "lint-staged" |
||||
|
}, |
||||
|
"lint-staged": { |
||||
|
"*.{js,jsx,vue}": [ |
||||
|
"vue-cli-service lint", |
||||
|
"git add" |
||||
|
] |
||||
|
} |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="en"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width,initial-scale=1.0"> |
||||
|
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> |
||||
|
<title><%= htmlWebpackPlugin.options.title %></title> |
||||
|
</head> |
||||
|
<body> |
||||
|
<noscript> |
||||
|
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> |
||||
|
</noscript> |
||||
|
<div id="app"></div> |
||||
|
<!-- built files will be auto injected --> |
||||
|
</body> |
||||
|
</html> |
After Width: 154 | Height: 132 | Size: 9.4 KiB |
After Width: 278 | Height: 276 | Size: 5.8 KiB |
After Width: 282 | Height: 280 | Size: 15 KiB |
After Width: 590 | Height: 274 | Size: 20 KiB |
After Width: 238 | Height: 238 | Size: 23 KiB |
After Width: 1200 | Height: 576 | Size: 499 KiB |
After Width: 126 | Height: 126 | Size: 5.3 KiB |
After Width: 174 | Height: 174 | Size: 8.9 KiB |
After Width: 594 | Height: 276 | Size: 26 KiB |
After Width: 152 | Height: 156 | Size: 11 KiB |
After Width: 140 | Height: 134 | Size: 8.9 KiB |
After Width: 146 | Height: 156 | Size: 9.2 KiB |
After Width: 588 | Height: 276 | Size: 20 KiB |
After Width: 146 | Height: 140 | Size: 6.5 KiB |
@ -0,0 +1,43 @@ |
|||||
|
<template> |
||||
|
<div id="app"> |
||||
|
<login-dialog /> |
||||
|
<api-doc /> |
||||
|
<HomeView /> |
||||
|
<!-- <router-view /> --> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import HomeView from "@/views/Home"; |
||||
|
import LoginDialog from "./components/LoginDialog.vue"; |
||||
|
import ApiDoc from "./components/ApiDoc.vue"; |
||||
|
|
||||
|
export default { |
||||
|
components: { |
||||
|
HomeView, |
||||
|
LoginDialog, |
||||
|
ApiDoc, |
||||
|
}, |
||||
|
computed: { |
||||
|
view() { |
||||
|
return (this.$route.query.view || "").toLowerCase(); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
<style lang="scss"> |
||||
|
#app { |
||||
|
font-family: Avenir, Helvetica, Arial, sans-serif; |
||||
|
-webkit-font-smoothing: antialiased; |
||||
|
-moz-osx-font-smoothing: grayscale; |
||||
|
} |
||||
|
* { |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
} |
||||
|
.page { |
||||
|
min-height: 100vh; |
||||
|
background: #0b0b0b; |
||||
|
color: #fff; |
||||
|
} |
||||
|
</style> |
After Width: 278 | Height: 276 | Size: 5.8 KiB |
After Width: 200 | Height: 200 | Size: 6.7 KiB |
@ -0,0 +1,84 @@ |
|||||
|
<template> |
||||
|
<div class="api-doc"> |
||||
|
<i |
||||
|
style="font-size: 13px" |
||||
|
class="el-icon-warning-outline" |
||||
|
@click="drawer = true" |
||||
|
> |
||||
|
</i> |
||||
|
<el-drawer append-to-body :with-header="false" :visible.sync="drawer" width="90%"> |
||||
|
<div class="content"> |
||||
|
<h2>应用API文档</h2> |
||||
|
<p style="font-size: 14px"> |
||||
|
所有的api都在window.$api对象上,在Vue的component中,可直接通过this.$api访问到 |
||||
|
</p> |
||||
|
<el-collapse class="collapse"> |
||||
|
<el-collapse-item title="登录" name="1"> |
||||
|
<code>$api.login({ username: "alice", password: "123", });</code> |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="登出" name="2"> |
||||
|
<code>$api.logout();</code> |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="获取前用户信息" name="3"> |
||||
|
<code>const session = $api.getSession();</code> |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="持久化存储" name="4"> |
||||
|
<code>$api.setStoreValue("key", "value");</code> |
||||
|
<code>const value = $api.getStoreValue("key"); </code> |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="获取已安装应用列表"> |
||||
|
const apps = $api.getApps(); |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="获取已安装应用列表"> |
||||
|
const apps = $api.getApps(); |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="安装新应用"> |
||||
|
$api.installApp("zipPath"); |
||||
|
</el-collapse-item> |
||||
|
<el-collapse-item title="卸载应用 "> |
||||
|
$api.removeApp("appId"); |
||||
|
</el-collapse-item> |
||||
|
</el-collapse> |
||||
|
</div> |
||||
|
</el-drawer> |
||||
|
</div> |
||||
|
</template> |
||||
|
<script> |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
drawer: false, |
||||
|
}; |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
.api-doc { |
||||
|
position: fixed; |
||||
|
right: 0; |
||||
|
top: 0; |
||||
|
} |
||||
|
.content { |
||||
|
padding: 5px; |
||||
|
color: #eee; |
||||
|
} |
||||
|
::v-deep .el-drawer { |
||||
|
width: 90% !important; |
||||
|
} |
||||
|
::v-deep .el-drawer__body { |
||||
|
background: #000; |
||||
|
border-left: 1px solid #fff; |
||||
|
overflow: scroll; |
||||
|
} |
||||
|
::v-deep .el-collapse-item__header { |
||||
|
background: none; |
||||
|
color: #eee; |
||||
|
} |
||||
|
::v-deep .el-collapse-item__wrap { |
||||
|
background: none; |
||||
|
.el-collapse-item__content { |
||||
|
color: #ccc; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,144 @@ |
|||||
|
<template> |
||||
|
<div class="content"> |
||||
|
<el-row> |
||||
|
<el-col v-for="(app, index) in apps" :key="index" :span="app.span || 4"> |
||||
|
<div class="widget-item" @click="handleClickApp(app)"> |
||||
|
<Widget |
||||
|
:showRemove="showRemove" |
||||
|
@remove="handleRemoveApp(app)" |
||||
|
:name="app.name" |
||||
|
:icon="`file://${app.appDir}/logo.png`" |
||||
|
:image="app.image" |
||||
|
/> |
||||
|
</div> |
||||
|
</el-col> |
||||
|
<el-col :span="4" v-if="showInstall"> |
||||
|
<div class="widget-item install-app"> |
||||
|
<input |
||||
|
ref="fileInput" |
||||
|
class="file-input" |
||||
|
type="file" |
||||
|
@change="handleInstallApp" |
||||
|
accept=".zip" |
||||
|
/> |
||||
|
<img src="../assets/add.png" style="width: 100%" /> |
||||
|
</div> |
||||
|
</el-col> |
||||
|
</el-row> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import Widget from "@/components/Widget"; |
||||
|
|
||||
|
export default { |
||||
|
name: "Home", |
||||
|
components: { |
||||
|
Widget, |
||||
|
}, |
||||
|
props: { |
||||
|
mode: { |
||||
|
type: String, |
||||
|
default: "default", |
||||
|
}, |
||||
|
}, |
||||
|
data() { |
||||
|
return { |
||||
|
apps: [], |
||||
|
}; |
||||
|
}, |
||||
|
computed: { |
||||
|
showInstall() { |
||||
|
return this.mode !== "choose"; |
||||
|
}, |
||||
|
showRemove() { |
||||
|
return this.mode !== "choose"; |
||||
|
}, |
||||
|
}, |
||||
|
created() { |
||||
|
this.getApps(); |
||||
|
}, |
||||
|
methods: { |
||||
|
async getApps() { |
||||
|
const apps = await this.$api.getApps(); |
||||
|
this.apps = apps; |
||||
|
}, |
||||
|
async handleRemoveApp(app) { |
||||
|
await this.$confirm( |
||||
|
`确认要删除【${app.name} id:${app.id}】程序吗?`, |
||||
|
"提示", |
||||
|
{ |
||||
|
confirmButtonText: "确定", |
||||
|
cancelButtonText: "取消", |
||||
|
type: "warning", |
||||
|
} |
||||
|
); |
||||
|
await this.$api.removeApp(app.id); |
||||
|
this.$message({ |
||||
|
message: "删除成功", |
||||
|
type: "success", |
||||
|
}); |
||||
|
this.getApps(); |
||||
|
}, |
||||
|
async handleInstallApp(e) { |
||||
|
const file = e.target.files[0]; |
||||
|
try { |
||||
|
this.$refs.fileInput.value = ""; // clear to ensure 'change event' if select same file again |
||||
|
} catch (e) { |
||||
|
console.error(e); |
||||
|
} |
||||
|
if (!file) { |
||||
|
return; |
||||
|
} |
||||
|
try { |
||||
|
await this.$api.installApp(file.path); |
||||
|
this.$message({ |
||||
|
message: "安装成功", |
||||
|
type: "success", |
||||
|
}); |
||||
|
this.getApps(); |
||||
|
} catch (err) { |
||||
|
console.log({ err }); |
||||
|
alert(err.message || "未知错误"); |
||||
|
} |
||||
|
}, |
||||
|
handleClickApp(app) { |
||||
|
this.$emit("clickApp", app); |
||||
|
// this.$rpc.invoke("openWidget", widget); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.content { |
||||
|
padding: 5px; |
||||
|
user-select: none; |
||||
|
.el-col { |
||||
|
padding: 5px; |
||||
|
} |
||||
|
} |
||||
|
.widget-item { |
||||
|
cursor: pointer; |
||||
|
border-radius: 4px; |
||||
|
height: 16vw; //(100/6) |
||||
|
background: #2b2b2b; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
transition: all 0.3s ease-in-out; |
||||
|
&:hover { |
||||
|
transform: scale(1.03); |
||||
|
} |
||||
|
} |
||||
|
.install-app { |
||||
|
position: relative; |
||||
|
.file-input { |
||||
|
cursor: pointer; |
||||
|
position: absolute; |
||||
|
height: 100%; |
||||
|
width: 100%; |
||||
|
opacity: 0; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,102 @@ |
|||||
|
<template> |
||||
|
<div class="app-tabs"> |
||||
|
<el-dialog |
||||
|
class="apps-dialog" |
||||
|
title="请选择要打开的应用" |
||||
|
:visible.sync="appListDialogVisible" |
||||
|
width="90%" |
||||
|
> |
||||
|
<app-list @clickApp="handleOpenApp" mode="choose" /> |
||||
|
</el-dialog> |
||||
|
<div |
||||
|
class="item" |
||||
|
v-for="(app, index) in $store.state.openedApps" |
||||
|
:class="$store.getters.activeApps.includes(app) && 'active'" |
||||
|
:key="index" |
||||
|
@click="handleClickAppTab(app, index)" |
||||
|
> |
||||
|
{{ app.name }} |
||||
|
<i class="el-icon-circle-close" @click="handleCloseApp(app, index)"></i> |
||||
|
</div> |
||||
|
<div |
||||
|
v-if="$store.getters.showOpenNewApp" |
||||
|
class="item" |
||||
|
@click="handleOpenNewApp" |
||||
|
> |
||||
|
<i class="el-icon-plus" /> |
||||
|
</div> |
||||
|
<div |
||||
|
v-if="$store.getters.showSplitApp" |
||||
|
class="item" |
||||
|
@click="handleSplitApp" |
||||
|
> |
||||
|
<i class="el-icon-scissors" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import AppList from "./AppList.vue"; |
||||
|
export default { |
||||
|
name: "AppTabs", |
||||
|
components: { AppList }, |
||||
|
data() { |
||||
|
return { |
||||
|
appListDialogVisible: false, |
||||
|
}; |
||||
|
}, |
||||
|
methods: { |
||||
|
handleClickAppTab(app) { |
||||
|
this.$store.commit("activeApp", app); |
||||
|
}, |
||||
|
handleCloseApp(_, index) { |
||||
|
this.$store.commit("closeApp", index); |
||||
|
// this.$bus.$emit("beforeCloseApp", index); |
||||
|
}, |
||||
|
handleOpenNewApp() { |
||||
|
this.appListDialogVisible = true; |
||||
|
}, |
||||
|
handleOpenApp(app) { |
||||
|
this.appListDialogVisible = false; |
||||
|
this.$store.commit("openApp", app); |
||||
|
}, |
||||
|
handleSplitApp() { |
||||
|
this.$store.commit("toggleSplit"); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss"> |
||||
|
.apps-dialog { |
||||
|
.el-dialog__body { |
||||
|
padding: 0; |
||||
|
} |
||||
|
} |
||||
|
.app-tabs { |
||||
|
color: #CFD0D1; |
||||
|
display: flex; |
||||
|
align-content: center; |
||||
|
.item { |
||||
|
padding: 10px 10px; |
||||
|
border-left: 1px solid #363738; |
||||
|
cursor: pointer; |
||||
|
&:hover { |
||||
|
background: #1b1c1d; |
||||
|
} |
||||
|
.el-icon-circle-close { |
||||
|
&:hover { |
||||
|
// transition: all 0.3s ease-in-out; |
||||
|
// transform: scale(1.1); |
||||
|
color: red; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.active { |
||||
|
background: #1b1c1d; |
||||
|
color: #FFF; |
||||
|
font-weight: bold; |
||||
|
// background: #333; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,58 @@ |
|||||
|
<template> |
||||
|
<div class="app-window"> |
||||
|
<iframe :src="indexUrl" ref="iframe" @load="onLoad" /> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "AppWindow", |
||||
|
components: {}, |
||||
|
props: { |
||||
|
app: Object, |
||||
|
index: Number, |
||||
|
show: Boolean, |
||||
|
}, |
||||
|
data() { |
||||
|
return {}; |
||||
|
}, |
||||
|
computed: { |
||||
|
indexUrl() { |
||||
|
return "file:///Users/kj/Code/luofei/s207-vue-app-template/dist/index.html"; |
||||
|
// return "'http://localhost:8081/index.html" |
||||
|
// return "file://" + this.app.appDir + "/index.html"; |
||||
|
}, |
||||
|
}, |
||||
|
created() {}, |
||||
|
beforeDestroy() { |
||||
|
this.postMessage("onUnload"); |
||||
|
}, |
||||
|
methods: { |
||||
|
onLoad() { |
||||
|
console.log("lllll") |
||||
|
this.postMessage("onLoad"); |
||||
|
}, |
||||
|
postMessage(name, params) { |
||||
|
this.$refs.iframe.contentWindow.postMessage({ name, params }, "*"); |
||||
|
}, |
||||
|
}, |
||||
|
watch: { |
||||
|
show() { |
||||
|
this.postMessage(this.show ? "onShow" : "onHide"); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.app-window { |
||||
|
height: 100%; |
||||
|
width: 100%; |
||||
|
iframe { |
||||
|
height: 100%; |
||||
|
width: 100%; |
||||
|
border: none; |
||||
|
background: #333; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,67 @@ |
|||||
|
<template> |
||||
|
<div class="header"> |
||||
|
<div class="left"> |
||||
|
<app-tabs /> |
||||
|
</div> |
||||
|
<h1 class="title" v-if="!$store.getters.hasOpenedApps">桌面</h1> |
||||
|
<el-dropdown v-if="session" @command="handleMenuCommand"> |
||||
|
<span class="user"> |
||||
|
<el-avatar size="small" :src="session.avatar"></el-avatar> |
||||
|
<span class="username">{{ session.username }}</span> |
||||
|
<i class="el-icon-arrow-down"></i> |
||||
|
</span> |
||||
|
<el-dropdown-menu slot="dropdown"> |
||||
|
<el-dropdown-item command="logout">退出</el-dropdown-item> |
||||
|
</el-dropdown-menu> |
||||
|
</el-dropdown> |
||||
|
<el-button v-else type="text" @click="handleLogin">登录</el-button> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import AppTabs from "./AppTabs.vue"; |
||||
|
export default { |
||||
|
name: "GlobalHeader", |
||||
|
components: { AppTabs }, |
||||
|
data() { |
||||
|
return {}; |
||||
|
}, |
||||
|
methods: { |
||||
|
handleMenuCommand(command) { |
||||
|
if (command === "logout") { |
||||
|
this.$api.logout(); |
||||
|
} |
||||
|
}, |
||||
|
handleLogin() { |
||||
|
this.$bus.$emit("showLogin"); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.header { |
||||
|
padding: 0 10px; |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
background: #151515; |
||||
|
height: 48px; |
||||
|
.title { |
||||
|
font-size: 18px; |
||||
|
} |
||||
|
.user { |
||||
|
color: #fff; |
||||
|
cursor: pointer; |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
.username { |
||||
|
margin: 0 10px; |
||||
|
} |
||||
|
} |
||||
|
.el-button--text { |
||||
|
color: #fff; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,100 @@ |
|||||
|
<template> |
||||
|
<el-dialog :visible.sync="visible" class="login-dialog"> |
||||
|
<h1 class="title">欢迎登录</h1> |
||||
|
<div class="content"> |
||||
|
<el-form> |
||||
|
<el-form-item> |
||||
|
<el-input |
||||
|
v-model="username" |
||||
|
placeholder="请输入账号 (alice)" |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-input |
||||
|
v-model="password" |
||||
|
placeholder="请输入密码 (123)" |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item style="text-align: center"> |
||||
|
<el-button type="primary" @click="handleSubmit">立即登录</el-button> |
||||
|
<br /> |
||||
|
<el-button type="text" @click="handleCancel">取消</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "LoginDialog", |
||||
|
data() { |
||||
|
return { |
||||
|
visible: false, |
||||
|
username: "", |
||||
|
password: "", |
||||
|
}; |
||||
|
}, |
||||
|
created() { |
||||
|
this.$bus.$on("showLogin", () => { |
||||
|
this.visible = true; |
||||
|
}); |
||||
|
}, |
||||
|
methods: { |
||||
|
async handleSubmit() { |
||||
|
const session = await this.$api.login({ |
||||
|
username: this.username, |
||||
|
password: this.password, |
||||
|
}); |
||||
|
if (session) { |
||||
|
this.$message({ |
||||
|
message: "登录成功", |
||||
|
type: "success", |
||||
|
}); |
||||
|
this.visible = false; |
||||
|
} else { |
||||
|
this.$message({ message: "账号或密码错误", type: "error" }); |
||||
|
} |
||||
|
}, |
||||
|
async handleCancel() { |
||||
|
this.$confirm("确定要退出登录吗?", "提示", { |
||||
|
confirmButtonText: "确定", |
||||
|
cancelButtonText: "取消", |
||||
|
type: "warning", |
||||
|
}) |
||||
|
.then(() => { |
||||
|
this.visible = false; |
||||
|
}) |
||||
|
.catch(() => {}); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
<style lang="scss"> |
||||
|
.login-dialog { |
||||
|
.el-dialog { |
||||
|
background: #0b0b0b; |
||||
|
border-radius: 6px; |
||||
|
// height: 400px; |
||||
|
border: 1px solid #666; |
||||
|
} |
||||
|
.el-dialog__body { |
||||
|
padding: 0; |
||||
|
} |
||||
|
.el-dialog__header { |
||||
|
display: none; |
||||
|
} |
||||
|
.title { |
||||
|
color: #fff; |
||||
|
padding: 20px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
.content { |
||||
|
padding: 20px 50px; |
||||
|
} |
||||
|
.content >>> .el-input__inner { |
||||
|
background-color: #2b2b2b !important; |
||||
|
color: #fff; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,45 @@ |
|||||
|
<template> |
||||
|
<div class="page"> |
||||
|
<div> |
||||
|
<input v-model="key" placeholder="请输入key" /> |
||||
|
<input v-model="value" placeholder="请输入value" /> |
||||
|
<button @click="onSet">Set</button> |
||||
|
<button @click="onGet">Get</button> |
||||
|
<button @click="onGetSession">Get Session</button> |
||||
|
<button @click="onLogin">Show Login</button> |
||||
|
<button @click="onLogout">logout</button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
key: "", |
||||
|
value: "", |
||||
|
}; |
||||
|
}, |
||||
|
methods: { |
||||
|
async onSet() { |
||||
|
await window.rpc.invoke("setStoreValue", this.key, this.value); |
||||
|
alert("操作成功"); |
||||
|
}, |
||||
|
async onGet() { |
||||
|
const v = await window.rpc.invoke("getStoreValue", this.key); |
||||
|
alert(v); |
||||
|
}, |
||||
|
async onGetSession() { |
||||
|
const session = await window.rpc.invoke("getSession"); |
||||
|
console.log({ session }); |
||||
|
}, |
||||
|
async onLogin() { |
||||
|
const user = await window.rpc.invoke("showLogin"); |
||||
|
console.log({ user }); |
||||
|
}, |
||||
|
async onLogout() { |
||||
|
window.rpc.invoke("logout"); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
@ -0,0 +1,70 @@ |
|||||
|
<template> |
||||
|
<div class="widget"> |
||||
|
<i v-if="showRemove" class="remove el-icon-remove-outline" @click="handleRemove"></i> |
||||
|
<img v-if="image" class="image" :src="image" alt="应用图标" /> |
||||
|
<template v-else> |
||||
|
<img v-if="icon" class="icon" :src="icon" alt="应用图标" /> |
||||
|
<h1 v-if="name" class="name">{{ name }}</h1> |
||||
|
<h1 v-if="!name && !icon" class="name">未知应用</h1> |
||||
|
</template> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "Widget", |
||||
|
props: { |
||||
|
showRemove: { |
||||
|
type: Boolean, |
||||
|
default: true |
||||
|
}, |
||||
|
icon: String, |
||||
|
image: String, |
||||
|
name: String, |
||||
|
}, |
||||
|
methods: { |
||||
|
handleRemove(e) { |
||||
|
e.preventDefault(); |
||||
|
e.stopPropagation(); |
||||
|
this.$emit("remove"); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style scoped lang="scss"> |
||||
|
.widget { |
||||
|
height: 100%; |
||||
|
position: relative; |
||||
|
width: 100%; |
||||
|
// width: 144px; |
||||
|
// height: 144px; |
||||
|
display: flex; |
||||
|
justify-content: center; |
||||
|
align-items: center; |
||||
|
flex-direction: column; |
||||
|
.remove { |
||||
|
position: absolute; |
||||
|
right: 2px; |
||||
|
top: 2px; |
||||
|
opacity: 0; |
||||
|
&:hover { |
||||
|
opacity: 1; |
||||
|
} |
||||
|
} |
||||
|
.image { |
||||
|
width: 100%; |
||||
|
} |
||||
|
.icon { |
||||
|
width: 55%; |
||||
|
margin-bottom: 10px; |
||||
|
} |
||||
|
.name { |
||||
|
margin: 0; |
||||
|
padding: 0; |
||||
|
text-align: center; |
||||
|
font-size: 2vw; |
||||
|
color: #ffffff; |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,13 @@ |
|||||
|
import mixins from "./mixins"; |
||||
|
|
||||
|
const install = (Vue, opts = { mixins: true }) => { |
||||
|
if (opts.mixins) { |
||||
|
Vue.mixin(mixins) |
||||
|
} |
||||
|
Vue.prototype.$api = window.api |
||||
|
}; |
||||
|
|
||||
|
export default { |
||||
|
version: '0.0.1', |
||||
|
install, |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
session: null, |
||||
|
} |
||||
|
}, |
||||
|
async created() { |
||||
|
this._sessionChangedListener = (event, newSession) => { |
||||
|
this.session = newSession |
||||
|
} |
||||
|
this.$api.on("sessionChanged", this._sessionChangedListener); |
||||
|
this.session = await this.$api.getSession() |
||||
|
}, |
||||
|
beforeDestroy() { |
||||
|
this.$api.removeListener("sessionChanged", this._sessionChangedListener) |
||||
|
} |
||||
|
} |
@ -0,0 +1,38 @@ |
|||||
|
import Vue from "vue"; |
||||
|
import App from "./App.vue"; |
||||
|
import router from "./router"; |
||||
|
import store from "./store"; |
||||
|
import Lib from "@/lib"; |
||||
|
import ElementUI from 'element-ui'; |
||||
|
import 'element-ui/lib/theme-chalk/index.css'; |
||||
|
|
||||
|
Vue.config.productionTip = false; |
||||
|
|
||||
|
if (!window.api) { |
||||
|
alert("请在客户端里运行"); |
||||
|
console.error("非客户端运行"); |
||||
|
window.api = { |
||||
|
on: () => { }, |
||||
|
invoke: () => { }, |
||||
|
removeListener: () => { }, |
||||
|
fake: true |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
Vue.use(ElementUI); |
||||
|
Vue.use(Lib); |
||||
|
|
||||
|
const EventBus = new Vue(); |
||||
|
Object.defineProperties(Vue.prototype, { |
||||
|
$bus: { |
||||
|
get: function () { |
||||
|
return EventBus |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
new Vue({ |
||||
|
router, |
||||
|
store, |
||||
|
render: h => h(App), |
||||
|
}).$mount("#app"); |
@ -0,0 +1,39 @@ |
|||||
|
import Vue from "vue"; |
||||
|
import VueRouter from "vue-router"; |
||||
|
import Home from "../views/Home.vue"; |
||||
|
|
||||
|
Vue.use(VueRouter); |
||||
|
|
||||
|
const routes = [ |
||||
|
{ |
||||
|
path: "/", |
||||
|
name: "Home", |
||||
|
component: Home |
||||
|
}, |
||||
|
{ |
||||
|
path: "/login", |
||||
|
name: "Login", |
||||
|
// route level code-splitting
|
||||
|
// this generates a separate chunk (about.[hash].js) for this route
|
||||
|
// which is lazy-loaded when the route is visited.
|
||||
|
component: () => |
||||
|
import(/* webpackChunkName: "about" */ "../views/Login.vue") |
||||
|
}, |
||||
|
{ |
||||
|
path: "/application", |
||||
|
name: "Application", |
||||
|
// route level code-splitting
|
||||
|
// this generates a separate chunk (about.[hash].js) for this route
|
||||
|
// which is lazy-loaded when the route is visited.
|
||||
|
component: () => |
||||
|
import(/* webpackChunkName: "about" */ "../views/Application.vue") |
||||
|
} |
||||
|
]; |
||||
|
|
||||
|
const router = new VueRouter({ |
||||
|
mode: "history", |
||||
|
base: process.env.BASE_URL, |
||||
|
routes |
||||
|
}); |
||||
|
|
||||
|
export default router; |
@ -0,0 +1,57 @@ |
|||||
|
import Vue from "vue"; |
||||
|
import Vuex from "vuex"; |
||||
|
|
||||
|
Vue.use(Vuex); |
||||
|
|
||||
|
export default new Vuex.Store({ |
||||
|
state: { |
||||
|
openedApps: [], |
||||
|
splitMode: false, |
||||
|
activeApp: null |
||||
|
}, |
||||
|
getters: { |
||||
|
hasOpenedApps: state => { |
||||
|
return state.openedApps.length > 0 |
||||
|
}, |
||||
|
showSplitApp: state => { |
||||
|
return state.openedApps.length >= 2 |
||||
|
}, |
||||
|
showOpenNewApp: state => { |
||||
|
return state.openedApps.length > 0 && state.openedApps.length <= 4 |
||||
|
}, |
||||
|
activeApps: state => { |
||||
|
if (state.splitMode) { |
||||
|
return state.openedApps.slice(-2) |
||||
|
} else if (state.openedApps.includes(state.activeApp)) { |
||||
|
return [state.activeApp] |
||||
|
} else { |
||||
|
return state.openedApps.slice(-1) |
||||
|
} |
||||
|
}, |
||||
|
}, |
||||
|
mutations: { |
||||
|
openApp(state, app) { |
||||
|
const found = state.openedApps.find(({ id }) => { |
||||
|
return id === app.id |
||||
|
}) |
||||
|
if (found) { |
||||
|
state.activeApp = found |
||||
|
} else { |
||||
|
state.activeApp = app |
||||
|
state.openedApps.push(app) |
||||
|
} |
||||
|
}, |
||||
|
closeApp(state, index) { |
||||
|
state.openedApps.splice(index, 1) |
||||
|
}, |
||||
|
activeApp(state, app) { |
||||
|
state.activeApp = app |
||||
|
}, |
||||
|
toggleSplit(state) { |
||||
|
state.splitMode = !state.splitMode |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
actions: {}, |
||||
|
modules: {} |
||||
|
}); |
@ -0,0 +1,89 @@ |
|||||
|
<template> |
||||
|
<div class="page"> |
||||
|
<div class="header"> |
||||
|
<el-button |
||||
|
type="text" |
||||
|
style="color: #fff" |
||||
|
icon="el-icon-s-home" |
||||
|
@click="handleBackHome" |
||||
|
>返回桌面</el-button |
||||
|
> |
||||
|
<h1 class="title">{{ title || "未知应用" }}</h1> |
||||
|
<el-dropdown v-if="session"> |
||||
|
<span class="user"> |
||||
|
<el-avatar size="small" :src="session.avatar"></el-avatar> |
||||
|
<span class="username">{{ session.username }}</span> |
||||
|
</span> |
||||
|
</el-dropdown> |
||||
|
<el-button v-else type="text" @click="handleLogin">登录</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<div class="content"> |
||||
|
<el-alert |
||||
|
:title="`【${this.title}】应用 正在开发中...`" |
||||
|
type="error" |
||||
|
center |
||||
|
show-icon |
||||
|
> |
||||
|
</el-alert> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
data() { |
||||
|
return { |
||||
|
title: "", |
||||
|
widget: null, |
||||
|
}; |
||||
|
}, |
||||
|
created() { |
||||
|
try { |
||||
|
this.widget = JSON.parse(this.$route.query.widget); |
||||
|
this.title = this.widget.name; |
||||
|
} catch (err) { |
||||
|
console.error(err); |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
handleBackHome() { |
||||
|
setTimeout(() => { |
||||
|
this.$rpc.invoke("showMainWindow"); |
||||
|
}, 0); |
||||
|
window.close(); |
||||
|
}, |
||||
|
handleLogin() { |
||||
|
this.$rpc.invoke("showLogin"); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
<style scoped lang="scss"> |
||||
|
.header { |
||||
|
padding: 0 10px; |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
background: #151515; |
||||
|
height: 48px; |
||||
|
.title { |
||||
|
font-size: 18px; |
||||
|
} |
||||
|
.user { |
||||
|
color: #fff; |
||||
|
cursor: pointer; |
||||
|
display: flex; |
||||
|
justify-content: space-between; |
||||
|
align-items: center; |
||||
|
.username { |
||||
|
margin: 0 10px; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
.content { |
||||
|
padding-top: 30vh; |
||||
|
width: 50vw; |
||||
|
margin: auto; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,89 @@ |
|||||
|
<template> |
||||
|
<div class="page"> |
||||
|
<global-header> |
||||
|
<!-- <el-button |
||||
|
slot="left" |
||||
|
type="text" |
||||
|
style="color: #fff" |
||||
|
icon="el-icon-s-home" |
||||
|
@click="handleBackHome" |
||||
|
>返回桌面</el-button |
||||
|
> --> |
||||
|
</global-header> |
||||
|
<div class="content"> |
||||
|
<api-doc /> |
||||
|
<app-list |
||||
|
v-if="!$store.getters.hasOpenedApps" |
||||
|
@clickApp="handleOpenApp" |
||||
|
/> |
||||
|
<div v-else class="opened-apps"> |
||||
|
<div |
||||
|
v-for="(app, index) in $store.state.openedApps" |
||||
|
:key="index" |
||||
|
:class="$store.getters.activeApps.includes(app) ? 'item' : 'hidden'" |
||||
|
> |
||||
|
<app-window |
||||
|
:app="app" |
||||
|
:index="index" |
||||
|
:show="$store.getters.activeApps.includes(app)" |
||||
|
/> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
import GlobalHeader from "../components/GlobalHeader.vue"; |
||||
|
import AppList from "../components/AppList.vue"; |
||||
|
import AppWindow from "../components/AppWindow.vue"; |
||||
|
import ApiDoc from "../components/ApiDoc.vue"; |
||||
|
|
||||
|
export default { |
||||
|
name: "Home", |
||||
|
components: { |
||||
|
GlobalHeader, |
||||
|
AppList, |
||||
|
AppWindow, |
||||
|
ApiDoc, |
||||
|
}, |
||||
|
data() { |
||||
|
return {}; |
||||
|
}, |
||||
|
computed: {}, |
||||
|
created() {}, |
||||
|
methods: { |
||||
|
handleOpenApp(app) { |
||||
|
this.$store.commit("openApp", app); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.page { |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
.content { |
||||
|
flex: 1; |
||||
|
display: flex; |
||||
|
flex-direction: column; |
||||
|
} |
||||
|
.opened-apps { |
||||
|
flex: 1; |
||||
|
display: flex; |
||||
|
.hidden { |
||||
|
display: none; |
||||
|
} |
||||
|
.item { |
||||
|
flex: 1; |
||||
|
border: 1px solid #5a5b5c; |
||||
|
margin: 10px; |
||||
|
margin-right: 0; |
||||
|
&:last-child { |
||||
|
margin-right: 10px; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,81 @@ |
|||||
|
<template> |
||||
|
<div class="page"> |
||||
|
<h1 class="title">欢迎登录</h1> |
||||
|
<div class="content"> |
||||
|
<el-form> |
||||
|
<el-form-item> |
||||
|
<el-input |
||||
|
v-model="username" |
||||
|
placeholder="请输入账号 (alice)" |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item> |
||||
|
<el-input |
||||
|
v-model="password" |
||||
|
placeholder="请输入密码 (123)" |
||||
|
></el-input> |
||||
|
</el-form-item> |
||||
|
<el-form-item style="text-align: center"> |
||||
|
<el-button type="primary" @click="handleSubmit">立即登录</el-button> |
||||
|
<br /> |
||||
|
<el-button type="text" @click="handleCancel">取消</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script> |
||||
|
export default { |
||||
|
name: "LoginPage", |
||||
|
data() { |
||||
|
return { |
||||
|
username: "", |
||||
|
password: "", |
||||
|
}; |
||||
|
}, |
||||
|
methods: { |
||||
|
async handleSubmit() { |
||||
|
const session = await window.rpc.invoke("login", { |
||||
|
username: this.username, |
||||
|
password: this.password, |
||||
|
}); |
||||
|
if (session) { |
||||
|
this.$message({ |
||||
|
message: "登录成功", |
||||
|
type: "success", |
||||
|
}); |
||||
|
setTimeout(() => { |
||||
|
window.close(); |
||||
|
}, 1000); |
||||
|
} else { |
||||
|
this.$message({ message: "账号或密码错误", type: "error" }); |
||||
|
} |
||||
|
}, |
||||
|
async handleCancel() { |
||||
|
this.$confirm("确定要退出登录吗?", "提示", { |
||||
|
confirmButtonText: "确定", |
||||
|
cancelButtonText: "取消", |
||||
|
type: "warning", |
||||
|
}) |
||||
|
.then(() => { |
||||
|
window.close(); |
||||
|
}) |
||||
|
.catch(() => {}); |
||||
|
}, |
||||
|
}, |
||||
|
}; |
||||
|
</script> |
||||
|
<style scoped> |
||||
|
.title { |
||||
|
padding: 20px; |
||||
|
text-align: center; |
||||
|
} |
||||
|
.content { |
||||
|
padding: 20px 50px; |
||||
|
} |
||||
|
.content >>> .el-input__inner { |
||||
|
background-color: #2b2b2b !important; |
||||
|
color: #fff; |
||||
|
} |
||||
|
</style> |
@ -0,0 +1,6 @@ |
|||||
|
module.exports = { |
||||
|
publicPath: './', |
||||
|
configureWebpack: { |
||||
|
// target: "electron-renderer"
|
||||
|
}, |
||||
|
} |
9009
app/renderer/src/main/yarn.lock
File diff suppressed because it is too large
View File
After Width: 1920 | Height: 1080 | Size: 208 KiB |
After Width: 512 | Height: 320 | Size: 107 KiB |
@ -0,0 +1,10 @@ |
|||||
|
{ |
||||
|
"production": { |
||||
|
"url": "http://localhost:3806/TIS_PLATFORM/", |
||||
|
"showMulWin":"false" |
||||
|
}, |
||||
|
"development": { |
||||
|
"url": "http://10.12.19.188:8080", |
||||
|
"showMulWin":"false" |
||||
|
} |
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
{"test":{"a":1},"test2":{"name":"hallo"},"position":{"x":1790,"y":327}} |
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"development": { |
||||
|
"getModelDataUrl":"http://10.12.19.203:3886/api/tisframework/msgtool/get_msg", |
||||
|
"getModelPutUrl" : "http://10.12.19.203:3886/api/tisframework/msgtool/update_msg", |
||||
|
"ws" : "10.12.19.203", |
||||
|
"getModelDataSet": "http://10.12.19.203:3886/api/tisframework/msgtool/get_set_msg", |
||||
|
"getModelPutSet" : "http://10.12.19.203:3886/api/tisframework/msgtool/update_set_msg" |
||||
|
}, |
||||
|
"production": { |
||||
|
"getModelDataUrl":"http://localhost:3806/api/tisframework/msgtool/get_msg", |
||||
|
"getModelPutUrl" : "http://localhost:3806/api/tisframework/msgtool/update_msg", |
||||
|
"ws" : "localhost", |
||||
|
"getModelDataSet": "http://localhost:3806/api/tisframework/msgtool/get_set_msg", |
||||
|
"getModelPutSet" : "http://localhost:3806/api/tisframework/msgtool/update_set_msg" |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
/** |
||||
|
* Created by sunjiangang 2019/10/9 |
||||
|
*/ |
||||
|
// import Axios from 'axios'
|
||||
|
// import Url from 'url.js'
|
||||
|
const Axios = require('axios') |
||||
|
const URL = require('url') |
||||
|
|
||||
|
let axios = Axios.create({ |
||||
|
timeout:500 |
||||
|
} |
||||
|
) |
||||
|
// function getModelData() {
|
||||
|
// return new Promise((resolve,reject) => {
|
||||
|
// axios.get(Url.getModelDataUrl).then( res =>{
|
||||
|
// console.log("返回数据",res.data)
|
||||
|
// resolve(res.data)
|
||||
|
// }).catch( error =>{
|
||||
|
// reject(error)
|
||||
|
// })
|
||||
|
// })
|
||||
|
// }
|
9
js/axios.min.js
File diff suppressed because it is too large
View File
@ -0,0 +1,85 @@ |
|||||
|
// alert("33333")
|
||||
|
const ipc= require('electron').ipcRenderer; |
||||
|
|
||||
|
setInterval(function(){ |
||||
|
|
||||
|
let item =document.querySelectorAll(".system-set-base.set-ul>li") |
||||
|
if (item && item.length>0 &&item[1]!=null){ |
||||
|
item[1].onclick = ()=>{ |
||||
|
console.log("点击最小化") |
||||
|
ipc.send('window-min') |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
let itemButton =document.querySelectorAll(".login-main footer>button") |
||||
|
if (itemButton && itemButton.length>0 && itemButton!=null) { |
||||
|
itemButton[1].onclick = ()=>{ |
||||
|
console.log("点击关闭") |
||||
|
ipc.send('window-close') |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
},500) |
||||
|
|
||||
|
ipc.on('clickButton',(event,args)=>{ |
||||
|
console.log("msg:",args) |
||||
|
// document.querySelector('webview').openDevTools()
|
||||
|
let item =document.querySelectorAll(".system-set-base.set-ul>li") |
||||
|
console.log(item,"@@@",document.querySelectorAll(".system-set-base.set-ul>li")) |
||||
|
if (item && item.length>0 &&item[5]!=null){ |
||||
|
item[5].click(); |
||||
|
console.log("点击关闭") |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
|
||||
|
|
||||
|
let memHeap = [], cpuHeap = [] |
||||
|
setInterval(function () { |
||||
|
let echart = document.querySelector("#echartCpu") |
||||
|
if (echart!=null){ |
||||
|
let promise = new Promise(function (resolve, reject) { |
||||
|
resolve(process.getProcessMemoryInfo()); |
||||
|
}); |
||||
|
promise.then(function (data) { |
||||
|
console.log('resolved.', data); |
||||
|
if (data!=null){ |
||||
|
if (memHeap.length>=20 ){ |
||||
|
memHeap.shift() |
||||
|
} |
||||
|
let temp = (data.residentSet/1024).toFixed(2) |
||||
|
memHeap.push(temp) |
||||
|
console.log("2222",memHeap) |
||||
|
} else { |
||||
|
if (memHeap.length>=20 ){ |
||||
|
memHeap.shift() |
||||
|
} |
||||
|
memHeap.push(0) |
||||
|
} |
||||
|
|
||||
|
}); |
||||
|
let cpuCost = process.getCPUUsage() |
||||
|
console.log( cpuCost) |
||||
|
let cpuUsage = (cpuCost.percentCPUUsage.toFixed(2)) |
||||
|
if (cpuHeap.length>=20 ){ |
||||
|
cpuHeap.shift() |
||||
|
} |
||||
|
console.log("cpuUsage",cpuUsage) |
||||
|
cpuHeap.push(cpuUsage) |
||||
|
console.log("1111",cpuHeap,cpuUsage) |
||||
|
esapp.vue.$store.commit("desktop/SET_RESOURCE_DATA",{"mem":[...memHeap], "cpu": [...cpuHeap]}) |
||||
|
console.log(esapp.vue.$store.state.desktop.resourceData) |
||||
|
console.log( cpuCost, process.getSystemMemoryInfo(), process.getHeapStatistics()) |
||||
|
} |
||||
|
if (echart == null) { |
||||
|
esapp.vue.$store.commit("desktop/SET_RESOURCE_DATA",{"mem":[], "cpu": []}) |
||||
|
if (memHeap.length>0){ |
||||
|
memHeap =[] |
||||
|
} |
||||
|
if (cpuHeap.length>0){ |
||||
|
cpuHeap=[] |
||||
|
} |
||||
|
} |
||||
|
}, 5000) |
||||
|
|