feat: electron support

This commit is contained in:
Netfan
2025-03-24 23:51:31 +08:00
parent 329a176a5c
commit 7536be5e49
22 changed files with 1945 additions and 11 deletions

View File

@@ -98,6 +98,8 @@
"@types/lodash.get": "catalog:",
"@types/lodash.isequal": "catalog:",
"@types/lodash.set": "catalog:",
"@types/nprogress": "catalog:"
"@types/nprogress": "catalog:",
"@vben-core/typings": "workspace:*",
"electron": "catalog:"
}
}

View File

@@ -28,10 +28,11 @@ function openWindow(url: string, options: OpenWindowOptions = {}): void {
* @param path
*/
function openRouteInNewWindow(path: string) {
const { hash, origin } = location;
// const { hash, origin } = location;
const fullPath = path.startsWith('/') ? path : `/${path}`;
const url = `${origin}${hash ? '/#' : ''}${fullPath}`;
openWindow(url, { target: '_blank' });
// const url = `${origin}${hash ? '/#' : ''}${fullPath}`;
// openWindow(url, { target: '_blank' });
window.ipcRenderer.invoke('open-win', fullPath);
}
export { openRouteInNewWindow, openWindow };

View File

@@ -1,6 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@vben/tsconfig/library.json",
"compilerOptions": {
"types": ["@vben-core/typings/electron"]
},
"include": ["src"],
"exclude": ["node_modules"]
}

View File

@@ -0,0 +1,22 @@
import type { IpcRendererEvent } from 'electron';
export type IpcRendererInvoke = 'open-win';
declare global {
interface Window {
ipcRenderer: {
invoke: (channel: IpcRendererInvoke, ...args: any[]) => Promise<any>;
off: (
channel: string,
listener: (event: IpcRendererEvent, ...args: any[]) => void,
) => void;
on: (
channel: string,
listener: (event: IpcRendererEvent, ...args: any[]) => void,
) => void;
send: (channel: string, data: any) => Promise<any>;
};
}
}
export {};

View File

@@ -27,6 +27,9 @@
},
"./vue-router": {
"types": "./vue-router.d.ts"
},
"./electron": {
"types": "./electron.d.ts"
}
},
"publishConfig": {