@trimjs/web-app 0.1.6 → 0.2.0
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.d.ts +205 -0
- package/package.json +5 -2
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
declare interface FilePickerParams {
|
|
2
|
+
/**
|
|
3
|
+
* 是否多选
|
|
4
|
+
* @default false
|
|
5
|
+
*/
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 是否选择文件夹
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
directory?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 接受的文件类型
|
|
14
|
+
* @example
|
|
15
|
+
* accept: ['.txt', '.jpg', '.png']
|
|
16
|
+
*/
|
|
17
|
+
accept?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* 可选的范围
|
|
20
|
+
* 传入顺序决定侧边栏的顺序
|
|
21
|
+
* myFiles. 我的文件
|
|
22
|
+
* otherShare. 他人共享
|
|
23
|
+
* external. 外接存储
|
|
24
|
+
* favorites. 我的收藏
|
|
25
|
+
* storage. 存储空间(管理员)
|
|
26
|
+
*
|
|
27
|
+
* @default
|
|
28
|
+
* ['myFiles']
|
|
29
|
+
*/
|
|
30
|
+
sidebarGroup?: (
|
|
31
|
+
| "myFiles"
|
|
32
|
+
| "otherShare"
|
|
33
|
+
| "external"
|
|
34
|
+
| "remote"
|
|
35
|
+
| "favorites"
|
|
36
|
+
| "storage"
|
|
37
|
+
| "torrent"
|
|
38
|
+
| "team"
|
|
39
|
+
| string
|
|
40
|
+
)[];
|
|
41
|
+
/**
|
|
42
|
+
* 不可选的路径列表, 如果是路径也不可被展开
|
|
43
|
+
* @example
|
|
44
|
+
* disabledPaths: ['/vol1/1000/xxx', '/vol2/1000/yyy']
|
|
45
|
+
*/
|
|
46
|
+
disabledPaths?: string[];
|
|
47
|
+
/**
|
|
48
|
+
* 可选择的正则表达式(预留)
|
|
49
|
+
* @example
|
|
50
|
+
* selectablePatterns: [['\\.(torrent|bt)$', 'i']]
|
|
51
|
+
*/
|
|
52
|
+
selectablePatterns?: [string, string][];
|
|
53
|
+
/**
|
|
54
|
+
* 扩充搜索 文件类型
|
|
55
|
+
* @example
|
|
56
|
+
* expandFiles: [
|
|
57
|
+
* {
|
|
58
|
+
* title: '我的种子',
|
|
59
|
+
* extension: '.torrent',
|
|
60
|
+
* },
|
|
61
|
+
* ]
|
|
62
|
+
*/
|
|
63
|
+
expandFiles?: {
|
|
64
|
+
/**
|
|
65
|
+
* 侧边栏标题
|
|
66
|
+
*/
|
|
67
|
+
title: string;
|
|
68
|
+
/**
|
|
69
|
+
* 文件扩展名
|
|
70
|
+
*/
|
|
71
|
+
extension: string;
|
|
72
|
+
}[];
|
|
73
|
+
/**
|
|
74
|
+
* 是否允许创建文件夹
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
creatable?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 标题
|
|
80
|
+
* @default '选择文件' | '选择文件夹'
|
|
81
|
+
*/
|
|
82
|
+
title?: string;
|
|
83
|
+
/**
|
|
84
|
+
* 确认按钮文本
|
|
85
|
+
* @default '确定'
|
|
86
|
+
*/
|
|
87
|
+
okText?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare interface PlatformConfig {
|
|
91
|
+
theme: "dark" | "light";
|
|
92
|
+
language: string;
|
|
93
|
+
appVersion?: string;
|
|
94
|
+
systemVersion: string;
|
|
95
|
+
format: {
|
|
96
|
+
date?: string;
|
|
97
|
+
time?: string;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
declare interface QueryConfig {
|
|
102
|
+
timer?: boolean; // 是否是 timer 请求
|
|
103
|
+
observable?: boolean; // 是否需要 observable 对象
|
|
104
|
+
|
|
105
|
+
encrypt?: boolean;
|
|
106
|
+
timeout?: number;
|
|
107
|
+
skipPreflight?: boolean;
|
|
108
|
+
autoFailTips?: boolean;
|
|
109
|
+
failTipsPrefix?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare type ResponseData<T> = T extends undefined ? ResponseDataBase : ResponseDataBase & T;
|
|
113
|
+
|
|
114
|
+
declare interface ResponseDataBase {
|
|
115
|
+
reqid: string;
|
|
116
|
+
result: ResponseStatus;
|
|
117
|
+
taskId?: string;
|
|
118
|
+
type?: string;
|
|
119
|
+
errmsg?: string;
|
|
120
|
+
errno?: number;
|
|
121
|
+
extra?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare enum ResponseStatus {
|
|
125
|
+
SUCCESS = 'succ', // 成功
|
|
126
|
+
FAIL = 'fail', // 失败
|
|
127
|
+
CANCEL = 'cancel', // 用户取消
|
|
128
|
+
DOING = 'doing', // 任务进行中
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Trim App 实例类
|
|
133
|
+
*/
|
|
134
|
+
declare class TrimApp {
|
|
135
|
+
private options;
|
|
136
|
+
private flutterInAppWebView;
|
|
137
|
+
private osConnector;
|
|
138
|
+
private initPromise;
|
|
139
|
+
isWeb: boolean;
|
|
140
|
+
constructor(options?: TrimAppOptions);
|
|
141
|
+
private init;
|
|
142
|
+
callAppMethod<T>(fn: string, params?: string): Promise<T | null>;
|
|
143
|
+
/**
|
|
144
|
+
* 等待初始化完成
|
|
145
|
+
* @returns Promise
|
|
146
|
+
*/
|
|
147
|
+
ready(): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* 获取配置
|
|
150
|
+
*/
|
|
151
|
+
getOptions(): TrimAppOptions;
|
|
152
|
+
/**
|
|
153
|
+
* 更新配置
|
|
154
|
+
*/
|
|
155
|
+
setOptions(options: Partial<TrimAppOptions>): void;
|
|
156
|
+
/**
|
|
157
|
+
* 获取平台配置
|
|
158
|
+
*/
|
|
159
|
+
getPlatformConfig(): Promise<PlatformConfig>;
|
|
160
|
+
/**
|
|
161
|
+
* setTitle - 设置标题
|
|
162
|
+
* @param title 标题文本
|
|
163
|
+
*/
|
|
164
|
+
setTitle(title: string): Promise<unknown>;
|
|
165
|
+
/**
|
|
166
|
+
* setExitPageTips - 设置退出页面提示
|
|
167
|
+
* @param params 提示参数
|
|
168
|
+
*/
|
|
169
|
+
setExitPageTips(params?: {
|
|
170
|
+
title?: string;
|
|
171
|
+
content?: string;
|
|
172
|
+
}): Promise<unknown>;
|
|
173
|
+
/**
|
|
174
|
+
* 通过应用打开某个文件
|
|
175
|
+
*/
|
|
176
|
+
openFile(path: string): Promise<unknown>;
|
|
177
|
+
/**
|
|
178
|
+
* 打开文件管理器
|
|
179
|
+
*/
|
|
180
|
+
openFileManager(path: string): Promise<unknown>;
|
|
181
|
+
/**
|
|
182
|
+
* 关闭应用
|
|
183
|
+
*/
|
|
184
|
+
close(): Promise<unknown>;
|
|
185
|
+
/**
|
|
186
|
+
* 请求接口
|
|
187
|
+
*/
|
|
188
|
+
query<T>(params: any, config?: QueryConfig): Promise<ResponseData<T>>;
|
|
189
|
+
/**
|
|
190
|
+
* 选择文件
|
|
191
|
+
*/
|
|
192
|
+
pickFile(params: FilePickerParams): Promise<unknown>;
|
|
193
|
+
}
|
|
194
|
+
export { TrimApp }
|
|
195
|
+
export default TrimApp;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* SDK 配置选项
|
|
199
|
+
*/
|
|
200
|
+
export declare interface TrimAppOptions {
|
|
201
|
+
/** 是否开启 debug 模式,开启后会输出日志 */
|
|
202
|
+
debug?: boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export { }
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trimjs/web-app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "web app sdk for nas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
8
9
|
"scripts": {
|
|
9
10
|
"dev": "vite",
|
|
10
|
-
"build": "
|
|
11
|
+
"build": "vite build",
|
|
11
12
|
"lint": "eslint .",
|
|
12
13
|
"typecheck": "tsc --noEmit"
|
|
13
14
|
},
|
|
@@ -16,6 +17,8 @@
|
|
|
16
17
|
],
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@babel/preset-env": "^7.21.4",
|
|
20
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
21
|
+
"vite-plugin-dts": "^4.5.4",
|
|
19
22
|
"@eslint/js": "^9.13.0",
|
|
20
23
|
"@fn/micro-app-event": "workspace:*",
|
|
21
24
|
"@fn/micro-app-postmate": "workspace:*",
|