Compare commits

...

3 Commits

Author SHA1 Message Date
朱浩 3ad5871505 Merge pull request 'zhuhao_dev' (#77) from zhuhao_dev into main
Reviewed-on: #77
2024-07-26 17:36:49 +08:00
朱浩 71aff5d1f8 Merge branch 'main' into zhuhao_dev 2024-07-26 17:36:16 +08:00
朱浩 14428f2706 二期:BUG修复 2024-07-26 17:36:04 +08:00
2 changed files with 12 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "electron-app", "name": "electron-app",
"version": "1.0.0", "version": "1.0.1",
"description": "An Electron application with Vue", "description": "An Electron application with Vue",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "example.com", "author": "example.com",
@ -22,6 +22,7 @@
"@electron-toolkit/preload": "^3.0.1", "@electron-toolkit/preload": "^3.0.1",
"@electron-toolkit/utils": "^3.0.0", "@electron-toolkit/utils": "^3.0.0",
"@element-plus/icons-vue": "^2.3.1", "@element-plus/icons-vue": "^2.3.1",
"@electron/remote": "^2.1.2",
"@vitejs/plugin-vue-jsx": "^4.0.0", "@vitejs/plugin-vue-jsx": "^4.0.0",
"@vueuse/core": "^10.11.0", "@vueuse/core": "^10.11.0",
"crypto-js": "^4.2.0", "crypto-js": "^4.2.0",
@ -44,7 +45,6 @@
}, },
"devDependencies": { "devDependencies": {
"@electron-toolkit/eslint-config": "^1.0.2", "@electron-toolkit/eslint-config": "^1.0.2",
"@electron/remote": "^2.1.2",
"@rushstack/eslint-patch": "^1.10.3", "@rushstack/eslint-patch": "^1.10.3",
"@vitejs/plugin-vue": "^5.0.5", "@vitejs/plugin-vue": "^5.0.5",
"@vue/eslint-config-prettier": "^9.0.0", "@vue/eslint-config-prettier": "^9.0.0",

View File

@ -1,11 +1,11 @@
/** /**
* @description: electron 封装的工具函数 * @description: electron 封装的工具函数
*/ */
// const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
// import { ipcRenderer } from 'electron' // 渲染器里面可以使用ipcRenderer // import { ipcRenderer } from 'electron' // 渲染器里面可以使用ipcRenderer
// const path = require('path') const path = require('path')
const Remote = require('@electron/remote') const Remote = require('@electron/remote')
// 常用变量 // 常用变量
@ -97,7 +97,7 @@ export function toolWindow({url, isFile, isConsole, option={}}) {
let height = option?.height || 600 let height = option?.height || 600
const mainWin = Remote.getCurrentWindow() // 获取主窗口对象 const mainWin = Remote.getCurrentWindow() // 获取主窗口对象
const devUrl = `${BaseUrl}${url}` const devUrl = `${BaseUrl}${url}`
const buildUrl = `file://${__dirname}/index.html${url}` const buildUrl = path.join(__dirname, 'index.html#')
const urlAll = isDev ? devUrl : buildUrl const urlAll = isDev ? devUrl : buildUrl
return new Promise((resolve) => { return new Promise((resolve) => {
const config = { const config = {
@ -113,8 +113,9 @@ export function toolWindow({url, isFile, isConsole, option={}}) {
} }
// 创建-新窗口 // 创建-新窗口
let win = new Remote.BrowserWindow(config) let win = new Remote.BrowserWindow(config)
if (!!isFile) win.loadFile(urlAll) // 加载文件 console.log(urlAll)
else win.loadURL(urlAll) // 加载url if (!!isFile) win.loadFile(urlAll+url) // 加载文件
else win.loadURL(urlAll,{hash: url}) // 加载url
win.once('ready-to-show', () => {resolve(win)}) win.once('ready-to-show', () => {resolve(win)})
// 主窗口关闭事件 // 主窗口关闭事件
mainWin.once('closed', () => { win.destroy()}) mainWin.once('closed', () => { win.destroy()})