clickgo 3.0.6-dev7 → 3.0.7-dev8
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/README.md +1 -1
- package/dist/app/task/form/bar/bar.js +3 -0
- package/dist/app/task/form/bar/bar.xml +1 -1
- package/dist/global.css +1 -1
- package/dist/lib/core.js +33 -4
- package/dist/lib/core.ts +32 -3
- package/dist/lib/dom.js +6 -3
- package/dist/lib/dom.ts +6 -3
- package/dist/lib/form.js +215 -30
- package/dist/lib/form.ts +232 -42
- package/dist/lib/native.js +8 -148
- package/dist/lib/native.ts +6 -211
- package/dist/lib/task.js +3 -10
- package/dist/lib/task.ts +3 -10
- package/package.json +1 -1
- package/types/index.d.ts +15 -2
package/dist/lib/form.ts
CHANGED
|
@@ -36,6 +36,7 @@ const info: {
|
|
|
36
36
|
'yes': string;
|
|
37
37
|
'no': string;
|
|
38
38
|
'cancel': string;
|
|
39
|
+
'search': string;
|
|
39
40
|
}>;
|
|
40
41
|
} = {
|
|
41
42
|
'lastId': 0,
|
|
@@ -46,25 +47,29 @@ const info: {
|
|
|
46
47
|
'ok': '好',
|
|
47
48
|
'yes': '是',
|
|
48
49
|
'no': '否',
|
|
49
|
-
'cancel': '取消'
|
|
50
|
+
'cancel': '取消',
|
|
51
|
+
'search': '搜索'
|
|
50
52
|
},
|
|
51
53
|
'tc': {
|
|
52
54
|
'ok': '好',
|
|
53
55
|
'yes': '是',
|
|
54
56
|
'no': '否',
|
|
55
|
-
'cancel': '取消'
|
|
57
|
+
'cancel': '取消',
|
|
58
|
+
'search': '檢索'
|
|
56
59
|
},
|
|
57
60
|
'en': {
|
|
58
61
|
'ok': 'OK',
|
|
59
62
|
'yes': 'Yes',
|
|
60
63
|
'no': 'No',
|
|
61
|
-
'cancel': 'Cancel'
|
|
64
|
+
'cancel': 'Cancel',
|
|
65
|
+
'search': 'Search'
|
|
62
66
|
},
|
|
63
67
|
'ja': {
|
|
64
68
|
'ok': '好',
|
|
65
69
|
'yes': 'はい',
|
|
66
70
|
'no': 'いいえ',
|
|
67
|
-
'cancel': 'キャンセル'
|
|
71
|
+
'cancel': 'キャンセル',
|
|
72
|
+
'search': '検索'
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
};
|
|
@@ -84,6 +89,7 @@ const popInfo: {
|
|
|
84
89
|
};
|
|
85
90
|
|
|
86
91
|
export let simpleSystemTaskRoot: types.IVue;
|
|
92
|
+
export let launcherRoot: types.IVue;
|
|
87
93
|
const elements: {
|
|
88
94
|
'wrap': HTMLDivElement;
|
|
89
95
|
'list': HTMLDivElement;
|
|
@@ -95,6 +101,7 @@ const elements: {
|
|
|
95
101
|
'dragIcon'?: HTMLElement;
|
|
96
102
|
'system': HTMLElement;
|
|
97
103
|
'simpleSystemtask': HTMLDivElement;
|
|
104
|
+
'launcher': HTMLDivElement;
|
|
98
105
|
'init': () => void;
|
|
99
106
|
} = {
|
|
100
107
|
'wrap': document.createElement('div'),
|
|
@@ -107,22 +114,17 @@ const elements: {
|
|
|
107
114
|
'dragIcon': undefined,
|
|
108
115
|
'system': document.createElement('div'),
|
|
109
116
|
'simpleSystemtask': document.createElement('div'),
|
|
117
|
+
'launcher': document.createElement('div'),
|
|
110
118
|
'init': function() {
|
|
111
119
|
/** --- clickgo 所有的 div wrap --- */
|
|
112
120
|
this.wrap.id = 'cg-wrap';
|
|
113
121
|
document.getElementsByTagName('body')[0].appendChild(this.wrap);
|
|
114
122
|
if (clickgo.getNative() && (clickgo.getPlatform() === 'win32')) {
|
|
115
123
|
this.wrap.addEventListener('mouseenter', function() {
|
|
116
|
-
native.
|
|
117
|
-
'token': native.getToken(),
|
|
118
|
-
'param': false
|
|
119
|
-
}));
|
|
124
|
+
native.invoke('cg-mouse-ignore', native.getToken(), false);
|
|
120
125
|
});
|
|
121
126
|
this.wrap.addEventListener('mouseleave', function() {
|
|
122
|
-
native.
|
|
123
|
-
'token': native.getToken(),
|
|
124
|
-
'param': true
|
|
125
|
-
}));
|
|
127
|
+
native.invoke('cg-mouse-ignore', native.getToken(), true);
|
|
126
128
|
});
|
|
127
129
|
}
|
|
128
130
|
|
|
@@ -242,6 +244,192 @@ const elements: {
|
|
|
242
244
|
}
|
|
243
245
|
});
|
|
244
246
|
simpletaskApp.mount('#cg-simpletask');
|
|
247
|
+
|
|
248
|
+
// --- cg-launcher ---
|
|
249
|
+
this.launcher.id = 'cg-launcher';
|
|
250
|
+
this.launcher.addEventListener('contextmenu', function(e): void {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
});
|
|
253
|
+
this.wrap.appendChild(this.launcher);
|
|
254
|
+
this.launcher.addEventListener('touchmove', function(e): void {
|
|
255
|
+
// --- 防止拖动时整个网页跟着动 ---
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
}, {
|
|
258
|
+
'passive': false
|
|
259
|
+
});
|
|
260
|
+
// --- Vue 挂载在这里 ---
|
|
261
|
+
const waiting = function(): void {
|
|
262
|
+
// --- 必须在这里执行,要不然 computed 无法更新,因为 core 还没加载进来 ---
|
|
263
|
+
if (!core.config) {
|
|
264
|
+
setTimeout(function() {
|
|
265
|
+
waiting();
|
|
266
|
+
}, 2000);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const launcherApp = clickgo.vue.createApp({
|
|
270
|
+
'template': `<div class="cg-launcher-search">` +
|
|
271
|
+
`<input v-if="folderName === ''" class="cg-launcher-sinput" :placeholder="search" v-model="name">` +
|
|
272
|
+
`<input v-else class="cg-launcher-foldername" :value="folderName" @change="folderNameChange">` +
|
|
273
|
+
`</div>` +
|
|
274
|
+
`<div class="cg-launcher-list" @mousedown="mousedown" @click="listClick" :class="[folderName === '' ? '' : 'cg-folder-open']">` +
|
|
275
|
+
`<div v-for="item of list" class="cg-launcher-item">` +
|
|
276
|
+
`<div class="cg-launcher-inner">` +
|
|
277
|
+
`<div v-if="!item.list || item.list.length === 0" class="cg-launcher-icon" :style="{'background-image': 'url(' + item.icon + ')'}" @click="iconClick($event, item)"></div>` +
|
|
278
|
+
`<div v-else class="cg-launcher-folder" @click="openFolder($event, item)">` +
|
|
279
|
+
`<div>` +
|
|
280
|
+
`<div v-for="sub of item.list" class="cg-launcher-item">` +
|
|
281
|
+
`<div class="cg-launcher-inner">` +
|
|
282
|
+
`<div class="cg-launcher-icon" :style="{'background-image': 'url(' + sub.icon + ')'}" @click="subIconClick($event, sub)"></div>` +
|
|
283
|
+
`<div class="cg-launcher-name">{{sub.name}}</div>` +
|
|
284
|
+
`</div>` +
|
|
285
|
+
`<div class="cg-launcher-space"></div>` +
|
|
286
|
+
`</div>` +
|
|
287
|
+
`</div>` +
|
|
288
|
+
`</div>` +
|
|
289
|
+
`<div class="cg-launcher-name">{{item.name}}</div>` +
|
|
290
|
+
`</div>` +
|
|
291
|
+
`<div class="cg-launcher-space"></div>` +
|
|
292
|
+
`</div>` +
|
|
293
|
+
`</div>`,
|
|
294
|
+
'data': function() {
|
|
295
|
+
return {
|
|
296
|
+
'name': '',
|
|
297
|
+
'folderName': ''
|
|
298
|
+
};
|
|
299
|
+
},
|
|
300
|
+
'computed': {
|
|
301
|
+
'search': function() {
|
|
302
|
+
return info.locale[core.config.locale]?.search ?? info.locale['en'].search;
|
|
303
|
+
},
|
|
304
|
+
'list': function(this: types.IVue) {
|
|
305
|
+
if (this.name === '') {
|
|
306
|
+
return core.config['launcher.list'];
|
|
307
|
+
}
|
|
308
|
+
const list = [];
|
|
309
|
+
for (const item of core.config['launcher.list']) {
|
|
310
|
+
if (item.list && item.list.length > 0) {
|
|
311
|
+
for (const sub of item.list) {
|
|
312
|
+
if (sub.name.toLowerCase().includes(this.name.toLowerCase())) {
|
|
313
|
+
list.push(sub);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else {
|
|
318
|
+
if (item.name.toLowerCase().includes(this.name.toLowerCase())) {
|
|
319
|
+
list.push(item);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return list;
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
'methods': {
|
|
327
|
+
mousedown: function(this: types.IVue, e: MouseEvent): void {
|
|
328
|
+
this.md = e.pageX + e.pageY;
|
|
329
|
+
},
|
|
330
|
+
listClick: function(this: types.IVue, e: MouseEvent) {
|
|
331
|
+
if (this.md !== e.pageX + e.pageY) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (e.currentTarget !== e.target) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (this.folderName === '') {
|
|
338
|
+
hideLauncher();
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
this.closeFolder();
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
iconClick: async function(
|
|
345
|
+
this: types.IVue,
|
|
346
|
+
e: MouseEvent,
|
|
347
|
+
item: types.IConfigLauncherItem
|
|
348
|
+
): Promise<void> {
|
|
349
|
+
if (this.md !== e.pageX + e.pageY) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
hideLauncher();
|
|
353
|
+
await clickgo.task.run(item.path!, {
|
|
354
|
+
'icon': item.icon
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
subIconClick: async function(
|
|
358
|
+
this: types.IVue,
|
|
359
|
+
e: MouseEvent,
|
|
360
|
+
item: types.IConfigLauncherItem
|
|
361
|
+
): Promise<void> {
|
|
362
|
+
if (this.md !== e.pageX + e.pageY) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
hideLauncher();
|
|
366
|
+
await clickgo.task.run(item.path!, {
|
|
367
|
+
'icon': item.icon
|
|
368
|
+
});
|
|
369
|
+
},
|
|
370
|
+
closeFolder: function(this: types.IVue): void {
|
|
371
|
+
// --- 关闭文件夹 ---
|
|
372
|
+
this.folderName = '';
|
|
373
|
+
const el = this.folderEl as HTMLDivElement;
|
|
374
|
+
const rect = (el.parentNode as HTMLDivElement).getBoundingClientRect();
|
|
375
|
+
el.classList.remove('cg-show');
|
|
376
|
+
el.style.left = (rect.left + 30).toString() + 'px';
|
|
377
|
+
el.style.top = rect.top.toString() + 'px';
|
|
378
|
+
el.style.width = '';
|
|
379
|
+
el.style.height = '';
|
|
380
|
+
setTimeout(() => {
|
|
381
|
+
el.style.position = '';
|
|
382
|
+
el.style.left = '';
|
|
383
|
+
el.style.top = '';
|
|
384
|
+
}, 150);
|
|
385
|
+
},
|
|
386
|
+
openFolder: function(this: types.IVue, e: MouseEvent, item: types.IConfigLauncherItem): void {
|
|
387
|
+
if (this.md !== e.pageX + e.pageY) {
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if ((e.currentTarget as HTMLElement).childNodes[0] !== e.target) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (this.folderName !== '') {
|
|
394
|
+
this.closeFolder();
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
this.folderName = item.name;
|
|
398
|
+
this.folderItem = item;
|
|
399
|
+
const el = (e.currentTarget as HTMLDivElement).childNodes.item(0) as HTMLDivElement;
|
|
400
|
+
this.folderEl = el;
|
|
401
|
+
const searchEl = document.getElementsByClassName('cg-launcher-search')[0] as HTMLDivElement;
|
|
402
|
+
const rect = el.getBoundingClientRect();
|
|
403
|
+
el.style.left = rect.left.toString() + 'px';
|
|
404
|
+
el.style.top = rect.top.toString() + 'px';
|
|
405
|
+
el.style.position = 'fixed';
|
|
406
|
+
requestAnimationFrame(() => {
|
|
407
|
+
el.classList.add('cg-show');
|
|
408
|
+
el.style.left = '50px';
|
|
409
|
+
el.style.top = searchEl.offsetHeight.toString() + 'px';
|
|
410
|
+
el.style.width = 'calc(100% - 100px)';
|
|
411
|
+
el.style.height = 'calc(100% - 50px - ' + searchEl.offsetHeight.toString() + 'px)';
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
folderNameChange: function(this: types.IVue, e: InputEvent): void {
|
|
415
|
+
const input = e.target as HTMLInputElement;
|
|
416
|
+
const val = input.value.trim();
|
|
417
|
+
if (val === '') {
|
|
418
|
+
input.value = this.folderName;
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
this.folderName = val;
|
|
422
|
+
// --- 触发 folder name change 事件 ---
|
|
423
|
+
core.trigger('launcherFolderNameChanged', this.folderItem.id ?? '', val);
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
'mounted': function(this: types.IVue): void {
|
|
427
|
+
launcherRoot = this;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
launcherApp.mount('#cg-launcher');
|
|
431
|
+
};
|
|
432
|
+
waiting();
|
|
245
433
|
}
|
|
246
434
|
};
|
|
247
435
|
elements.init();
|
|
@@ -1620,6 +1808,12 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
|
|
|
1620
1808
|
},
|
|
1621
1809
|
hide: function(fid?: number): void {
|
|
1622
1810
|
clickgo.form.hide(fid ?? formId, taskId);
|
|
1811
|
+
},
|
|
1812
|
+
showLauncher: function(): void {
|
|
1813
|
+
clickgo.form.showLauncher();
|
|
1814
|
+
},
|
|
1815
|
+
hideLauncher: function(): void {
|
|
1816
|
+
clickgo.form.hideLauncher();
|
|
1623
1817
|
}
|
|
1624
1818
|
},
|
|
1625
1819
|
'fs': {
|
|
@@ -1739,36 +1933,8 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
|
|
|
1739
1933
|
}
|
|
1740
1934
|
},
|
|
1741
1935
|
'native': {
|
|
1742
|
-
|
|
1743
|
-
return clickgo.native.
|
|
1744
|
-
},
|
|
1745
|
-
send: function(
|
|
1746
|
-
name: string,
|
|
1747
|
-
param?: string,
|
|
1748
|
-
handler?: (param?: string) => void | Promise<void>
|
|
1749
|
-
): number {
|
|
1750
|
-
return clickgo.native.send(name, param, handler, taskId);
|
|
1751
|
-
},
|
|
1752
|
-
on: function(
|
|
1753
|
-
name: string,
|
|
1754
|
-
handler: (param?: string) => void | Promise<void>,
|
|
1755
|
-
id?: number,
|
|
1756
|
-
once: boolean = false
|
|
1757
|
-
): void {
|
|
1758
|
-
clickgo.native.on(name, handler, id, once, taskId);
|
|
1759
|
-
},
|
|
1760
|
-
once: function(
|
|
1761
|
-
name: string,
|
|
1762
|
-
handler: (param?: string) => void | Promise<void>,
|
|
1763
|
-
id?: number
|
|
1764
|
-
): void {
|
|
1765
|
-
clickgo.native.once(name, handler, id, taskId);
|
|
1766
|
-
},
|
|
1767
|
-
off: function(name: string, handler: (param?: string) => void | Promise<void>): void {
|
|
1768
|
-
clickgo.native.off(name, handler, taskId);
|
|
1769
|
-
},
|
|
1770
|
-
clearListener: function(): void {
|
|
1771
|
-
clickgo.native.clearListener(taskId);
|
|
1936
|
+
invoke: function(name: string, ...param: any[]): any {
|
|
1937
|
+
return clickgo.native.invoke(name, ...param);
|
|
1772
1938
|
},
|
|
1773
1939
|
max: function(): void {
|
|
1774
1940
|
clickgo.native.max();
|
|
@@ -2509,6 +2675,30 @@ export function hide(formId?: number, taskId?: number): void {
|
|
|
2509
2675
|
form.vroot.$refs.form.$data.showData = false;
|
|
2510
2676
|
}
|
|
2511
2677
|
|
|
2678
|
+
/**
|
|
2679
|
+
* --- 显示 launcher 界面 ---
|
|
2680
|
+
*/
|
|
2681
|
+
export function showLauncher(): void {
|
|
2682
|
+
elements.launcher.style.display = 'flex';
|
|
2683
|
+
requestAnimationFrame(function() {
|
|
2684
|
+
elements.launcher.classList.add('cg-show');
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
|
|
2688
|
+
/**
|
|
2689
|
+
* --- 隐藏 launcher 界面 ---
|
|
2690
|
+
*/
|
|
2691
|
+
export function hideLauncher(): void {
|
|
2692
|
+
elements.launcher.classList.remove('cg-show');
|
|
2693
|
+
setTimeout(function() {
|
|
2694
|
+
if (launcherRoot.folderName !== '') {
|
|
2695
|
+
launcherRoot.closeFolder();
|
|
2696
|
+
}
|
|
2697
|
+
launcherRoot.name = '';
|
|
2698
|
+
elements.launcher.style.display = 'none';
|
|
2699
|
+
}, 300);
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2512
2702
|
// --- 绑定 resize 事件 ---
|
|
2513
2703
|
window.addEventListener('resize', function(): void {
|
|
2514
2704
|
// --- 触发 screenResize 事件 ---
|
package/dist/lib/native.js
CHANGED
|
@@ -1,172 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.size = exports.restore = exports.min = exports.max = exports.invoke = exports.getToken = void 0;
|
|
4
4
|
const clickgo = require("../clickgo");
|
|
5
|
-
let sendId = 0;
|
|
6
|
-
let sendList = [];
|
|
7
|
-
const listeners = {};
|
|
8
5
|
const token = (Math.random() * 100000000000000 * (100 + Math.round(Math.random() * (999 - 100)))).toString(32);
|
|
9
6
|
function getToken() {
|
|
10
7
|
return token;
|
|
11
8
|
}
|
|
12
9
|
exports.getToken = getToken;
|
|
13
|
-
function
|
|
14
|
-
const list = [];
|
|
15
|
-
for (const name in listeners) {
|
|
16
|
-
for (const item of listeners[name]) {
|
|
17
|
-
list.push({
|
|
18
|
-
'id': item.id,
|
|
19
|
-
'name': name,
|
|
20
|
-
'once': item.once,
|
|
21
|
-
'taskId': item.taskId
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return list;
|
|
26
|
-
}
|
|
27
|
-
exports.getListeners = getListeners;
|
|
28
|
-
function send(name, param, handler, taskId) {
|
|
29
|
-
if (!clickgo.getNative()) {
|
|
30
|
-
return 0;
|
|
31
|
-
}
|
|
32
|
-
const id = ++sendId;
|
|
33
|
-
sendList.push({
|
|
34
|
-
'id': id,
|
|
35
|
-
'name': name,
|
|
36
|
-
'param': param
|
|
37
|
-
});
|
|
38
|
-
if (handler) {
|
|
39
|
-
on(name, handler, id, true, taskId);
|
|
40
|
-
}
|
|
41
|
-
return id;
|
|
42
|
-
}
|
|
43
|
-
exports.send = send;
|
|
44
|
-
function on(name, handler, id, once = false, taskId) {
|
|
10
|
+
function invoke(name, ...param) {
|
|
45
11
|
if (!clickgo.getNative()) {
|
|
46
12
|
return;
|
|
47
13
|
}
|
|
48
|
-
|
|
49
|
-
listeners[name] = [];
|
|
50
|
-
}
|
|
51
|
-
listeners[name].push({
|
|
52
|
-
'id': id !== null && id !== void 0 ? id : 0,
|
|
53
|
-
'once': once,
|
|
54
|
-
'taskId': taskId,
|
|
55
|
-
'handler': handler
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
exports.on = on;
|
|
59
|
-
function once(name, handler, id, taskId) {
|
|
60
|
-
on(name, handler, id, true, taskId);
|
|
14
|
+
return window.clickgoNative.invoke(name, ...param);
|
|
61
15
|
}
|
|
62
|
-
exports.
|
|
63
|
-
function off(name, handler, taskId) {
|
|
64
|
-
if (!listeners[name]) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
for (let i = 0; i < listeners[name].length; ++i) {
|
|
68
|
-
if (listeners[name][i].handler !== handler) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (taskId && (listeners[name][i].taskId !== taskId)) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
listeners[name].splice(i, 1);
|
|
75
|
-
if (listeners[name].length === 0) {
|
|
76
|
-
delete listeners[name];
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
--i;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.off = off;
|
|
83
|
-
function clearListener(taskId) {
|
|
84
|
-
if (!taskId) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
for (const name in listeners) {
|
|
88
|
-
for (let i = 0; i < listeners[name].length; ++i) {
|
|
89
|
-
if (listeners[name][i].taskId !== taskId) {
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
listeners[name].splice(i, 1);
|
|
93
|
-
if (listeners[name].length === 0) {
|
|
94
|
-
delete listeners[name];
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.clearListener = clearListener;
|
|
16
|
+
exports.invoke = invoke;
|
|
101
17
|
function max() {
|
|
102
|
-
|
|
103
|
-
'token': token,
|
|
104
|
-
'state': 'max'
|
|
105
|
-
}));
|
|
18
|
+
invoke('cg-set-state', token, 'max');
|
|
106
19
|
}
|
|
107
20
|
exports.max = max;
|
|
108
21
|
function min() {
|
|
109
|
-
|
|
110
|
-
'token': token,
|
|
111
|
-
'state': 'min'
|
|
112
|
-
}));
|
|
22
|
+
invoke('cg-set-state', token, 'min');
|
|
113
23
|
}
|
|
114
24
|
exports.min = min;
|
|
115
25
|
function restore() {
|
|
116
|
-
|
|
117
|
-
'token': token,
|
|
118
|
-
'state': 'restore'
|
|
119
|
-
}));
|
|
26
|
+
invoke('cg-set-state', token, 'restore');
|
|
120
27
|
}
|
|
121
28
|
exports.restore = restore;
|
|
122
29
|
function size(width, height) {
|
|
123
|
-
|
|
124
|
-
'token': token,
|
|
125
|
-
'width': width,
|
|
126
|
-
'height': height
|
|
127
|
-
}));
|
|
30
|
+
invoke('cg-set-size', token, width, height);
|
|
128
31
|
}
|
|
129
32
|
exports.size = size;
|
|
130
|
-
function cgInnerGetSends() {
|
|
131
|
-
const json = JSON.stringify(sendList);
|
|
132
|
-
sendList = [];
|
|
133
|
-
return json;
|
|
134
|
-
}
|
|
135
|
-
exports.cgInnerGetSends = cgInnerGetSends;
|
|
136
|
-
function cgInnerReceive(id, name, result) {
|
|
137
|
-
if (!listeners[name]) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
for (let i = 0; i < listeners[name].length; ++i) {
|
|
141
|
-
const item = listeners[name][i];
|
|
142
|
-
if (item.id > 0) {
|
|
143
|
-
if (item.id !== id) {
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
const r = item.handler(result);
|
|
147
|
-
if (r instanceof Promise) {
|
|
148
|
-
r.catch(function (e) {
|
|
149
|
-
console.log(e);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
const r = item.handler(result);
|
|
155
|
-
if (r instanceof Promise) {
|
|
156
|
-
r.catch(function (e) {
|
|
157
|
-
console.log(e);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (item.once) {
|
|
162
|
-
listeners[name].splice(i, 1);
|
|
163
|
-
--i;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.cgInnerReceive = cgInnerReceive;
|
|
168
|
-
window.clickGoNative = {
|
|
169
|
-
isReady: true,
|
|
170
|
-
cgInnerGetSends: cgInnerGetSends,
|
|
171
|
-
cgInnerReceive: cgInnerReceive
|
|
172
|
-
};
|