@widget-js/core 24.1.1-beta.87 → 24.1.1-beta.88
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/dist/index.cjs +75 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +707 -684
- package/dist/index.d.ts +707 -684
- package/dist/index.js +75 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -92,6 +92,8 @@ interface ThemeColors {
|
|
|
92
92
|
border: string;
|
|
93
93
|
input: string;
|
|
94
94
|
ring: string;
|
|
95
|
+
shadow: string;
|
|
96
|
+
innerShadow: string;
|
|
95
97
|
}
|
|
96
98
|
interface ThemeRadius {
|
|
97
99
|
sm: string;
|
|
@@ -104,9 +106,14 @@ interface ThemeTypography {
|
|
|
104
106
|
fontSize: string;
|
|
105
107
|
}
|
|
106
108
|
interface ThemeShadow {
|
|
107
|
-
sm:
|
|
108
|
-
md:
|
|
109
|
-
lg:
|
|
109
|
+
sm: ThemeBoxShadow;
|
|
110
|
+
md: ThemeBoxShadow;
|
|
111
|
+
lg: ThemeBoxShadow;
|
|
112
|
+
}
|
|
113
|
+
interface ThemeBoxShadow {
|
|
114
|
+
offsetX: string;
|
|
115
|
+
offsetY: string;
|
|
116
|
+
blur: string;
|
|
110
117
|
}
|
|
111
118
|
interface IAppTheme {
|
|
112
119
|
useGlobalTheme?: boolean;
|
|
@@ -252,6 +259,31 @@ declare class AppConfig {
|
|
|
252
259
|
static readonly LAUNCH_AT_STARTUP = "CONFIG_LAUNCH_AT_STARTUP";
|
|
253
260
|
}
|
|
254
261
|
|
|
262
|
+
interface AiConfig {
|
|
263
|
+
id: string;
|
|
264
|
+
model: string;
|
|
265
|
+
apiKey: string;
|
|
266
|
+
apiBaseUrl: string;
|
|
267
|
+
}
|
|
268
|
+
interface IAiApi {
|
|
269
|
+
addConfig: (config: AiConfig) => Promise<AiConfig>;
|
|
270
|
+
deleteConfig: (id: string) => Promise<void>;
|
|
271
|
+
updateConfig: (config: AiConfig) => Promise<void>;
|
|
272
|
+
getConfigList: () => Promise<AiConfig[]>;
|
|
273
|
+
setConfigList: (configs: AiConfig[]) => Promise<void>;
|
|
274
|
+
getConfig: (id: string) => Promise<AiConfig | undefined>;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* AiApiEvent
|
|
278
|
+
*/
|
|
279
|
+
declare enum AiApiEvent {
|
|
280
|
+
/**
|
|
281
|
+
* 配置更新事件
|
|
282
|
+
*/
|
|
283
|
+
CONFIG_UPDATED = "channel::cn.widgetjs.core.ai.config.updated"
|
|
284
|
+
}
|
|
285
|
+
type AiApiMethods = keyof IAiApi;
|
|
286
|
+
|
|
255
287
|
interface Language {
|
|
256
288
|
baseName: string;
|
|
257
289
|
language: string;
|
|
@@ -768,173 +800,492 @@ declare enum AppApiConstants {
|
|
|
768
800
|
CONFIG_LANGUAGE = "cn.widgetjs.config.app.language"
|
|
769
801
|
}
|
|
770
802
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
803
|
+
type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
|
|
804
|
+
|
|
805
|
+
interface MetaInfo {
|
|
806
|
+
[key: string]: string | number | boolean;
|
|
807
|
+
}
|
|
808
|
+
interface IWindowSize {
|
|
809
|
+
width: number;
|
|
810
|
+
height: number;
|
|
811
|
+
maxWidth?: number;
|
|
812
|
+
maxHeight?: number;
|
|
813
|
+
minWidth?: number;
|
|
814
|
+
minHeight?: number;
|
|
815
|
+
}
|
|
816
|
+
interface IPageOptions extends IWindowSize {
|
|
817
|
+
name: string;
|
|
780
818
|
/**
|
|
781
|
-
*
|
|
819
|
+
* 当showInSearch为true时,此项必填
|
|
782
820
|
*/
|
|
783
|
-
|
|
784
|
-
}
|
|
785
|
-
type DialogApiMethods = keyof IDialogApi;
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* WidgetPackageApi 提供了组件包的升级、获取、安装等功能
|
|
789
|
-
*/
|
|
790
|
-
interface IWidgetPackageApi {
|
|
821
|
+
title: LanguageTextMap;
|
|
791
822
|
/**
|
|
792
|
-
*
|
|
793
|
-
* @param packageName 组件包名称
|
|
794
|
-
* @param remoteUrlInfo
|
|
823
|
+
* 当showInSearch为true时,此项必填
|
|
795
824
|
*/
|
|
796
|
-
|
|
825
|
+
description?: LanguageTextMap;
|
|
797
826
|
/**
|
|
798
|
-
*
|
|
799
|
-
* @param packageName
|
|
827
|
+
* 当showInSearch为true时,此项必填
|
|
800
828
|
*/
|
|
801
|
-
|
|
829
|
+
keywords?: WidgetKeyword[];
|
|
830
|
+
lang: LanguageCode;
|
|
831
|
+
packageName?: string;
|
|
832
|
+
icon?: string;
|
|
802
833
|
/**
|
|
803
|
-
*
|
|
804
|
-
* @param packageName
|
|
834
|
+
* 当showInSearch为true时,此项必填
|
|
805
835
|
*/
|
|
806
|
-
|
|
836
|
+
previewImage?: string;
|
|
807
837
|
/**
|
|
808
|
-
*
|
|
809
|
-
* @param name
|
|
838
|
+
* 是否在搜索中显示
|
|
810
839
|
*/
|
|
811
|
-
|
|
840
|
+
showInSearch?: boolean;
|
|
812
841
|
/**
|
|
813
|
-
*
|
|
842
|
+
* 悬浮窗模式 是否可移动
|
|
843
|
+
* @deprecated
|
|
814
844
|
*/
|
|
815
|
-
|
|
845
|
+
movable?: boolean;
|
|
816
846
|
/**
|
|
817
|
-
*
|
|
818
|
-
* @param widgetPackage
|
|
847
|
+
* @deprecated
|
|
819
848
|
*/
|
|
820
|
-
|
|
849
|
+
resizable?: boolean;
|
|
821
850
|
/**
|
|
822
|
-
*
|
|
823
|
-
* @param packageName
|
|
824
|
-
* @param clearData Whether to clear the data of the widget package, default is false.
|
|
851
|
+
* @deprecated
|
|
825
852
|
*/
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
type WidgetPackageApiMethods = keyof IWidgetPackageApi;
|
|
829
|
-
/**
|
|
830
|
-
* WidgetPackageApiEvent
|
|
831
|
-
*/
|
|
832
|
-
declare enum WidgetPackageApiEvent {
|
|
853
|
+
backgroundThrottling?: boolean;
|
|
854
|
+
security?: boolean;
|
|
833
855
|
/**
|
|
834
|
-
*
|
|
856
|
+
* @deprecated
|
|
835
857
|
*/
|
|
836
|
-
|
|
858
|
+
webviewTag?: boolean;
|
|
859
|
+
path: string;
|
|
837
860
|
/**
|
|
838
|
-
*
|
|
861
|
+
* 是否只能添加一次
|
|
839
862
|
*/
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
* LogApi提供了日志输出的方法,日志会保存在用户的`当前用户名/文档/桌面组件/logs/日期/组件包名.log`文件中
|
|
845
|
-
*/
|
|
846
|
-
interface ILogApi {
|
|
847
|
-
info: (...data: any[]) => void;
|
|
848
|
-
error: (...data: any[]) => void;
|
|
849
|
-
warn: (...data: any[]) => void;
|
|
850
|
-
log: (...data: any[]) => void;
|
|
851
|
-
json: (data: any) => void;
|
|
863
|
+
singleton?: boolean;
|
|
864
|
+
permissions?: WidgetPermission[];
|
|
865
|
+
meta?: MetaInfo;
|
|
866
|
+
broadcastChannels?: string[];
|
|
852
867
|
}
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
/**
|
|
856
|
-
* ProcessApi 提供进程信息获取功能
|
|
857
|
-
*/
|
|
858
|
-
interface IProcessApi {
|
|
859
|
-
getBlinkMemoryInfo: () => Promise<Electron.BlinkMemoryInfo>;
|
|
860
|
-
getHeapStatistics: () => Promise<Electron.HeapStatistics>;
|
|
868
|
+
interface IPage {
|
|
869
|
+
readonly name: string;
|
|
861
870
|
/**
|
|
862
|
-
*
|
|
863
|
-
*
|
|
871
|
+
* 窗口标题,显示在界面上的,
|
|
872
|
+
* https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
864
873
|
*/
|
|
865
|
-
|
|
874
|
+
readonly title: LanguageTextMap;
|
|
875
|
+
readonly permissions: WidgetPermission[];
|
|
876
|
+
readonly webviewTag: boolean;
|
|
866
877
|
/**
|
|
867
|
-
*
|
|
878
|
+
* 窗口介绍
|
|
868
879
|
*/
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
type ProcessApiMethods = keyof IProcessApi;
|
|
872
|
-
|
|
873
|
-
/**
|
|
874
|
-
* MouseApi
|
|
875
|
-
*/
|
|
876
|
-
interface IMouseApi {
|
|
880
|
+
readonly description: LanguageTextMap;
|
|
881
|
+
readonly keywords: WidgetKeyword[];
|
|
877
882
|
/**
|
|
878
|
-
*
|
|
879
|
-
* @param rect
|
|
883
|
+
* 组件默认语言
|
|
880
884
|
*/
|
|
881
|
-
|
|
885
|
+
readonly lang: LanguageCode;
|
|
886
|
+
readonly width: number;
|
|
887
|
+
packageName?: string | null;
|
|
888
|
+
readonly height: number;
|
|
889
|
+
readonly maxWidth: number;
|
|
890
|
+
readonly maxHeight: number;
|
|
891
|
+
readonly minWidth: number;
|
|
892
|
+
readonly minHeight: number;
|
|
893
|
+
readonly movable: boolean;
|
|
894
|
+
readonly singleton: boolean;
|
|
895
|
+
readonly resizable: boolean;
|
|
896
|
+
readonly path: string;
|
|
897
|
+
readonly meta: {
|
|
898
|
+
[key: string]: string | number | boolean;
|
|
899
|
+
};
|
|
900
|
+
readonly backgroundThrottling: boolean;
|
|
882
901
|
/**
|
|
883
|
-
*
|
|
902
|
+
* 预览图片,可以是GIF
|
|
884
903
|
*/
|
|
885
|
-
|
|
904
|
+
readonly previewImage?: string;
|
|
886
905
|
}
|
|
887
|
-
|
|
888
|
-
* SystemApiEvent
|
|
889
|
-
*/
|
|
890
|
-
declare enum MouseApiEvent {
|
|
906
|
+
declare class Page implements IPage {
|
|
891
907
|
/**
|
|
892
|
-
*
|
|
908
|
+
* 页面名称,名称必须以包名开头,如果以.开头,会自动加上包名<br>
|
|
909
|
+
* 假设包名为`example.com`,以下两种写法等价
|
|
910
|
+
* @example example.com.countdown
|
|
911
|
+
* @example .countdown
|
|
893
912
|
*/
|
|
894
|
-
|
|
895
|
-
}
|
|
896
|
-
type MouseApiMethods = keyof IMouseApi;
|
|
897
|
-
|
|
898
|
-
/**
|
|
899
|
-
* @see https://electronjs.org/docs/api/structures/size
|
|
900
|
-
*/
|
|
901
|
-
interface Size {
|
|
902
|
-
height: number;
|
|
903
|
-
width: number;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* @see https://electronjs.org/docs/api/structures/display
|
|
908
|
-
*/
|
|
909
|
-
interface Display {
|
|
913
|
+
name: string;
|
|
910
914
|
/**
|
|
911
|
-
*
|
|
915
|
+
* 窗口标题,显示在界面上的,
|
|
916
|
+
* @see https://zh.m.wikipedia.org/zh-hans/ISO_639-1
|
|
912
917
|
*/
|
|
913
|
-
|
|
918
|
+
readonly title: LanguageTextMap;
|
|
914
919
|
/**
|
|
915
|
-
*
|
|
920
|
+
* 窗口介绍
|
|
916
921
|
*/
|
|
917
|
-
|
|
922
|
+
readonly description: LanguageTextMap;
|
|
923
|
+
readonly keywords: WidgetKeyword[];
|
|
924
|
+
readonly security: boolean;
|
|
925
|
+
readonly permissions: WidgetPermission[];
|
|
918
926
|
/**
|
|
919
|
-
*
|
|
927
|
+
* 组件默认语言
|
|
920
928
|
*/
|
|
921
|
-
|
|
929
|
+
readonly lang: LanguageCode;
|
|
930
|
+
readonly width: number;
|
|
931
|
+
packageName?: string | null;
|
|
932
|
+
readonly height: number;
|
|
933
|
+
readonly maxWidth: number;
|
|
922
934
|
/**
|
|
923
|
-
*
|
|
924
|
-
* color combinations) for the purpose of color conversions
|
|
935
|
+
* @deprecated
|
|
925
936
|
*/
|
|
926
|
-
|
|
937
|
+
readonly webviewTag: boolean;
|
|
938
|
+
readonly maxHeight: number;
|
|
939
|
+
readonly minWidth: number;
|
|
940
|
+
readonly minHeight: number;
|
|
941
|
+
readonly movable: boolean;
|
|
942
|
+
readonly singleton: boolean;
|
|
943
|
+
readonly resizable: boolean;
|
|
944
|
+
readonly path: string;
|
|
945
|
+
readonly icon?: string;
|
|
946
|
+
readonly meta: MetaInfo;
|
|
947
|
+
readonly backgroundThrottling: boolean;
|
|
927
948
|
/**
|
|
928
|
-
*
|
|
949
|
+
* 预览图片,可以是GIF
|
|
929
950
|
*/
|
|
930
|
-
|
|
951
|
+
readonly previewImage?: string;
|
|
952
|
+
constructor(options: IPageOptions);
|
|
931
953
|
/**
|
|
932
|
-
*
|
|
954
|
+
* 获取组件标题
|
|
955
|
+
* @param lang 语言环境,不传则获取默认语言
|
|
933
956
|
*/
|
|
934
|
-
|
|
957
|
+
getTitle(lang?: LanguageCode): string | undefined;
|
|
935
958
|
/**
|
|
936
|
-
*
|
|
937
|
-
|
|
959
|
+
* 获取组件描述
|
|
960
|
+
* @param lang 语言环境,不传则获取默认标题
|
|
961
|
+
*/
|
|
962
|
+
getDescription(lang?: LanguageCode): string | undefined;
|
|
963
|
+
static parseJSON(json: string): Page;
|
|
964
|
+
static parseObject(obj: any): Page;
|
|
965
|
+
isResizable(): boolean;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
type SocialType = 'qq' | 'wechat' | 'qq-group' | 'discord' | 'telegram' | 'tiktok' | 'douyin' | 'youtube' | 'instagram' | 'twitter' | 'facebook' | 'kuaishou' | 'bilibili' | 'github' | 'email' | 'gitee' | 'homepage';
|
|
969
|
+
declare class SocialInfo {
|
|
970
|
+
content: string;
|
|
971
|
+
name: SocialType;
|
|
972
|
+
constructor(name: SocialType, content: string);
|
|
973
|
+
}
|
|
974
|
+
interface SocialLink {
|
|
975
|
+
name: SocialType;
|
|
976
|
+
link: string;
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* @see [Web Manifest Categories]https://developer.mozilla.org/en-US/docs/Web/Manifest/categories
|
|
981
|
+
* @see [W3C Categories](https://github.com/w3c/manifest/wiki/Categories)
|
|
982
|
+
*/
|
|
983
|
+
type Category = 'news' | 'photo' | 'productivity' | 'social' | 'utilities' | 'weather'
|
|
984
|
+
/**
|
|
985
|
+
* @deprecated
|
|
986
|
+
*/
|
|
987
|
+
| 'calendar' | 'fun'
|
|
988
|
+
/**
|
|
989
|
+
* @deprecated
|
|
990
|
+
*/
|
|
991
|
+
| 'countdown' | 'time' | 'finance' | 'ai';
|
|
992
|
+
|
|
993
|
+
interface IWidgetOptions extends IWindowSize, IPageOptions {
|
|
994
|
+
supportDeployMode?: DeployMode;
|
|
995
|
+
configPagePath?: string;
|
|
996
|
+
/**
|
|
997
|
+
* 如果为true,组件将不会添加到组件包中
|
|
998
|
+
*/
|
|
999
|
+
disabled?: boolean;
|
|
1000
|
+
previewImage: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* whether the widget data can be synchronized
|
|
1003
|
+
*/
|
|
1004
|
+
synchronizable?: boolean;
|
|
1005
|
+
categories?: Category[];
|
|
1006
|
+
/**
|
|
1007
|
+
* 组件包所需的App版本
|
|
1008
|
+
*/
|
|
1009
|
+
requiredAppVersion?: string;
|
|
1010
|
+
description: LanguageTextMap;
|
|
1011
|
+
keywords: WidgetKeyword[];
|
|
1012
|
+
/**
|
|
1013
|
+
* @deprecated
|
|
1014
|
+
*/
|
|
1015
|
+
routes?: WidgetRoute[];
|
|
1016
|
+
/**
|
|
1017
|
+
* 一般用于填写教程链接
|
|
1018
|
+
*/
|
|
1019
|
+
socialLinks?: SocialLink[];
|
|
1020
|
+
browserWindowOptions?: Pick<BrowserWindowOptions, 'backgroundThrottling'>;
|
|
1021
|
+
trayOptions?: TrayWidgetOptions;
|
|
1022
|
+
}
|
|
1023
|
+
interface IBackgroundWidgetOptions extends Omit<IWidgetOptions, 'width' | 'height'> {
|
|
1024
|
+
width?: number;
|
|
1025
|
+
height?: number;
|
|
1026
|
+
browserWindowOptions?: BrowserWindowOptions;
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* @deprecated
|
|
1030
|
+
*/
|
|
1031
|
+
interface WidgetRoute {
|
|
1032
|
+
url: string;
|
|
1033
|
+
name: string;
|
|
1034
|
+
}
|
|
1035
|
+
interface TrayWidgetOptions {
|
|
1036
|
+
closeOnBlur?: boolean;
|
|
1037
|
+
hideOnBlur?: boolean;
|
|
1038
|
+
}
|
|
1039
|
+
declare class Widget extends Page {
|
|
1040
|
+
readonly previewImage: string;
|
|
1041
|
+
readonly categories?: Category[];
|
|
1042
|
+
readonly supportDeployMode: number;
|
|
1043
|
+
readonly trayOptions?: TrayWidgetOptions;
|
|
1044
|
+
/**
|
|
1045
|
+
* 组件包所需的App版本
|
|
1046
|
+
*/
|
|
1047
|
+
readonly requiredAppVersion?: string;
|
|
1048
|
+
/**
|
|
1049
|
+
* 如果为true,组件将不会添加到组件包中
|
|
1050
|
+
*/
|
|
1051
|
+
readonly disabled?: boolean;
|
|
1052
|
+
readonly synchronizable?: boolean;
|
|
1053
|
+
/**
|
|
1054
|
+
* 配置页面路径,没有则不能修改
|
|
1055
|
+
*/
|
|
1056
|
+
readonly configPagePath?: string;
|
|
1057
|
+
/**
|
|
1058
|
+
* @deprecated
|
|
1059
|
+
*/
|
|
1060
|
+
readonly routes: WidgetRoute[];
|
|
1061
|
+
protected browserWindowOptions?: BrowserWindowOptions;
|
|
1062
|
+
readonly socialLinks?: SocialLink[];
|
|
1063
|
+
constructor(options: IWidgetOptions);
|
|
1064
|
+
static parseJSON(json: string): Widget;
|
|
1065
|
+
static parseObject(obj: any): Widget;
|
|
1066
|
+
/**
|
|
1067
|
+
* 是否支持悬浮窗
|
|
1068
|
+
*/
|
|
1069
|
+
isSupportOverlap(): boolean;
|
|
1070
|
+
isSupportBackground(): boolean;
|
|
1071
|
+
isSupportTray(): boolean;
|
|
1072
|
+
/**
|
|
1073
|
+
* 是否支持普通模式
|
|
1074
|
+
*/
|
|
1075
|
+
isSupportNormal(): boolean;
|
|
1076
|
+
isConfigurable(): boolean;
|
|
1077
|
+
}
|
|
1078
|
+
declare class BackgroundWidget extends Widget {
|
|
1079
|
+
constructor(options: IBackgroundWidgetOptions);
|
|
1080
|
+
}
|
|
1081
|
+
declare enum WidgetKeyword {
|
|
1082
|
+
RECOMMEND = "recommend",
|
|
1083
|
+
TOOLS = "tools",
|
|
1084
|
+
EFFICIENCY = "efficiency",
|
|
1085
|
+
PICTURE = "picture",
|
|
1086
|
+
LIFE = "life",
|
|
1087
|
+
SHORTCUT = "shortcut",
|
|
1088
|
+
COUNTDOWN = "countdown",
|
|
1089
|
+
TIMER = "timer",
|
|
1090
|
+
INFO = "info",
|
|
1091
|
+
DASHBOARD = "dashboard"
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
declare class WidgetParams {
|
|
1095
|
+
static readonly PARAM_PREFIX = "w_";
|
|
1096
|
+
static readonly PARAM_ID = "id";
|
|
1097
|
+
static readonly PARAM_LANG = "lang";
|
|
1098
|
+
static readonly PARAM_THEME = "theme";
|
|
1099
|
+
static readonly PARAM_MODE = "mode";
|
|
1100
|
+
static readonly PARAM_NAME = "name";
|
|
1101
|
+
static readonly PARAM_TITLE = "title";
|
|
1102
|
+
static readonly PARAM_PREVIEW = "preview";
|
|
1103
|
+
static readonly PARAMS: string[];
|
|
1104
|
+
id?: string;
|
|
1105
|
+
width?: number;
|
|
1106
|
+
widthPx?: number;
|
|
1107
|
+
heightPx?: number;
|
|
1108
|
+
height?: number;
|
|
1109
|
+
x?: number;
|
|
1110
|
+
y?: number;
|
|
1111
|
+
preview?: boolean;
|
|
1112
|
+
lang?: string;
|
|
1113
|
+
theme?: ThemeMode;
|
|
1114
|
+
mode?: DeployMode;
|
|
1115
|
+
radius?: number;
|
|
1116
|
+
name?: string;
|
|
1117
|
+
title?: string;
|
|
1118
|
+
/**
|
|
1119
|
+
* 将组件参数转为url参数
|
|
1120
|
+
* @param object
|
|
1121
|
+
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
1122
|
+
*/
|
|
1123
|
+
toUrlParams(): URLSearchParams;
|
|
1124
|
+
getPersistKey(): string;
|
|
1125
|
+
/**
|
|
1126
|
+
* 从当前地址解析组件参数:
|
|
1127
|
+
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
1128
|
+
* =>
|
|
1129
|
+
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
1130
|
+
*/
|
|
1131
|
+
static fromCurrentLocation(): WidgetParams;
|
|
1132
|
+
static fromLocation(url: string): WidgetParams;
|
|
1133
|
+
private static setValue;
|
|
1134
|
+
/**
|
|
1135
|
+
* 从对象键值对中初始化组件参数
|
|
1136
|
+
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
1137
|
+
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
1138
|
+
* @param object
|
|
1139
|
+
*/
|
|
1140
|
+
static fromObject(object: any): WidgetParams;
|
|
1141
|
+
}
|
|
1142
|
+
declare enum ThemeMode {
|
|
1143
|
+
AUTO = "auto",
|
|
1144
|
+
LIGHT = "LIGHT",
|
|
1145
|
+
DARK = "DARK"
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
declare abstract class BaseApi<T extends string> {
|
|
1149
|
+
abstract getChannel(): string;
|
|
1150
|
+
protected invokeMethod(method: T, ...args: any[]): Promise<any>;
|
|
1151
|
+
protected invoke(...args: any[]): Promise<any>;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
interface AddWidgetOption {
|
|
1155
|
+
widgetName: string;
|
|
1156
|
+
widgetTitle?: string;
|
|
1157
|
+
deployMode: DeployMode;
|
|
1158
|
+
packageJsonUrl?: string;
|
|
1159
|
+
hostname?: string;
|
|
1160
|
+
}
|
|
1161
|
+
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
1162
|
+
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
1163
|
+
getChannel(): string;
|
|
1164
|
+
/**
|
|
1165
|
+
* 移除组件
|
|
1166
|
+
* @param id
|
|
1167
|
+
*/
|
|
1168
|
+
removeDeployedWidget(id?: string): Promise<any>;
|
|
1169
|
+
addWidget(options: AddWidgetOption): Promise<Widget[]>;
|
|
1170
|
+
createDesktopShortcut(widgetName: string): Promise<boolean>;
|
|
1171
|
+
/**
|
|
1172
|
+
* 通过组件名移除已添加的组件
|
|
1173
|
+
* @param name 组件名
|
|
1174
|
+
*/
|
|
1175
|
+
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
1176
|
+
/**
|
|
1177
|
+
* 获取已添加的组件
|
|
1178
|
+
* @param name 组件名,可以不传
|
|
1179
|
+
*/
|
|
1180
|
+
getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
|
|
1181
|
+
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Opens the dev tools for a widget with the specified ID.
|
|
1184
|
+
*
|
|
1185
|
+
* @param {string} widgetId - The ID of the widget to open the dev tools for.
|
|
1186
|
+
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
1187
|
+
*/
|
|
1188
|
+
openDevTools(widgetId: string): Promise<any>;
|
|
1189
|
+
openConfigPage(widgetId?: string, params?: WidgetParams): Promise<any>;
|
|
1190
|
+
/**
|
|
1191
|
+
* 注册激活、呼出、置顶组件快捷键
|
|
1192
|
+
* @param widgetId 组件id
|
|
1193
|
+
* @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
|
|
1194
|
+
* https://www.electronjs.org/docs/latest/api/accelerator
|
|
1195
|
+
*/
|
|
1196
|
+
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
1197
|
+
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
1198
|
+
}
|
|
1199
|
+
declare const DeployedWidgetApi: DeployedWidgetApiImpl;
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* DeployedWidgetApi provides methods for managing deployed widgets within the application.
|
|
1203
|
+
* It allows for the removal, retrieval, and configuration of deployed widgets,
|
|
1204
|
+
* as well as the ability to manipulate their settings and behavior.
|
|
1205
|
+
* @remarks
|
|
1206
|
+
*/
|
|
1207
|
+
interface IDeployedWidgetApi {
|
|
1208
|
+
removeDeployedWidget: (id?: string) => Promise<void>;
|
|
1209
|
+
removeDeployedWidgetByName: (name: string) => Promise<DeployedWidget[]>;
|
|
1210
|
+
getDeployedWidgets: () => Promise<DeployedWidget[]>;
|
|
1211
|
+
openDevTools: (id: string) => Promise<void>;
|
|
1212
|
+
/**
|
|
1213
|
+
* @deprecated 使用WidgetApi.openConfigPage代替
|
|
1214
|
+
* @param id
|
|
1215
|
+
*/
|
|
1216
|
+
openConfigPage: (id?: string, params?: WidgetParams) => Promise<void>;
|
|
1217
|
+
registerActiveShortcut: (id: string, shortcut: string) => Promise<boolean>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Set proxy for the widget, this will reload the widget after setting the proxy.
|
|
1220
|
+
* @param id
|
|
1221
|
+
* @param proxy
|
|
1222
|
+
*/
|
|
1223
|
+
setProxy: (id: string, proxy: string) => Promise<boolean>;
|
|
1224
|
+
getDeployedWidget: (id: string) => Promise<DeployedWidget>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Adds a new widget with the specified options.
|
|
1227
|
+
* If in browser environment, it will open widget://widgetjs.cn/widget?packageUrl=xxx&name=xxx&package
|
|
1228
|
+
* @param options - The options for the widget to be added.
|
|
1229
|
+
* @returns A promise that resolves with an array of added widgets.
|
|
1230
|
+
*/
|
|
1231
|
+
addWidget: (options: AddWidgetOption) => Promise<Widget[]>;
|
|
1232
|
+
/**
|
|
1233
|
+
* 创建桌面快捷方式
|
|
1234
|
+
* @param widgetName 组件名
|
|
1235
|
+
* @returns 成功返回 true,否则返回 false
|
|
1236
|
+
*/
|
|
1237
|
+
createDesktopShortcut: (widgetName: string) => Promise<boolean>;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* AiApiEvent
|
|
1241
|
+
*/
|
|
1242
|
+
declare enum DeployedWidgetApiEvent {
|
|
1243
|
+
/**
|
|
1244
|
+
* 第二实例启动事件
|
|
1245
|
+
*/
|
|
1246
|
+
SECOND_INSTANCE = "channel::cn.widgetjs.core.deployed_widget.second_instance"
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
/**
|
|
1250
|
+
* @see https://electronjs.org/docs/api/structures/size
|
|
1251
|
+
*/
|
|
1252
|
+
interface Size {
|
|
1253
|
+
height: number;
|
|
1254
|
+
width: number;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
/**
|
|
1258
|
+
* @see https://electronjs.org/docs/api/structures/display
|
|
1259
|
+
*/
|
|
1260
|
+
interface Display {
|
|
1261
|
+
/**
|
|
1262
|
+
* Can be `available`, `unavailable`, `unknown`.
|
|
1263
|
+
*/
|
|
1264
|
+
accelerometerSupport: ('available' | 'unavailable' | 'unknown');
|
|
1265
|
+
/**
|
|
1266
|
+
* the bounds of the display in DIP points.
|
|
1267
|
+
*/
|
|
1268
|
+
bounds: Rectangle;
|
|
1269
|
+
/**
|
|
1270
|
+
* The number of bits per pixel.
|
|
1271
|
+
*/
|
|
1272
|
+
colorDepth: number;
|
|
1273
|
+
/**
|
|
1274
|
+
* represent a color space (three-dimensional object which contains all realizable
|
|
1275
|
+
* color combinations) for the purpose of color conversions
|
|
1276
|
+
*/
|
|
1277
|
+
colorSpace: string;
|
|
1278
|
+
/**
|
|
1279
|
+
* The number of bits per color component.
|
|
1280
|
+
*/
|
|
1281
|
+
depthPerComponent: number;
|
|
1282
|
+
/**
|
|
1283
|
+
* The display refresh rate.
|
|
1284
|
+
*/
|
|
1285
|
+
displayFrequency: number;
|
|
1286
|
+
/**
|
|
1287
|
+
* Unique identifier associated with the display.
|
|
1288
|
+
*/
|
|
938
1289
|
id: number;
|
|
939
1290
|
/**
|
|
940
1291
|
* `true` for an internal display and `false` for an external display
|
|
@@ -1049,8 +1400,24 @@ interface IDeviceApi {
|
|
|
1049
1400
|
* Checks if Caps Lock is on.
|
|
1050
1401
|
* @returns A promise that resolves to a boolean indicating if Caps Lock is on.
|
|
1051
1402
|
*/
|
|
1052
|
-
isCapsLockOn: () => Promise<boolean>;
|
|
1403
|
+
isCapsLockOn: () => Promise<boolean>;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* DialogApi 提供文件、文件夹选择功能
|
|
1408
|
+
*/
|
|
1409
|
+
interface IDialogApi {
|
|
1410
|
+
/**
|
|
1411
|
+
* 选取单个文件
|
|
1412
|
+
* @param extensions 允许的文件后缀格式,如:["txt","docx","gif"]
|
|
1413
|
+
*/
|
|
1414
|
+
pickFile: (extensions?: string[]) => Promise<string | undefined>;
|
|
1415
|
+
/**
|
|
1416
|
+
* 选取文件夹
|
|
1417
|
+
*/
|
|
1418
|
+
pickFolder: () => Promise<string | undefined>;
|
|
1053
1419
|
}
|
|
1420
|
+
type DialogApiMethods = keyof IDialogApi;
|
|
1054
1421
|
|
|
1055
1422
|
interface Metadata {
|
|
1056
1423
|
/** Number value of the EXIF Orientation header, if present */
|
|
@@ -2224,6 +2591,61 @@ interface IFileApi {
|
|
|
2224
2591
|
trashItem: (path: string) => Promise<void>;
|
|
2225
2592
|
}
|
|
2226
2593
|
|
|
2594
|
+
/**
|
|
2595
|
+
* LogApi提供了日志输出的方法,日志会保存在用户的`当前用户名/文档/桌面组件/logs/日期/组件包名.log`文件中
|
|
2596
|
+
*/
|
|
2597
|
+
interface ILogApi {
|
|
2598
|
+
info: (...data: any[]) => void;
|
|
2599
|
+
error: (...data: any[]) => void;
|
|
2600
|
+
warn: (...data: any[]) => void;
|
|
2601
|
+
log: (...data: any[]) => void;
|
|
2602
|
+
json: (data: any) => void;
|
|
2603
|
+
}
|
|
2604
|
+
type LogApiMethods = keyof ILogApi;
|
|
2605
|
+
|
|
2606
|
+
/**
|
|
2607
|
+
* MouseApi
|
|
2608
|
+
*/
|
|
2609
|
+
interface IMouseApi {
|
|
2610
|
+
/**
|
|
2611
|
+
* Create a mouse screen edge hotspot, usually used for edge-hiding windows.
|
|
2612
|
+
* @param rect
|
|
2613
|
+
*/
|
|
2614
|
+
createHotspot: (rect: Rectangle) => Promise<void>;
|
|
2615
|
+
/**
|
|
2616
|
+
* Remove the mouse screen edge hotspot.
|
|
2617
|
+
*/
|
|
2618
|
+
removeHotspot: () => Promise<void>;
|
|
2619
|
+
}
|
|
2620
|
+
/**
|
|
2621
|
+
* SystemApiEvent
|
|
2622
|
+
*/
|
|
2623
|
+
declare enum MouseApiEvent {
|
|
2624
|
+
/**
|
|
2625
|
+
* Triggered when the mouse enters the hotspot area.
|
|
2626
|
+
*/
|
|
2627
|
+
HOTSPOT_ACTIVE = "event::cn.widgetjs.core.mouse.hotspot.active"
|
|
2628
|
+
}
|
|
2629
|
+
type MouseApiMethods = keyof IMouseApi;
|
|
2630
|
+
|
|
2631
|
+
/**
|
|
2632
|
+
* ProcessApi 提供进程信息获取功能
|
|
2633
|
+
*/
|
|
2634
|
+
interface IProcessApi {
|
|
2635
|
+
getBlinkMemoryInfo: () => Promise<Electron.BlinkMemoryInfo>;
|
|
2636
|
+
getHeapStatistics: () => Promise<Electron.HeapStatistics>;
|
|
2637
|
+
/**
|
|
2638
|
+
* 获取系统版本信息
|
|
2639
|
+
* @example '10.0.17763'
|
|
2640
|
+
*/
|
|
2641
|
+
getSystemVersion: () => Promise<string>;
|
|
2642
|
+
/**
|
|
2643
|
+
* 获取当前应用内存信息
|
|
2644
|
+
*/
|
|
2645
|
+
getProcessMemoryInfo: () => Promise<Electron.ProcessMemoryInfo>;
|
|
2646
|
+
}
|
|
2647
|
+
type ProcessApiMethods = keyof IProcessApi;
|
|
2648
|
+
|
|
2227
2649
|
/**
|
|
2228
2650
|
* MenuApi 接口定义了一系列用于控制窗口的方法,这些方法提供了窗口的显示、隐藏、移动、调整大小等功能
|
|
2229
2651
|
* @remarks 注意:桌面类型组件不支持窗口移动、调整大小、最大化、最小化等操作
|
|
@@ -2387,504 +2809,238 @@ interface ITrayApi {
|
|
|
2387
2809
|
* Replaces any previously set menu.
|
|
2388
2810
|
* @param menus Array of WidgetMenuItem describing the menu structure
|
|
2389
2811
|
*/
|
|
2390
|
-
setContextMenu: (menus: WidgetMenuItem[]) => Promise<void>;
|
|
2391
|
-
/**
|
|
2392
|
-
* Close any open context menu for the tray (if supported by the platform).
|
|
2393
|
-
*/
|
|
2394
|
-
closeContextMenu: () => Promise<void>;
|
|
2395
|
-
/**
|
|
2396
|
-
* Programmatically pop up a context menu at the optional screen position.
|
|
2397
|
-
* On some platforms the position may be ignored.
|
|
2398
|
-
* @param menus menu items to show
|
|
2399
|
-
* @param position optional screen point where the menu should appear
|
|
2400
|
-
*/
|
|
2401
|
-
popUpContextMenu: (menus: WidgetMenuItem[], position?: Point) => Promise<void>;
|
|
2402
|
-
/**
|
|
2403
|
-
* Returns whether the underlying native tray object has been destroyed.
|
|
2404
|
-
* Useful to check before calling other tray methods.
|
|
2405
|
-
*/
|
|
2406
|
-
isDestroyed: () => Promise<boolean>;
|
|
2407
|
-
/**
|
|
2408
|
-
* Get the bounds of the tray icon on screen.
|
|
2409
|
-
* Returns a Rectangle when available, or `null` if the bounds cannot be determined
|
|
2410
|
-
* on the current platform or if the tray is not present.
|
|
2411
|
-
*/
|
|
2412
|
-
getBounds: () => Promise<Rectangle | null>;
|
|
2413
|
-
/**
|
|
2414
|
-
* Bring the application to the foreground or focus the window associated with the tray.
|
|
2415
|
-
* Exact behavior depends on platform and application window state.
|
|
2416
|
-
*/
|
|
2417
|
-
focus: () => Promise<void>;
|
|
2418
|
-
}
|
|
2419
|
-
/**
|
|
2420
|
-
* TrayApiEvent
|
|
2421
|
-
*
|
|
2422
|
-
* Events emitted from the tray icon. Channels are stable strings used for internal
|
|
2423
|
-
* event routing; subscribers should listen to these channels to react to user
|
|
2424
|
-
* interactions with the tray icon.
|
|
2425
|
-
*/
|
|
2426
|
-
declare enum TrayApiEvent {
|
|
2427
|
-
/**
|
|
2428
|
-
* Emitted when the tray icon is clicked (usually left-button click).
|
|
2429
|
-
* Channel: 'channel::cn.widgetjs.core.tray.click'
|
|
2430
|
-
*/
|
|
2431
|
-
CLICK = "channel::cn.widgetjs.core.tray.click",
|
|
2432
|
-
/**
|
|
2433
|
-
* Emitted when the tray icon receives a right-button click.
|
|
2434
|
-
* Channel: 'channel::cn.widgetjs.core.tray.right-click'
|
|
2435
|
-
*/
|
|
2436
|
-
RIGHT_CLICK = "channel::cn.widgetjs.core.tray.right-click",
|
|
2437
|
-
/**
|
|
2438
|
-
* Emitted when the tray icon receives a middle-button click (if supported).
|
|
2439
|
-
* Channel: 'channel::cn.widgetjs.core.tray.middle-click'
|
|
2440
|
-
*/
|
|
2441
|
-
MIDDLE_CLICK = "channel::cn.widgetjs.core.tray.middle-click",
|
|
2442
|
-
/**
|
|
2443
|
-
* Emitted when the mouse pointer enters the tray icon area (hover start).
|
|
2444
|
-
* Channel: 'channel::cn.widgetjs.core.tray.mouse-enter'
|
|
2445
|
-
*/
|
|
2446
|
-
MOUSE_ENTER = "channel::cn.widgetjs.core.tray.mouse-enter",
|
|
2447
|
-
/**
|
|
2448
|
-
* Emitted when the mouse pointer leaves the tray icon area (hover end).
|
|
2449
|
-
* Channel: 'channel::cn.widgetjs.core.tray.mouse-leave'
|
|
2450
|
-
*/
|
|
2451
|
-
MOUSE_LEAVE = "channel::cn.widgetjs.core.tray.mouse-leave"
|
|
2452
|
-
}
|
|
2453
|
-
type TrayApiMethods = keyof ITrayApi;
|
|
2454
|
-
|
|
2455
|
-
interface IUserApi {
|
|
2456
|
-
/**
|
|
2457
|
-
* Login with user info.
|
|
2458
|
-
* @param token
|
|
2459
|
-
*/
|
|
2460
|
-
login: (session: AuthSession) => Promise<void>;
|
|
2461
|
-
/**
|
|
2462
|
-
* Clear user auth token and user info.
|
|
2463
|
-
*/
|
|
2464
|
-
logout: () => Promise<void>;
|
|
2465
|
-
/**
|
|
2466
|
-
* Get current logged in user info. If no user is logged in, return null.
|
|
2467
|
-
*/
|
|
2468
|
-
getUser: () => Promise<AuthUser | null>;
|
|
2469
|
-
updateSession: (session: AuthSession) => Promise<void>;
|
|
2470
|
-
getSession: () => Promise<AuthSession | null>;
|
|
2471
|
-
updateUser: (user: AuthUser) => Promise<void>;
|
|
2472
|
-
}
|
|
2473
|
-
/**
|
|
2474
|
-
* ShortcutApiEvent
|
|
2475
|
-
*/
|
|
2476
|
-
declare enum UserApiEvent {
|
|
2477
|
-
/**
|
|
2478
|
-
* 快捷键触发事件
|
|
2479
|
-
*/
|
|
2480
|
-
USER_UPDATED = "channel::cn.widgetjs.core.user.updated",
|
|
2481
|
-
SIGNED_OUT = "channel::cn.widgetjs.core.user.signed.out",
|
|
2482
|
-
SIGNED_IN = "channel::cn.widgetjs.core.user.signed.in",
|
|
2483
|
-
TOKEN_REFRESHED = "channel::cn.widgetjs.core.user.token.refreshed"
|
|
2484
|
-
}
|
|
2485
|
-
type UserApiMethods = keyof IUserApi;
|
|
2486
|
-
|
|
2487
|
-
interface AiConfig {
|
|
2488
|
-
id: string;
|
|
2489
|
-
model: string;
|
|
2490
|
-
apiKey: string;
|
|
2491
|
-
apiBaseUrl: string;
|
|
2492
|
-
}
|
|
2493
|
-
interface IAiApi {
|
|
2494
|
-
addConfig(config: AiConfig): Promise<AiConfig>;
|
|
2495
|
-
deleteConfig(id: string): Promise<void>;
|
|
2496
|
-
updateConfig(config: AiConfig): Promise<void>;
|
|
2497
|
-
getConfigList(): Promise<AiConfig[]>;
|
|
2498
|
-
setConfigList(configs: AiConfig[]): Promise<void>;
|
|
2499
|
-
getConfig(id: string): Promise<AiConfig | undefined>;
|
|
2500
|
-
}
|
|
2501
|
-
/**
|
|
2502
|
-
* AiApiEvent
|
|
2503
|
-
*/
|
|
2504
|
-
declare enum AiApiEvent {
|
|
2505
|
-
/**
|
|
2506
|
-
* 配置更新事件
|
|
2507
|
-
*/
|
|
2508
|
-
CONFIG_UPDATED = "channel::cn.widgetjs.core.ai.config.updated"
|
|
2509
|
-
}
|
|
2510
|
-
type AiApiMethods = keyof IAiApi;
|
|
2511
|
-
|
|
2512
|
-
declare const AppApi: IAppApi;
|
|
2513
|
-
|
|
2514
|
-
declare abstract class BaseApi<T extends string> {
|
|
2515
|
-
abstract getChannel(): string;
|
|
2516
|
-
protected invokeMethod(method: T, ...args: any[]): Promise<any>;
|
|
2517
|
-
protected invoke(...args: any[]): Promise<any>;
|
|
2518
|
-
}
|
|
2519
|
-
|
|
2520
|
-
/**
|
|
2521
|
-
* WidgetApi 接口定义了一系列用于控制组件的方法,这些方法提供了组件的注册、升级、获取、打开设置页面、重新加载等功能
|
|
2522
|
-
*/
|
|
2523
|
-
interface IWidgetApi {
|
|
2524
|
-
/**
|
|
2525
|
-
* 注册组件
|
|
2526
|
-
* @param widgets
|
|
2527
|
-
*/
|
|
2528
|
-
registerWidgets: (widgets: Widget[]) => Promise<void>;
|
|
2529
|
-
/**
|
|
2530
|
-
* @deprecated
|
|
2531
|
-
*/
|
|
2532
|
-
registerWidgetPackage: (widgetPackage: WidgetPackage) => Promise<void>;
|
|
2533
|
-
/**
|
|
2534
|
-
* ignore mouse events
|
|
2535
|
-
* @param widgetId
|
|
2536
|
-
* @param ignore
|
|
2537
|
-
*/
|
|
2538
|
-
setIgnoreMouseEvents: (widgetId: string, ignore: boolean) => Promise<void>;
|
|
2539
|
-
/**
|
|
2540
|
-
* Check if the widget is ignoring mouse events.
|
|
2541
|
-
* @param widgetId
|
|
2542
|
-
*/
|
|
2543
|
-
isIgnoreMouseEvents: (widgetId?: string) => Promise<boolean>;
|
|
2544
|
-
/**
|
|
2545
|
-
* 设置组件是否可以左键拖动
|
|
2546
|
-
* @param draggable boolean true-启用左键拖动 false-禁用左键拖动
|
|
2547
|
-
* @remarks 注意:只对悬浮窗组件(DeployMode.OVERLAP)有效
|
|
2548
|
-
*/
|
|
2549
|
-
setMouseDraggable: (draggable: boolean) => Promise<void>;
|
|
2550
|
-
/**
|
|
2551
|
-
* 升级组件包
|
|
2552
|
-
* @param packageName 组件包名
|
|
2553
|
-
*/
|
|
2554
|
-
upgradePackage: (packageName: string) => Promise<void>;
|
|
2555
|
-
/**
|
|
2556
|
-
* 获取所有组件
|
|
2557
|
-
* @return Promise<Widget[]>
|
|
2558
|
-
*/
|
|
2559
|
-
getWidgets: () => Promise<Widget[]>;
|
|
2560
|
-
/**
|
|
2561
|
-
* 通过组件名称获取组件
|
|
2562
|
-
* @param name string 组件名
|
|
2563
|
-
* @return Promise<Widget>
|
|
2564
|
-
*/
|
|
2565
|
-
getWidget: (name: string) => Promise<Widget>;
|
|
2566
|
-
/**
|
|
2567
|
-
* @param name
|
|
2568
|
-
* @deprecated
|
|
2569
|
-
*/
|
|
2570
|
-
getWidgetPackage: (name: string) => Promise<WidgetPackage | undefined>;
|
|
2571
|
-
/**
|
|
2572
|
-
* @deprecated
|
|
2573
|
-
*/
|
|
2574
|
-
getWidgetPackages: () => Promise<WidgetPackage[]>;
|
|
2575
|
-
/**
|
|
2576
|
-
* 打开组件设置页面
|
|
2577
|
-
* @param id string 组件id
|
|
2578
|
-
*/
|
|
2579
|
-
openConfigPage: (id?: string) => Promise<void>;
|
|
2580
|
-
/**
|
|
2581
|
-
* @param name
|
|
2582
|
-
*/
|
|
2583
|
-
openConfigPageByName: (name: string) => Promise<void>;
|
|
2584
|
-
/**
|
|
2585
|
-
* 重新加载组件
|
|
2586
|
-
*/
|
|
2587
|
-
reload: (id?: string) => Promise<void>;
|
|
2588
|
-
/**
|
|
2589
|
-
*
|
|
2590
|
-
* @param packageName
|
|
2591
|
-
* @deprecated
|
|
2592
|
-
*/
|
|
2593
|
-
getWidgetPackageUrl: (packageName: string) => Promise<string | null>;
|
|
2594
|
-
restartWidgets: (mode?: DeployMode) => Promise<void>;
|
|
2595
|
-
updateSyncInfo: () => Promise<void>;
|
|
2596
|
-
getSyncInfo: (widgetName?: string) => Promise<WidgetSyncInfo | null>;
|
|
2597
|
-
}
|
|
2598
|
-
|
|
2599
|
-
type WidgetPermission = 'keyboard' | 'mouse' | 'clipboard' | 'notification' | 'storage' | 'network' | 'cpu' | 'system-info';
|
|
2600
|
-
|
|
2601
|
-
interface MetaInfo {
|
|
2602
|
-
[key: string]: string | number | boolean;
|
|
2603
|
-
}
|
|
2604
|
-
interface IWindowSize {
|
|
2605
|
-
width: number;
|
|
2606
|
-
height: number;
|
|
2607
|
-
maxWidth?: number;
|
|
2608
|
-
maxHeight?: number;
|
|
2609
|
-
minWidth?: number;
|
|
2610
|
-
minHeight?: number;
|
|
2611
|
-
}
|
|
2612
|
-
interface IPageOptions extends IWindowSize {
|
|
2613
|
-
name: string;
|
|
2812
|
+
setContextMenu: (menus: WidgetMenuItem[]) => Promise<void>;
|
|
2614
2813
|
/**
|
|
2615
|
-
*
|
|
2814
|
+
* Close any open context menu for the tray (if supported by the platform).
|
|
2616
2815
|
*/
|
|
2617
|
-
|
|
2816
|
+
closeContextMenu: () => Promise<void>;
|
|
2618
2817
|
/**
|
|
2619
|
-
*
|
|
2818
|
+
* Programmatically pop up a context menu at the optional screen position.
|
|
2819
|
+
* On some platforms the position may be ignored.
|
|
2820
|
+
* @param menus menu items to show
|
|
2821
|
+
* @param position optional screen point where the menu should appear
|
|
2620
2822
|
*/
|
|
2621
|
-
|
|
2823
|
+
popUpContextMenu: (menus: WidgetMenuItem[], position?: Point) => Promise<void>;
|
|
2622
2824
|
/**
|
|
2623
|
-
*
|
|
2825
|
+
* Returns whether the underlying native tray object has been destroyed.
|
|
2826
|
+
* Useful to check before calling other tray methods.
|
|
2624
2827
|
*/
|
|
2625
|
-
|
|
2626
|
-
lang: LanguageCode;
|
|
2627
|
-
packageName?: string;
|
|
2628
|
-
icon?: string;
|
|
2828
|
+
isDestroyed: () => Promise<boolean>;
|
|
2629
2829
|
/**
|
|
2630
|
-
*
|
|
2830
|
+
* Get the bounds of the tray icon on screen.
|
|
2831
|
+
* Returns a Rectangle when available, or `null` if the bounds cannot be determined
|
|
2832
|
+
* on the current platform or if the tray is not present.
|
|
2631
2833
|
*/
|
|
2632
|
-
|
|
2834
|
+
getBounds: () => Promise<Rectangle | null>;
|
|
2633
2835
|
/**
|
|
2634
|
-
*
|
|
2836
|
+
* Bring the application to the foreground or focus the window associated with the tray.
|
|
2837
|
+
* Exact behavior depends on platform and application window state.
|
|
2635
2838
|
*/
|
|
2636
|
-
|
|
2839
|
+
focus: () => Promise<void>;
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* TrayApiEvent
|
|
2843
|
+
*
|
|
2844
|
+
* Events emitted from the tray icon. Channels are stable strings used for internal
|
|
2845
|
+
* event routing; subscribers should listen to these channels to react to user
|
|
2846
|
+
* interactions with the tray icon.
|
|
2847
|
+
*/
|
|
2848
|
+
declare enum TrayApiEvent {
|
|
2637
2849
|
/**
|
|
2638
|
-
*
|
|
2639
|
-
*
|
|
2850
|
+
* Emitted when the tray icon is clicked (usually left-button click).
|
|
2851
|
+
* Channel: 'channel::cn.widgetjs.core.tray.click'
|
|
2640
2852
|
*/
|
|
2641
|
-
|
|
2853
|
+
CLICK = "channel::cn.widgetjs.core.tray.click",
|
|
2642
2854
|
/**
|
|
2643
|
-
*
|
|
2855
|
+
* Emitted when the tray icon receives a right-button click.
|
|
2856
|
+
* Channel: 'channel::cn.widgetjs.core.tray.right-click'
|
|
2644
2857
|
*/
|
|
2645
|
-
|
|
2858
|
+
RIGHT_CLICK = "channel::cn.widgetjs.core.tray.right-click",
|
|
2646
2859
|
/**
|
|
2647
|
-
*
|
|
2860
|
+
* Emitted when the tray icon receives a middle-button click (if supported).
|
|
2861
|
+
* Channel: 'channel::cn.widgetjs.core.tray.middle-click'
|
|
2648
2862
|
*/
|
|
2649
|
-
|
|
2650
|
-
security?: boolean;
|
|
2863
|
+
MIDDLE_CLICK = "channel::cn.widgetjs.core.tray.middle-click",
|
|
2651
2864
|
/**
|
|
2652
|
-
*
|
|
2865
|
+
* Emitted when the mouse pointer enters the tray icon area (hover start).
|
|
2866
|
+
* Channel: 'channel::cn.widgetjs.core.tray.mouse-enter'
|
|
2653
2867
|
*/
|
|
2654
|
-
|
|
2655
|
-
path: string;
|
|
2868
|
+
MOUSE_ENTER = "channel::cn.widgetjs.core.tray.mouse-enter",
|
|
2656
2869
|
/**
|
|
2657
|
-
*
|
|
2870
|
+
* Emitted when the mouse pointer leaves the tray icon area (hover end).
|
|
2871
|
+
* Channel: 'channel::cn.widgetjs.core.tray.mouse-leave'
|
|
2658
2872
|
*/
|
|
2659
|
-
|
|
2660
|
-
permissions?: WidgetPermission[];
|
|
2661
|
-
meta?: MetaInfo;
|
|
2662
|
-
broadcastChannels?: string[];
|
|
2873
|
+
MOUSE_LEAVE = "channel::cn.widgetjs.core.tray.mouse-leave"
|
|
2663
2874
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2875
|
+
type TrayApiMethods = keyof ITrayApi;
|
|
2876
|
+
|
|
2877
|
+
interface IUserApi {
|
|
2666
2878
|
/**
|
|
2667
|
-
*
|
|
2668
|
-
*
|
|
2879
|
+
* Login with user info.
|
|
2880
|
+
* @param token
|
|
2669
2881
|
*/
|
|
2670
|
-
|
|
2671
|
-
readonly permissions: WidgetPermission[];
|
|
2672
|
-
readonly webviewTag: boolean;
|
|
2882
|
+
login: (session: AuthSession) => Promise<void>;
|
|
2673
2883
|
/**
|
|
2674
|
-
*
|
|
2884
|
+
* Clear user auth token and user info.
|
|
2675
2885
|
*/
|
|
2676
|
-
|
|
2677
|
-
readonly keywords: WidgetKeyword[];
|
|
2886
|
+
logout: () => Promise<void>;
|
|
2678
2887
|
/**
|
|
2679
|
-
*
|
|
2888
|
+
* Get current logged in user info. If no user is logged in, return null.
|
|
2680
2889
|
*/
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
readonly singleton: boolean;
|
|
2691
|
-
readonly resizable: boolean;
|
|
2692
|
-
readonly path: string;
|
|
2693
|
-
readonly meta: {
|
|
2694
|
-
[key: string]: string | number | boolean;
|
|
2695
|
-
};
|
|
2696
|
-
readonly backgroundThrottling: boolean;
|
|
2890
|
+
getUser: () => Promise<AuthUser | null>;
|
|
2891
|
+
updateSession: (session: AuthSession) => Promise<void>;
|
|
2892
|
+
getSession: () => Promise<AuthSession | null>;
|
|
2893
|
+
updateUser: (user: AuthUser) => Promise<void>;
|
|
2894
|
+
}
|
|
2895
|
+
/**
|
|
2896
|
+
* ShortcutApiEvent
|
|
2897
|
+
*/
|
|
2898
|
+
declare enum UserApiEvent {
|
|
2697
2899
|
/**
|
|
2698
|
-
*
|
|
2900
|
+
* 快捷键触发事件
|
|
2699
2901
|
*/
|
|
2700
|
-
|
|
2902
|
+
USER_UPDATED = "channel::cn.widgetjs.core.user.updated",
|
|
2903
|
+
SIGNED_OUT = "channel::cn.widgetjs.core.user.signed.out",
|
|
2904
|
+
SIGNED_IN = "channel::cn.widgetjs.core.user.signed.in",
|
|
2905
|
+
TOKEN_REFRESHED = "channel::cn.widgetjs.core.user.token.refreshed"
|
|
2701
2906
|
}
|
|
2702
|
-
|
|
2907
|
+
type UserApiMethods = keyof IUserApi;
|
|
2908
|
+
|
|
2909
|
+
/**
|
|
2910
|
+
* WidgetPackageApi 提供了组件包的升级、获取、安装等功能
|
|
2911
|
+
*/
|
|
2912
|
+
interface IWidgetPackageApi {
|
|
2703
2913
|
/**
|
|
2704
|
-
*
|
|
2705
|
-
*
|
|
2706
|
-
* @
|
|
2707
|
-
* @example .countdown
|
|
2914
|
+
* 升级组件包
|
|
2915
|
+
* @param packageName 组件包名称
|
|
2916
|
+
* @param remoteUrlInfo
|
|
2708
2917
|
*/
|
|
2709
|
-
|
|
2918
|
+
upgrade: (packageName: string, remoteUrlInfo: RemotePackageUrlInfo) => Promise<void>;
|
|
2710
2919
|
/**
|
|
2711
|
-
*
|
|
2712
|
-
* @
|
|
2920
|
+
* 获取组件包的首页url信息
|
|
2921
|
+
* @param packageName
|
|
2713
2922
|
*/
|
|
2714
|
-
|
|
2923
|
+
getIndexUrl: (packageName: string) => Promise<string | null>;
|
|
2715
2924
|
/**
|
|
2716
|
-
*
|
|
2925
|
+
* 获取组件包入口url信息
|
|
2926
|
+
* @param packageName
|
|
2717
2927
|
*/
|
|
2718
|
-
|
|
2719
|
-
readonly keywords: WidgetKeyword[];
|
|
2720
|
-
readonly security: boolean;
|
|
2721
|
-
readonly permissions: WidgetPermission[];
|
|
2928
|
+
getEntryUrl: (packageName: string) => Promise<string | null>;
|
|
2722
2929
|
/**
|
|
2723
|
-
*
|
|
2930
|
+
* 通过包名获取组件包信息
|
|
2931
|
+
* @param name
|
|
2724
2932
|
*/
|
|
2725
|
-
|
|
2726
|
-
readonly width: number;
|
|
2727
|
-
packageName?: string | null;
|
|
2728
|
-
readonly height: number;
|
|
2729
|
-
readonly maxWidth: number;
|
|
2933
|
+
getPackage: (name: string) => Promise<WidgetPackage | undefined>;
|
|
2730
2934
|
/**
|
|
2731
|
-
*
|
|
2935
|
+
* 获取已经安装的组件包
|
|
2732
2936
|
*/
|
|
2733
|
-
|
|
2734
|
-
readonly maxHeight: number;
|
|
2735
|
-
readonly minWidth: number;
|
|
2736
|
-
readonly minHeight: number;
|
|
2737
|
-
readonly movable: boolean;
|
|
2738
|
-
readonly singleton: boolean;
|
|
2739
|
-
readonly resizable: boolean;
|
|
2740
|
-
readonly path: string;
|
|
2741
|
-
readonly icon?: string;
|
|
2742
|
-
readonly meta: MetaInfo;
|
|
2743
|
-
readonly backgroundThrottling: boolean;
|
|
2937
|
+
getPackages: () => Promise<WidgetPackage[]>;
|
|
2744
2938
|
/**
|
|
2745
|
-
*
|
|
2939
|
+
* Install a widget package, if the package is a string, it will be treated as a path or http url to install the widget.zip file.
|
|
2940
|
+
* @param widgetPackage
|
|
2746
2941
|
*/
|
|
2747
|
-
|
|
2748
|
-
constructor(options: IPageOptions);
|
|
2942
|
+
install: (widgetPackage: WidgetPackage | string) => Promise<void>;
|
|
2749
2943
|
/**
|
|
2750
|
-
*
|
|
2751
|
-
* @param
|
|
2944
|
+
* Uninstall a widget package by package name.
|
|
2945
|
+
* @param packageName
|
|
2946
|
+
* @param clearData Whether to clear the data of the widget package, default is false.
|
|
2752
2947
|
*/
|
|
2753
|
-
|
|
2948
|
+
uninstall: (widgetPackage: WidgetPackage | string, clearData?: boolean) => Promise<void>;
|
|
2949
|
+
}
|
|
2950
|
+
type WidgetPackageApiMethods = keyof IWidgetPackageApi;
|
|
2951
|
+
/**
|
|
2952
|
+
* WidgetPackageApiEvent
|
|
2953
|
+
*/
|
|
2954
|
+
declare enum WidgetPackageApiEvent {
|
|
2754
2955
|
/**
|
|
2755
|
-
*
|
|
2756
|
-
* @param lang 语言环境,不传则获取默认标题
|
|
2956
|
+
* 组件包升级事件
|
|
2757
2957
|
*/
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2958
|
+
PACKAGE_UPGRADE = "event::cn.widgetjs.core.widget.package.upgraded",
|
|
2959
|
+
/**
|
|
2960
|
+
* 组件包安装事件
|
|
2961
|
+
*/
|
|
2962
|
+
PACKAGE_INSTALLED = "event::cn.widgetjs.core.widget.package.installed"
|
|
2762
2963
|
}
|
|
2763
2964
|
|
|
2764
|
-
|
|
2765
|
-
declare class SocialInfo {
|
|
2766
|
-
content: string;
|
|
2767
|
-
name: SocialType;
|
|
2768
|
-
constructor(name: SocialType, content: string);
|
|
2769
|
-
}
|
|
2770
|
-
interface SocialLink {
|
|
2771
|
-
name: SocialType;
|
|
2772
|
-
link: string;
|
|
2773
|
-
}
|
|
2965
|
+
declare const AppApi: IAppApi;
|
|
2774
2966
|
|
|
2775
2967
|
/**
|
|
2776
|
-
*
|
|
2777
|
-
* @see [W3C Categories](https://github.com/w3c/manifest/wiki/Categories)
|
|
2778
|
-
*/
|
|
2779
|
-
type Category = 'news' | 'photo' | 'productivity' | 'social' | 'utilities' | 'weather'
|
|
2780
|
-
/**
|
|
2781
|
-
* @deprecated
|
|
2782
|
-
*/
|
|
2783
|
-
| 'calendar' | 'fun'
|
|
2784
|
-
/**
|
|
2785
|
-
* @deprecated
|
|
2968
|
+
* WidgetApi 接口定义了一系列用于控制组件的方法,这些方法提供了组件的注册、升级、获取、打开设置页面、重新加载等功能
|
|
2786
2969
|
*/
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
interface IWidgetOptions extends IWindowSize, IPageOptions {
|
|
2790
|
-
supportDeployMode?: DeployMode;
|
|
2791
|
-
configPagePath?: string;
|
|
2970
|
+
interface IWidgetApi {
|
|
2792
2971
|
/**
|
|
2793
|
-
*
|
|
2972
|
+
* 注册组件
|
|
2973
|
+
* @param widgets
|
|
2794
2974
|
*/
|
|
2795
|
-
|
|
2796
|
-
previewImage: string;
|
|
2975
|
+
registerWidgets: (widgets: Widget[]) => Promise<void>;
|
|
2797
2976
|
/**
|
|
2798
|
-
*
|
|
2977
|
+
* @deprecated
|
|
2799
2978
|
*/
|
|
2800
|
-
|
|
2801
|
-
categories?: Category[];
|
|
2979
|
+
registerWidgetPackage: (widgetPackage: WidgetPackage) => Promise<void>;
|
|
2802
2980
|
/**
|
|
2803
|
-
*
|
|
2981
|
+
* ignore mouse events
|
|
2982
|
+
* @param widgetId
|
|
2983
|
+
* @param ignore
|
|
2804
2984
|
*/
|
|
2805
|
-
|
|
2806
|
-
description: LanguageTextMap;
|
|
2807
|
-
keywords: WidgetKeyword[];
|
|
2985
|
+
setIgnoreMouseEvents: (widgetId: string, ignore: boolean) => Promise<void>;
|
|
2808
2986
|
/**
|
|
2809
|
-
*
|
|
2987
|
+
* Check if the widget is ignoring mouse events.
|
|
2988
|
+
* @param widgetId
|
|
2810
2989
|
*/
|
|
2811
|
-
|
|
2990
|
+
isIgnoreMouseEvents: (widgetId?: string) => Promise<boolean>;
|
|
2812
2991
|
/**
|
|
2813
|
-
*
|
|
2992
|
+
* 设置组件是否可以左键拖动
|
|
2993
|
+
* @param draggable boolean true-启用左键拖动 false-禁用左键拖动
|
|
2994
|
+
* @remarks 注意:只对悬浮窗组件(DeployMode.OVERLAP)有效
|
|
2814
2995
|
*/
|
|
2815
|
-
|
|
2816
|
-
browserWindowOptions?: Pick<BrowserWindowOptions, 'backgroundThrottling'>;
|
|
2817
|
-
trayOptions?: TrayWidgetOptions;
|
|
2818
|
-
}
|
|
2819
|
-
interface IBackgroundWidgetOptions extends Omit<IWidgetOptions, 'width' | 'height'> {
|
|
2820
|
-
width?: number;
|
|
2821
|
-
height?: number;
|
|
2822
|
-
browserWindowOptions?: BrowserWindowOptions;
|
|
2823
|
-
}
|
|
2824
|
-
/**
|
|
2825
|
-
* @deprecated
|
|
2826
|
-
*/
|
|
2827
|
-
interface WidgetRoute {
|
|
2828
|
-
url: string;
|
|
2829
|
-
name: string;
|
|
2830
|
-
}
|
|
2831
|
-
interface TrayWidgetOptions {
|
|
2832
|
-
closeOnBlur?: boolean;
|
|
2833
|
-
hideOnBlur?: boolean;
|
|
2834
|
-
}
|
|
2835
|
-
declare class Widget extends Page {
|
|
2836
|
-
readonly previewImage: string;
|
|
2837
|
-
readonly categories?: Category[];
|
|
2838
|
-
readonly supportDeployMode: number;
|
|
2839
|
-
readonly trayOptions?: TrayWidgetOptions;
|
|
2996
|
+
setMouseDraggable: (draggable: boolean) => Promise<void>;
|
|
2840
2997
|
/**
|
|
2841
|
-
*
|
|
2998
|
+
* 升级组件包
|
|
2999
|
+
* @param packageName 组件包名
|
|
2842
3000
|
*/
|
|
2843
|
-
|
|
3001
|
+
upgradePackage: (packageName: string) => Promise<void>;
|
|
2844
3002
|
/**
|
|
2845
|
-
*
|
|
3003
|
+
* 获取所有组件
|
|
3004
|
+
* @return Promise<Widget[]>
|
|
2846
3005
|
*/
|
|
2847
|
-
|
|
2848
|
-
readonly synchronizable?: boolean;
|
|
3006
|
+
getWidgets: () => Promise<Widget[]>;
|
|
2849
3007
|
/**
|
|
2850
|
-
*
|
|
3008
|
+
* 通过组件名称获取组件
|
|
3009
|
+
* @param name string 组件名
|
|
3010
|
+
* @return Promise<Widget>
|
|
2851
3011
|
*/
|
|
2852
|
-
|
|
3012
|
+
getWidget: (name: string) => Promise<Widget>;
|
|
2853
3013
|
/**
|
|
3014
|
+
* @param name
|
|
2854
3015
|
* @deprecated
|
|
2855
3016
|
*/
|
|
2856
|
-
|
|
2857
|
-
protected browserWindowOptions?: BrowserWindowOptions;
|
|
2858
|
-
readonly socialLinks?: SocialLink[];
|
|
2859
|
-
constructor(options: IWidgetOptions);
|
|
2860
|
-
static parseJSON(json: string): Widget;
|
|
2861
|
-
static parseObject(obj: any): Widget;
|
|
3017
|
+
getWidgetPackage: (name: string) => Promise<WidgetPackage | undefined>;
|
|
2862
3018
|
/**
|
|
2863
|
-
*
|
|
3019
|
+
* @deprecated
|
|
2864
3020
|
*/
|
|
2865
|
-
|
|
2866
|
-
isSupportBackground(): boolean;
|
|
2867
|
-
isSupportTray(): boolean;
|
|
3021
|
+
getWidgetPackages: () => Promise<WidgetPackage[]>;
|
|
2868
3022
|
/**
|
|
2869
|
-
*
|
|
3023
|
+
* 打开组件设置页面
|
|
3024
|
+
* @param id string 组件id
|
|
2870
3025
|
*/
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
3026
|
+
openConfigPage: (id?: string) => Promise<void>;
|
|
3027
|
+
/**
|
|
3028
|
+
* @param name
|
|
3029
|
+
*/
|
|
3030
|
+
openConfigPageByName: (name: string) => Promise<void>;
|
|
3031
|
+
/**
|
|
3032
|
+
* 重新加载组件
|
|
3033
|
+
*/
|
|
3034
|
+
reload: (id?: string) => Promise<void>;
|
|
3035
|
+
/**
|
|
3036
|
+
*
|
|
3037
|
+
* @param packageName
|
|
3038
|
+
* @deprecated
|
|
3039
|
+
*/
|
|
3040
|
+
getWidgetPackageUrl: (packageName: string) => Promise<string | null>;
|
|
3041
|
+
restartWidgets: (mode?: DeployMode) => Promise<void>;
|
|
3042
|
+
updateSyncInfo: () => Promise<void>;
|
|
3043
|
+
getSyncInfo: (widgetName?: string) => Promise<WidgetSyncInfo | null>;
|
|
2888
3044
|
}
|
|
2889
3045
|
|
|
2890
3046
|
interface LocalPackageUrlInfo {
|
|
@@ -3550,139 +3706,6 @@ declare enum Channel {
|
|
|
3550
3706
|
AI = "channel::cn.widgetjs.core.ai"
|
|
3551
3707
|
}
|
|
3552
3708
|
|
|
3553
|
-
declare class WidgetParams {
|
|
3554
|
-
static readonly PARAM_PREFIX = "w_";
|
|
3555
|
-
static readonly PARAM_ID = "id";
|
|
3556
|
-
static readonly PARAM_LANG = "lang";
|
|
3557
|
-
static readonly PARAM_THEME = "theme";
|
|
3558
|
-
static readonly PARAM_MODE = "mode";
|
|
3559
|
-
static readonly PARAM_NAME = "name";
|
|
3560
|
-
static readonly PARAM_TITLE = "title";
|
|
3561
|
-
static readonly PARAM_PREVIEW = "preview";
|
|
3562
|
-
static readonly PARAMS: string[];
|
|
3563
|
-
id?: string;
|
|
3564
|
-
width?: number;
|
|
3565
|
-
widthPx?: number;
|
|
3566
|
-
heightPx?: number;
|
|
3567
|
-
height?: number;
|
|
3568
|
-
x?: number;
|
|
3569
|
-
y?: number;
|
|
3570
|
-
preview?: boolean;
|
|
3571
|
-
lang?: string;
|
|
3572
|
-
theme?: ThemeMode;
|
|
3573
|
-
mode?: DeployMode;
|
|
3574
|
-
radius?: number;
|
|
3575
|
-
name?: string;
|
|
3576
|
-
title?: string;
|
|
3577
|
-
/**
|
|
3578
|
-
* 将组件参数转为url参数
|
|
3579
|
-
* @param object
|
|
3580
|
-
* @return URLSearchParams w_w=2&w_h=2&w_id=21&w_width=156&w_height=156
|
|
3581
|
-
*/
|
|
3582
|
-
toUrlParams(): URLSearchParams;
|
|
3583
|
-
getPersistKey(): string;
|
|
3584
|
-
/**
|
|
3585
|
-
* 从当前地址解析组件参数:
|
|
3586
|
-
* http://localhost:8080/#/widget/config/labor_progress?w_w=2&w_h=2&w_width=156&w_height=156
|
|
3587
|
-
* =>
|
|
3588
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
3589
|
-
*/
|
|
3590
|
-
static fromCurrentLocation(): WidgetParams;
|
|
3591
|
-
static fromLocation(url: string): WidgetParams;
|
|
3592
|
-
private static setValue;
|
|
3593
|
-
/**
|
|
3594
|
-
* 从对象键值对中初始化组件参数
|
|
3595
|
-
* {w_width:2,w_height:2,w_id:21,w_width_px:156,w_height_px:156}=>
|
|
3596
|
-
* {width:2,height:2,id:21,width_px:156,height_px:156}
|
|
3597
|
-
* @param object
|
|
3598
|
-
*/
|
|
3599
|
-
static fromObject(object: any): WidgetParams;
|
|
3600
|
-
}
|
|
3601
|
-
declare enum ThemeMode {
|
|
3602
|
-
AUTO = "auto",
|
|
3603
|
-
LIGHT = "LIGHT",
|
|
3604
|
-
DARK = "DARK"
|
|
3605
|
-
}
|
|
3606
|
-
|
|
3607
|
-
/**
|
|
3608
|
-
* DeployedWidgetApi provides methods for managing deployed widgets within the application.
|
|
3609
|
-
* It allows for the removal, retrieval, and configuration of deployed widgets,
|
|
3610
|
-
* as well as the ability to manipulate their settings and behavior.
|
|
3611
|
-
* @remarks
|
|
3612
|
-
*/
|
|
3613
|
-
interface IDeployedWidgetApi {
|
|
3614
|
-
removeDeployedWidget: (id?: string) => Promise<void>;
|
|
3615
|
-
removeDeployedWidgetByName: (name: string) => Promise<DeployedWidget[]>;
|
|
3616
|
-
getDeployedWidgets: () => Promise<DeployedWidget[]>;
|
|
3617
|
-
openDevTools: (id: string) => Promise<void>;
|
|
3618
|
-
/**
|
|
3619
|
-
* @deprecated 使用WidgetApi.openConfigPage代替
|
|
3620
|
-
* @param id
|
|
3621
|
-
*/
|
|
3622
|
-
openConfigPage: (id?: string, params?: WidgetParams) => Promise<void>;
|
|
3623
|
-
registerActiveShortcut: (id: string, shortcut: string) => Promise<boolean>;
|
|
3624
|
-
/**
|
|
3625
|
-
* Set proxy for the widget, this will reload the widget after setting the proxy.
|
|
3626
|
-
* @param id
|
|
3627
|
-
* @param proxy
|
|
3628
|
-
*/
|
|
3629
|
-
setProxy: (id: string, proxy: string) => Promise<boolean>;
|
|
3630
|
-
getDeployedWidget: (id: string) => Promise<DeployedWidget>;
|
|
3631
|
-
/**
|
|
3632
|
-
* Adds a new widget with the specified options.
|
|
3633
|
-
* If in browser environment, it will open widget://widgetjs.cn/widget?packageUrl=xxx&name=xxx&package
|
|
3634
|
-
* @param options - The options for the widget to be added.
|
|
3635
|
-
* @returns A promise that resolves with an array of added widgets.
|
|
3636
|
-
*/
|
|
3637
|
-
addWidget: (options: AddWidgetOption) => Promise<Widget[]>;
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
interface AddWidgetOption {
|
|
3641
|
-
widgetName: string;
|
|
3642
|
-
widgetTitle?: string;
|
|
3643
|
-
deployMode: DeployMode;
|
|
3644
|
-
packageJsonUrl?: string;
|
|
3645
|
-
hostname?: string;
|
|
3646
|
-
}
|
|
3647
|
-
type DeployedWidgetApiMethods = keyof IDeployedWidgetApi;
|
|
3648
|
-
declare class DeployedWidgetApiImpl extends BaseApi<DeployedWidgetApiMethods> implements IDeployedWidgetApi {
|
|
3649
|
-
getChannel(): string;
|
|
3650
|
-
/**
|
|
3651
|
-
* 移除组件
|
|
3652
|
-
* @param id
|
|
3653
|
-
*/
|
|
3654
|
-
removeDeployedWidget(id?: string): Promise<any>;
|
|
3655
|
-
addWidget(options: AddWidgetOption): Promise<Widget[]>;
|
|
3656
|
-
/**
|
|
3657
|
-
* 通过组件名移除已添加的组件
|
|
3658
|
-
* @param name 组件名
|
|
3659
|
-
*/
|
|
3660
|
-
removeDeployedWidgetByName(name: string): Promise<DeployedWidget[]>;
|
|
3661
|
-
/**
|
|
3662
|
-
* 获取已添加的组件
|
|
3663
|
-
* @param name 组件名,可以不传
|
|
3664
|
-
*/
|
|
3665
|
-
getDeployedWidgets(name?: string): Promise<DeployedWidget[]>;
|
|
3666
|
-
getDeployedWidget(id: string): Promise<DeployedWidget>;
|
|
3667
|
-
/**
|
|
3668
|
-
* Opens the dev tools for a widget with the specified ID.
|
|
3669
|
-
*
|
|
3670
|
-
* @param {string} widgetId - The ID of the widget to open the dev tools for.
|
|
3671
|
-
* @return {Promise} A Promise that resolves when the dev tools are opened.
|
|
3672
|
-
*/
|
|
3673
|
-
openDevTools(widgetId: string): Promise<any>;
|
|
3674
|
-
openConfigPage(widgetId?: string, params?: WidgetParams): Promise<any>;
|
|
3675
|
-
/**
|
|
3676
|
-
* 注册激活、呼出、置顶组件快捷键
|
|
3677
|
-
* @param widgetId 组件id
|
|
3678
|
-
* @param shortcut 如果传空或者不传,则会取消快捷键。更多快捷键配置,请查看Accelerator用法
|
|
3679
|
-
* https://www.electronjs.org/docs/latest/api/accelerator
|
|
3680
|
-
*/
|
|
3681
|
-
registerActiveShortcut(widgetId: string, shortcut?: string): Promise<boolean>;
|
|
3682
|
-
setProxy(widgetId: string, proxy: string): Promise<boolean>;
|
|
3683
|
-
}
|
|
3684
|
-
declare const DeployedWidgetApi: DeployedWidgetApiImpl;
|
|
3685
|
-
|
|
3686
3709
|
type DeviceApiMethods = keyof IDeviceApi;
|
|
3687
3710
|
declare const DeviceApi: IDeviceApi;
|
|
3688
3711
|
|
|
@@ -4575,4 +4598,4 @@ declare class GridSystem extends GridRect {
|
|
|
4575
4598
|
getHeight(): number;
|
|
4576
4599
|
}
|
|
4577
4600
|
|
|
4578
|
-
export { type AddTrayOptions, type AddWidgetOption, AiApiEvent, type AiApiMethods, type AiConfig, type AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, type AppApiMethods, AppConfig, AppEvent, type AppMouseEvent, AppNotification, AppReminderNotification, type AppRoutes, type AppRuntimeInfo, AppTheme, type AudioData, BackgroundWidget, BaseApi, type BaseboardData, type BatteryData, type BiosData, type BlockDevicesData, type BluetoothDeviceData, BroadcastApi, type BroadcastApiMethods, BroadcastEvent, type BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, type BrowserWindowApiMethods, type BrowserWindowOptions, type CallNotificationOption, type Category, Channel, type ChassisData, ClipboardApi, ClipboardApiEvent, type ClipboardApiMethods, type CountdownNotificationOption, type CpuCacheData, type CpuCurrentSpeedData, type CpuData, type CpuTemperatureData, type CurrentLoadCpuData, type CurrentLoadData, type DeepPartial, DefaultTheme, DefaultThemeDark, DefaultThemeLight, DefaultWidgetTheme, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, type DeployedWidgetApiMethods, type DevOptions, DeviceApi, type DeviceApiMethods, DialogApi, type DialogApiMethods, type DiskLayoutData, type DisksIoData, type Display, type DisplayBalloonOptions, type DockerContainerData, type DockerContainerMountData, type DockerContainerProcessData, type DockerContainerStatsData, type DockerImageData, type DockerInfoData, type DockerVolumeData, type DownloadUrlOptions, type DynamicData, ElectronApi, ElectronUtils, FileApi, type FileApiMethods, type FsOpenFilesData, type FsSizeData, type FsStatsData, type GraphicsControllerData, type GraphicsData, type GraphicsDisplayData, Gravity, GridRect, GridSystem, HostedMode, HttpApi, type HttpApiMethods, type IAiApi, type IAppApi, type IAppTheme, type IBackgroundWidgetOptions, type IDeviceApi, type IDialogApi, type IFileApi, type IGridRect, type ILogApi, type IMouseApi, type IPage, type IPageOptions, type IProcessApi, type ITrayApi, type IUserApi, type IWidgetDataApi, type IWidgetOptions, type IWidgetPackageApi, type IWidgetTheme, type IWindowSize, type InetChecksiteData, type InfoNotificationOption, type Language, type LanguageCode, LanguageMap, type LanguageTextMap, LanguageUtils, type LocalPackageUrlInfo, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, LogApi, type LogApiMethods, type MemData, type MemLayoutData, MenuApi, MenuApiEvent, type MenuApiMethods, type MetaInfo, type Metadata, MouseApi, MouseApiEvent, type MouseApiMethods, type NativeKeyboardEvent, type NetworkConnectionsData, type NetworkInterfacesData, type NetworkStatsData, type NormalizeOptions, NotificationApi, NotificationApiEvent, type NotificationApiMethods, type NotificationOption, NotificationSize, type NotificationType, type OsData, Page, type Point, type Position, type PrinterData, ProcessApi, type ProcessApiMethods, type ProcessesData, type ProcessesProcessData, type ProcessesProcessLoadData, type ProxyConfig, type RaspberryRevisionData, type ReadDirOptions, type Rectangle, type ReminderNotificationOption, type RemotePackageUrlInfo, type SaveWidgetOption, type ServicesData, type SetPositionOptions, ShortcutApi, ShortcutApiEvent, type ShortcutApiMethods, type ShortcutDetails, type ShowMenuOption, type Size, type SmartData, SocialInfo, type SocialLink, type SocialType, type StaticData, StorageApi, type StorageApiMethods, StoreApi, type StoreApiMethods, SystemApi, SystemApiEvent, type SystemApiMethods, type SystemData, type SystemFile, type SystemInfoMethods, type SystemInfoResultMap, type ThemeColors, ThemeMode, type ThemeRadius, type ThemeShadow, type ThemeTypography, type TimeData, TrayApi, TrayApiEvent, type TrayApiMethods, type TrayWidgetOptions, type UsbData, UserApi, UserApiEvent, type UserApiMethods, type UserData, type UuidData, type VboxInfoData, type VersionData, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, type WidgetApiMethods, WidgetData, WidgetDataApi, type WidgetDataApiMethods, WidgetKeyword, type WidgetMenuItem, WidgetPackage, WidgetPackageApi, WidgetPackageApiEvent, type WidgetPackageApiMethods, type WidgetPackageOptions, WidgetPackageUtils, WidgetParams, type WidgetPermission, type WidgetRoute, type WidgetSyncInfo, WidgetTheme, type WidgetThemeKey, type WidgetThemeProperty, WidgetUtils, type WifiConnectionData, type WifiInterfaceData, type WifiNetworkData, delay, normalizeUrl, parseQuery, stringifyQuery };
|
|
4601
|
+
export { type AddTrayOptions, type AddWidgetOption, AiApiEvent, type AiApiMethods, type AiConfig, type AlignPosition, ApiConstants, AppApi, AppApiConstants, AppApiEvent, type AppApiMethods, AppConfig, AppEvent, type AppMouseEvent, AppNotification, AppReminderNotification, type AppRoutes, type AppRuntimeInfo, AppTheme, type AudioData, BackgroundWidget, BaseApi, type BaseboardData, type BatteryData, type BiosData, type BlockDevicesData, type BluetoothDeviceData, BroadcastApi, type BroadcastApiMethods, BroadcastEvent, type BroadcastEventType, BrowserWindowApi, BrowserWindowApiEvent, type BrowserWindowApiMethods, type BrowserWindowOptions, type CallNotificationOption, type Category, Channel, type ChassisData, ClipboardApi, ClipboardApiEvent, type ClipboardApiMethods, type CountdownNotificationOption, type CpuCacheData, type CpuCurrentSpeedData, type CpuData, type CpuTemperatureData, type CurrentLoadCpuData, type CurrentLoadData, type DeepPartial, DefaultTheme, DefaultThemeDark, DefaultThemeLight, DefaultWidgetTheme, DeployMode, DeployedPage, DeployedWidget, DeployedWidgetApi, DeployedWidgetApiEvent, type DeployedWidgetApiMethods, type DevOptions, DeviceApi, type DeviceApiMethods, DialogApi, type DialogApiMethods, type DiskLayoutData, type DisksIoData, type Display, type DisplayBalloonOptions, type DockerContainerData, type DockerContainerMountData, type DockerContainerProcessData, type DockerContainerStatsData, type DockerImageData, type DockerInfoData, type DockerVolumeData, type DownloadUrlOptions, type DynamicData, ElectronApi, ElectronUtils, FileApi, type FileApiMethods, type FsOpenFilesData, type FsSizeData, type FsStatsData, type GraphicsControllerData, type GraphicsData, type GraphicsDisplayData, Gravity, GridRect, GridSystem, HostedMode, HttpApi, type HttpApiMethods, type IAiApi, type IAppApi, type IAppTheme, type IBackgroundWidgetOptions, type IDeployedWidgetApi, type IDeviceApi, type IDialogApi, type IFileApi, type IGridRect, type ILogApi, type IMouseApi, type IPage, type IPageOptions, type IProcessApi, type ITrayApi, type IUserApi, type IWidgetDataApi, type IWidgetOptions, type IWidgetPackageApi, type IWidgetTheme, type IWindowSize, type InetChecksiteData, type InfoNotificationOption, type Language, type LanguageCode, LanguageMap, type LanguageTextMap, LanguageUtils, type LocalPackageUrlInfo, type LocationQuery, type LocationQueryRaw, type LocationQueryValue, type LocationQueryValueRaw, LogApi, type LogApiMethods, type MemData, type MemLayoutData, MenuApi, MenuApiEvent, type MenuApiMethods, type MetaInfo, type Metadata, MouseApi, MouseApiEvent, type MouseApiMethods, type NativeKeyboardEvent, type NetworkConnectionsData, type NetworkInterfacesData, type NetworkStatsData, type NormalizeOptions, NotificationApi, NotificationApiEvent, type NotificationApiMethods, type NotificationOption, NotificationSize, type NotificationType, type OsData, Page, type Point, type Position, type PrinterData, ProcessApi, type ProcessApiMethods, type ProcessesData, type ProcessesProcessData, type ProcessesProcessLoadData, type ProxyConfig, type RaspberryRevisionData, type ReadDirOptions, type Rectangle, type ReminderNotificationOption, type RemotePackageUrlInfo, type SaveWidgetOption, type ServicesData, type SetPositionOptions, ShortcutApi, ShortcutApiEvent, type ShortcutApiMethods, type ShortcutDetails, type ShowMenuOption, type Size, type SmartData, SocialInfo, type SocialLink, type SocialType, type StaticData, StorageApi, type StorageApiMethods, StoreApi, type StoreApiMethods, SystemApi, SystemApiEvent, type SystemApiMethods, type SystemData, type SystemFile, type SystemInfoMethods, type SystemInfoResultMap, type ThemeBoxShadow, type ThemeColors, ThemeMode, type ThemeRadius, type ThemeShadow, type ThemeTypography, type TimeData, TrayApi, TrayApiEvent, type TrayApiMethods, type TrayWidgetOptions, type UsbData, UserApi, UserApiEvent, type UserApiMethods, type UserData, type UuidData, type VboxInfoData, type VersionData, WebSocketEvent, WebSocketEventType, Widget, WidgetApi, WidgetApiEvent, type WidgetApiMethods, WidgetData, WidgetDataApi, type WidgetDataApiMethods, WidgetKeyword, type WidgetMenuItem, WidgetPackage, WidgetPackageApi, WidgetPackageApiEvent, type WidgetPackageApiMethods, type WidgetPackageOptions, WidgetPackageUtils, WidgetParams, type WidgetPermission, type WidgetRoute, type WidgetSyncInfo, WidgetTheme, type WidgetThemeKey, type WidgetThemeProperty, WidgetUtils, type WifiConnectionData, type WifiInterfaceData, type WifiNetworkData, delay, normalizeUrl, parseQuery, stringifyQuery };
|