升级electron egg脚手架版本

This commit is contained in:
2025-10-15 14:12:24 +08:00
parent ca8f173394
commit 081a77ac4c
54 changed files with 1756 additions and 1077 deletions

View File

@@ -6,7 +6,6 @@
</template>
<script lang="ts" setup>
import autofit from 'autofit.js'
import { useI18n } from 'vue-i18n'
import { getBrowserLang } from '@/utils'
import { useTheme } from '@/hooks/useTheme'
@@ -32,16 +31,14 @@ onMounted(() => {
const language = globalStore.language ?? getBrowserLang()
i18n.locale.value = language
globalStore.setGlobalState('language', language as LanguageType)
// 自动适配
autofit.init({
el: '#app',
//dh: 720 * 1,
//dw: 1280 * 1.2,
dw: 1920 / 1.5,
dh: 1080 / 1.2,
resize: true,
limit: 0.1
})
// 移除 autofit使用 CSS 自适应
// autofit.init({
// el: '#app',
// dw: 1440,
// dh: 900,
// resize: true,
// limit: 0.1
// })
})
// element language
@@ -59,4 +56,10 @@ const buttonConfig = reactive({ autoInsertSpace: false })
document.getElementById('loadingPage')?.remove()
</script>
<style scoped></style>
<style scoped>
#app {
width: 100vw;
height: 100vh;
overflow: hidden;
}
</style>

View File

@@ -1,17 +1,23 @@
export const dialogSmall = {
width:'500px',
width:'26vw',
maxWidth:'500px',
minWidth:'300px',
closeOnClickModal:false,
draggable:true,
class:'dialog-small'
}
export const dialogMiddle = {
width:'800px',
width:'42vw',
maxWidth:'800px',
minWidth:'600px',
closeOnClickModal:false,
draggable:true,
class:'dialog-middle'
}
export const dialogBig = {
width:'1200px',
width:'62vw',
maxWidth:'1200px',
minWidth:'800px',
closeOnClickModal:false,
draggable:true,
class:'dialog-big',

View File

@@ -1,39 +0,0 @@
declare global {
interface Window {
electron?: any;
}
}
const Renderer = (window.require && window.require('electron')) || window.electron || {};
/**
* ipc
* 官方api说明https://www.electronjs.org/zh/docs/latest/api/ipc-renderer
*
* 属性/方法
* ipc.invoke(channel, param) - 发送异步消息invoke/handle 模型)
* ipc.sendSync(channel, param) - 发送同步消息send/on 模型)
* ipc.on(channel, listener) - 监听 channel, 当新消息到达,调用 listener
* ipc.once(channel, listener) - 添加一次性 listener 函数
* ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者
* ipc.removeAllListeners(channel) - 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
* ipc.send(channel, ...args) - 通过channel向主进程发送异步消息
* ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程
* ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口
* ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 <webview> 元素
*/
/**
* ipc
*/
const ipc = Renderer.ipcRenderer || undefined;
/**
* 是否为EE环境
*/
const isEE = ipc ? true : false;
export {
Renderer, ipc, isEE
};

View File

@@ -0,0 +1,119 @@
/**
* Electron IPC Renderer 类型定义
*/
interface IpcRenderer {
/**
* 发送异步消息invoke/handle 模型)
* @param channel 通道名称
* @param param 传递的参数
* @returns Promise<T> 返回结果
*/
invoke<T = any>(channel: string, param?: any): Promise<T>;
/**
* 发送同步消息send/on 模型)
* @param channel 通道名称
* @param param 传递的参数
* @returns 返回结果
*/
sendSync(channel: string, param?: any): any;
/**
* 监听 channel当新消息到达调用 listener
* @param channel 通道名称
* @param listener 监听器函数
*/
on(channel: string, listener: (event: any, ...args: any[]) => void): void;
/**
* 添加一次性 listener 函数
* @param channel 通道名称
* @param listener 监听器函数
*/
once(channel: string, listener: (event: any, ...args: any[]) => void): void;
/**
* 为特定的 channel 从监听队列中删除特定的 listener 监听者
* @param channel 通道名称
* @param listener 要移除的监听器函数
*/
removeListener(channel: string, listener: (event: any, ...args: any[]) => void): void;
/**
* 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
* @param channel 通道名称(可选)
*/
removeAllListeners(channel?: string): void;
/**
* 通过 channel 向主进程发送异步消息
* @param channel 通道名称
* @param args 传递的参数
*/
send(channel: string, ...args: any[]): void;
/**
* 发送消息到主进程
* @param channel 通道名称
* @param message 消息内容
* @param transfer 传输对象(可选)
*/
postMessage(channel: string, message: any, transfer?: MessagePort[]): void;
/**
* 通过 channel 发送消息到带有 webContentsId 的窗口
* @param webContentsId 目标窗口的 ID
* @param channel 通道名称
* @param args 传递的参数
*/
sendTo(webContentsId: number, channel: string, ...args: any[]): void;
/**
* 消息会被发送到 host 页面上的 <webview> 元素
* @param channel 通道名称
* @param args 传递的参数
*/
sendToHost(channel: string, ...args: any[]): void;
}
interface Electron {
ipcRenderer?: IpcRenderer;
}
const Renderer = (window.require && window.require('electron')) || (window as any).electron || {};
/**
* ipc
* 官方api说明https://www.electronjs.org/zh/docs/latest/api/ipc-renderer
*
* 属性/方法
* ipc.invoke(channel, param) - 发送异步消息invoke/handle 模型)
* ipc.sendSync(channel, param) - 发送同步消息send/on 模型)
* ipc.on(channel, listener) - 监听 channel, 当新消息到达,调用 listener
* ipc.once(channel, listener) - 添加一次性 listener 函数
* ipc.removeListener(channel, listener) - 为特定的 channel 从监听队列中删除特定的 listener 监听者
* ipc.removeAllListeners(channel) - 移除所有的监听器,当指定 channel 时只移除与其相关的所有监听器
* ipc.send(channel, ...args) - 通过channel向主进程发送异步消息
* ipc.postMessage(channel, message, [transfer]) - 发送消息到主进程
* ipc.sendTo(webContentsId, channel, ...args) - 通过 channel 发送消息到带有 webContentsId 的窗口
* ipc.sendToHost(channel, ...args) - 消息会被发送到 host 页面上的 <webview> 元素
*/
/**
* ipc
*/
const ipc: IpcRenderer | undefined = Renderer.ipcRenderer;
/**
* 是否为EE环境
*/
const isEE: boolean = ipc ? true : false;
export {
type IpcRenderer,
type Electron,
Renderer,
ipc,
isEE
};

View File

@@ -1,7 +1,8 @@
<template>
<el-dialog
:title="dialogTitle"
width="1550px"
width="90vw"
:style="{ maxWidth: '1550px', minWidth: '800px' }"
:model-value="dialogVisible"
:before-close="beforeClose"
@close="handleClose"