perf: 🚀 采用新的方法实现所有进程共享 isPackaged

This commit is contained in:
viarotel 2023-10-18 11:34:40 +08:00
parent 4f9cb3002a
commit 8a5f7d9f37
6 changed files with 26 additions and 10 deletions

View File

@ -48,6 +48,16 @@
请参阅 [scrcpy/doc/shortcuts](https://github.com/Genymobile/scrcpy/blob/master/doc/shortcuts.md)
## 设备交互操作栏
- 切换键
- 主屏幕键
- 返回键
- 菜单键
- 电源键
- 截取屏幕
- 安装应用
## 高级配置
> 持续完善中 目前支持 Scrcpy 中以下常用配置
@ -159,7 +169,7 @@
## 支持项目
> 如果该项目帮到你的话,可以请我喝杯咖啡,让我更有精神完善该项目😛
> 如果该项目帮到你的话,可以请我喝杯咖啡,让我更有精神完善该项目 😛
> 注意:非 BUG 或计划外的需求,有偿处理;至于金额,根据问题难易程度,你觉得帮助了多少,看着给吧(维护这些项目已经耗费了大量精力,还要免费花时间解答问题就说不过去了吧...所以白嫖的一律不通过。)

View File

@ -9,4 +9,5 @@ export const icoLogoPath = buildResolve('logo.ico')
export const icnsLogoPath = buildResolve('logo.icns')
export const adbPath = extraResolve('core/adb.exe')
export const scrcpyPath = extraResolve('core/scrcpy.exe')

View File

@ -1,12 +1,13 @@
import { resolve } from 'node:path'
import { contextBridge } from 'electron'
export const isPackaged = !process.env.VITE_DEV_SERVER_URL
export const isPackaged = process.env.IS_PACKAGED === 'true'
export const extraResolve = value =>
isPackaged
export const extraResolve = (value) => {
return isPackaged
? resolve(process.resourcesPath, `extra/${value}`)
: resolve(`electron/resources/extra/${value}`)
}
export const buildResolve = value =>
resolve(`electron/resources/build/${value}`)

View File

@ -0,0 +1,6 @@
/** 在主进程中获取项目打包状态并将该值存储到环境变量中,从而在预加载脚本中及渲染进程中使用 */
/** 注意: app.isPackaged 可能被被某些方法改变所以请将该文件放到 main.js 必须位于非依赖项的顶部 */
import { app } from 'electron'
process.env.IS_PACKAGED = JSON.stringify(app.isPackaged)

View File

@ -2,11 +2,10 @@ import path from 'node:path'
import { BrowserWindow, app, shell } from 'electron'
import { electronApp, optimizer } from '@electron-toolkit/utils'
import {
icnsLogoPath,
icoLogoPath,
logoPath,
} from '@electron/configs/index.js'
// packaged.js 必须位于非依赖项的顶部
import './helpers/packaged.js'
import { icnsLogoPath, icoLogoPath, logoPath } from './configs/index.js'
import events from './events/index.js'

View File

@ -28,7 +28,6 @@ export default {
},
},
render() {
console.log('this', this)
if (this.SvgComponent) {
const props = this.SvgComponent.props
return {