@talex-touch/utils 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin/channel.ts +1 -1
- package/plugin/sdk/common.ts +1 -13
- package/plugin/sdk/window/index.ts +40 -0
package/package.json
CHANGED
package/plugin/channel.ts
CHANGED
package/plugin/sdk/common.ts
CHANGED
|
@@ -15,16 +15,4 @@ export function regShortcut(key: string, func: Function) {
|
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
19
|
-
const res = genChannel().sendSync('window:new', options)
|
|
20
|
-
if ( res.error ) throw new Error(res.error)
|
|
21
|
-
|
|
22
|
-
return res.id
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function toggleWinVisible(id: number, visible?: boolean): boolean {
|
|
26
|
-
const res = genChannel().sendSync('window:visible', visible !== undefined ? { id, visible } : { id })
|
|
27
|
-
if ( res.error ) throw new Error(res.error)
|
|
28
|
-
|
|
29
|
-
return res.visible
|
|
30
|
-
}
|
|
18
|
+
export * from './window';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { genChannel } from '../../channel';
|
|
2
|
+
import {
|
|
3
|
+
BrowserWindowConstructorOptions, BrowserWindow, WebContents
|
|
4
|
+
} from "electron";
|
|
5
|
+
|
|
6
|
+
export function createWindow(options: BrowserWindowConstructorOptions & { file?: string } & { url?: string }): number {
|
|
7
|
+
const res = genChannel().sendSync('window:new', options)
|
|
8
|
+
if (res.error) throw new Error(res.error)
|
|
9
|
+
|
|
10
|
+
return res.id
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function toggleWinVisible(id: number, visible?: boolean): boolean {
|
|
14
|
+
const res = genChannel().sendSync('window:visible', visible !== undefined ? { id, visible } : { id })
|
|
15
|
+
if (res.error) throw new Error(res.error)
|
|
16
|
+
|
|
17
|
+
return res.visible
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function setWindowProperty<K extends keyof BrowserWindow, V>(id: number, property: {
|
|
21
|
+
|
|
22
|
+
}): boolean {
|
|
23
|
+
const res = genChannel().sendSync('window:property', { id, property })
|
|
24
|
+
if (res.error) throw new Error(res.error)
|
|
25
|
+
|
|
26
|
+
return res.success
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type WindowProperty = {
|
|
30
|
+
[P in keyof BrowserWindow]?: BrowserWindow[P]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type WebContentsProperty = {
|
|
34
|
+
[P in keyof WebContents]?: WebContents[P]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface WindowProperties {
|
|
38
|
+
window?: WindowProperty
|
|
39
|
+
webContents?: WebContentsProperty
|
|
40
|
+
}
|