clickgo 3.0.4-dev5 → 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/dist/lib/form.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.hide = exports.show = exports.flash = exports.setTopMost = exports.confirm = exports.dialog = exports.create = exports.remove = exports.doFocusAndPopEvent = exports.hidePop = exports.showPop = exports.removeFromPop = exports.appendToPop = exports.hideNotify = exports.notifyProgress = exports.notify = exports.hideDrag = exports.moveDrag = exports.showDrag = exports.hideRectangle = exports.showRectangle = exports.moveRectangle = exports.showCircular = exports.getRectByBorder = exports.getMaxZIndexID = exports.changeFocus = exports.getList = exports.send = exports.get = exports.getTaskId = exports.refreshMaxPosition = exports.bindDrag = exports.bindResize = exports.close = exports.max = exports.min = exports.simpleSystemTaskRoot = void 0;
12
+ exports.hideLauncher = exports.showLauncher = exports.hide = exports.show = exports.flash = exports.setTopMost = exports.confirm = exports.dialog = exports.create = exports.remove = exports.doFocusAndPopEvent = exports.hidePop = exports.showPop = exports.removeFromPop = exports.appendToPop = exports.hideNotify = exports.notifyProgress = exports.notify = exports.hideDrag = exports.moveDrag = exports.showDrag = exports.hideRectangle = exports.showRectangle = exports.moveRectangle = exports.showCircular = exports.getRectByBorder = exports.getMaxZIndexID = exports.changeFocus = exports.getList = exports.send = exports.get = exports.getTaskId = exports.refreshMaxPosition = exports.bindDrag = exports.bindResize = exports.close = exports.max = exports.min = exports.launcherRoot = exports.simpleSystemTaskRoot = void 0;
13
13
  const clickgo = require("../clickgo");
14
14
  const core = require("./core");
15
15
  const task = require("./task");
@@ -26,25 +26,29 @@ const info = {
26
26
  'ok': '好',
27
27
  'yes': '是',
28
28
  'no': '否',
29
- 'cancel': '取消'
29
+ 'cancel': '取消',
30
+ 'search': '搜索'
30
31
  },
31
32
  'tc': {
32
33
  'ok': '好',
33
34
  'yes': '是',
34
35
  'no': '否',
35
- 'cancel': '取消'
36
+ 'cancel': '取消',
37
+ 'search': '檢索'
36
38
  },
37
39
  'en': {
38
40
  'ok': 'OK',
39
41
  'yes': 'Yes',
40
42
  'no': 'No',
41
- 'cancel': 'Cancel'
43
+ 'cancel': 'Cancel',
44
+ 'search': 'Search'
42
45
  },
43
46
  'ja': {
44
47
  'ok': '好',
45
48
  'yes': 'はい',
46
49
  'no': 'いいえ',
47
- 'cancel': 'キャンセル'
50
+ 'cancel': 'キャンセル',
51
+ 'search': '検索'
48
52
  }
49
53
  }
50
54
  };
@@ -64,21 +68,16 @@ const elements = {
64
68
  'dragIcon': undefined,
65
69
  'system': document.createElement('div'),
66
70
  'simpleSystemtask': document.createElement('div'),
71
+ 'launcher': document.createElement('div'),
67
72
  'init': function () {
68
73
  this.wrap.id = 'cg-wrap';
69
74
  document.getElementsByTagName('body')[0].appendChild(this.wrap);
70
75
  if (clickgo.getNative() && (clickgo.getPlatform() === 'win32')) {
71
76
  this.wrap.addEventListener('mouseenter', function () {
72
- native.send('cg-mouse-ignore', JSON.stringify({
73
- 'token': native.getToken(),
74
- 'param': false
75
- }));
77
+ native.invoke('cg-mouse-ignore', native.getToken(), false);
76
78
  });
77
79
  this.wrap.addEventListener('mouseleave', function () {
78
- native.send('cg-mouse-ignore', JSON.stringify({
79
- 'token': native.getToken(),
80
- 'param': true
81
- }));
80
+ native.invoke('cg-mouse-ignore', native.getToken(), true);
82
81
  });
83
82
  }
84
83
  this.list.id = 'cg-form-list';
@@ -176,6 +175,183 @@ const elements = {
176
175
  }
177
176
  });
178
177
  simpletaskApp.mount('#cg-simpletask');
178
+ this.launcher.id = 'cg-launcher';
179
+ this.launcher.addEventListener('contextmenu', function (e) {
180
+ e.preventDefault();
181
+ });
182
+ this.wrap.appendChild(this.launcher);
183
+ this.launcher.addEventListener('touchmove', function (e) {
184
+ e.preventDefault();
185
+ }, {
186
+ 'passive': false
187
+ });
188
+ const waiting = function () {
189
+ if (!core.config) {
190
+ setTimeout(function () {
191
+ waiting();
192
+ }, 2000);
193
+ return;
194
+ }
195
+ const launcherApp = clickgo.vue.createApp({
196
+ 'template': `<div class="cg-launcher-search">` +
197
+ `<input v-if="folderName === ''" class="cg-launcher-sinput" :placeholder="search" v-model="name">` +
198
+ `<input v-else class="cg-launcher-foldername" :value="folderName" @change="folderNameChange">` +
199
+ `</div>` +
200
+ `<div class="cg-launcher-list" @mousedown="mousedown" @click="listClick" :class="[folderName === '' ? '' : 'cg-folder-open']">` +
201
+ `<div v-for="item of list" class="cg-launcher-item">` +
202
+ `<div class="cg-launcher-inner">` +
203
+ `<div v-if="!item.list || item.list.length === 0" class="cg-launcher-icon" :style="{'background-image': 'url(' + item.icon + ')'}" @click="iconClick($event, item)"></div>` +
204
+ `<div v-else class="cg-launcher-folder" @click="openFolder($event, item)">` +
205
+ `<div>` +
206
+ `<div v-for="sub of item.list" class="cg-launcher-item">` +
207
+ `<div class="cg-launcher-inner">` +
208
+ `<div class="cg-launcher-icon" :style="{'background-image': 'url(' + sub.icon + ')'}" @click="subIconClick($event, sub)"></div>` +
209
+ `<div class="cg-launcher-name">{{sub.name}}</div>` +
210
+ `</div>` +
211
+ `<div class="cg-launcher-space"></div>` +
212
+ `</div>` +
213
+ `</div>` +
214
+ `</div>` +
215
+ `<div class="cg-launcher-name">{{item.name}}</div>` +
216
+ `</div>` +
217
+ `<div class="cg-launcher-space"></div>` +
218
+ `</div>` +
219
+ `</div>`,
220
+ 'data': function () {
221
+ return {
222
+ 'name': '',
223
+ 'folderName': ''
224
+ };
225
+ },
226
+ 'computed': {
227
+ 'search': function () {
228
+ var _a, _b;
229
+ return (_b = (_a = info.locale[core.config.locale]) === null || _a === void 0 ? void 0 : _a.search) !== null && _b !== void 0 ? _b : info.locale['en'].search;
230
+ },
231
+ 'list': function () {
232
+ if (this.name === '') {
233
+ return core.config['launcher.list'];
234
+ }
235
+ const list = [];
236
+ for (const item of core.config['launcher.list']) {
237
+ if (item.list && item.list.length > 0) {
238
+ for (const sub of item.list) {
239
+ if (sub.name.toLowerCase().includes(this.name.toLowerCase())) {
240
+ list.push(sub);
241
+ }
242
+ }
243
+ }
244
+ else {
245
+ if (item.name.toLowerCase().includes(this.name.toLowerCase())) {
246
+ list.push(item);
247
+ }
248
+ }
249
+ }
250
+ return list;
251
+ }
252
+ },
253
+ 'methods': {
254
+ mousedown: function (e) {
255
+ this.md = e.pageX + e.pageY;
256
+ },
257
+ listClick: function (e) {
258
+ if (this.md !== e.pageX + e.pageY) {
259
+ return;
260
+ }
261
+ if (e.currentTarget !== e.target) {
262
+ return;
263
+ }
264
+ if (this.folderName === '') {
265
+ hideLauncher();
266
+ }
267
+ else {
268
+ this.closeFolder();
269
+ }
270
+ },
271
+ iconClick: function (e, item) {
272
+ return __awaiter(this, void 0, void 0, function* () {
273
+ if (this.md !== e.pageX + e.pageY) {
274
+ return;
275
+ }
276
+ hideLauncher();
277
+ yield clickgo.task.run(item.path, {
278
+ 'icon': item.icon
279
+ });
280
+ });
281
+ },
282
+ subIconClick: function (e, item) {
283
+ return __awaiter(this, void 0, void 0, function* () {
284
+ if (this.md !== e.pageX + e.pageY) {
285
+ return;
286
+ }
287
+ hideLauncher();
288
+ yield clickgo.task.run(item.path, {
289
+ 'icon': item.icon
290
+ });
291
+ });
292
+ },
293
+ closeFolder: function () {
294
+ this.folderName = '';
295
+ const el = this.folderEl;
296
+ const rect = el.parentNode.getBoundingClientRect();
297
+ el.classList.remove('cg-show');
298
+ el.style.left = (rect.left + 30).toString() + 'px';
299
+ el.style.top = rect.top.toString() + 'px';
300
+ el.style.width = '';
301
+ el.style.height = '';
302
+ setTimeout(() => {
303
+ el.style.position = '';
304
+ el.style.left = '';
305
+ el.style.top = '';
306
+ }, 150);
307
+ },
308
+ openFolder: function (e, item) {
309
+ if (this.md !== e.pageX + e.pageY) {
310
+ return;
311
+ }
312
+ if (e.currentTarget.childNodes[0] !== e.target) {
313
+ return;
314
+ }
315
+ if (this.folderName !== '') {
316
+ this.closeFolder();
317
+ return;
318
+ }
319
+ this.folderName = item.name;
320
+ this.folderItem = item;
321
+ const el = e.currentTarget.childNodes.item(0);
322
+ this.folderEl = el;
323
+ const searchEl = document.getElementsByClassName('cg-launcher-search')[0];
324
+ const rect = el.getBoundingClientRect();
325
+ el.style.left = rect.left.toString() + 'px';
326
+ el.style.top = rect.top.toString() + 'px';
327
+ el.style.position = 'fixed';
328
+ requestAnimationFrame(() => {
329
+ el.classList.add('cg-show');
330
+ el.style.left = '50px';
331
+ el.style.top = searchEl.offsetHeight.toString() + 'px';
332
+ el.style.width = 'calc(100% - 100px)';
333
+ el.style.height = 'calc(100% - 50px - ' + searchEl.offsetHeight.toString() + 'px)';
334
+ });
335
+ },
336
+ folderNameChange: function (e) {
337
+ var _a;
338
+ const input = e.target;
339
+ const val = input.value.trim();
340
+ if (val === '') {
341
+ input.value = this.folderName;
342
+ return;
343
+ }
344
+ this.folderName = val;
345
+ core.trigger('launcherFolderNameChanged', (_a = this.folderItem.id) !== null && _a !== void 0 ? _a : '', val);
346
+ }
347
+ },
348
+ 'mounted': function () {
349
+ exports.launcherRoot = this;
350
+ }
351
+ });
352
+ launcherApp.mount('#cg-launcher');
353
+ };
354
+ waiting();
179
355
  }
180
356
  };
181
357
  elements.init();
@@ -781,7 +957,7 @@ function showPop(el, pop, direction, opt = {}) {
781
957
  left = bcr.left + bcr.width - 2;
782
958
  top = bcr.top - 2;
783
959
  }
784
- if (width + left > document.body.clientWidth) {
960
+ if (width + left > window.innerWidth) {
785
961
  if (direction === 'v') {
786
962
  left = bcr.left + bcr.width - width;
787
963
  }
@@ -789,7 +965,7 @@ function showPop(el, pop, direction, opt = {}) {
789
965
  left = bcr.left - width + 2;
790
966
  }
791
967
  }
792
- if (height + top > document.body.clientHeight) {
968
+ if (height + top > window.innerHeight) {
793
969
  if (direction === 'v') {
794
970
  top = bcr.top - height;
795
971
  }
@@ -815,10 +991,10 @@ function showPop(el, pop, direction, opt = {}) {
815
991
  }
816
992
  left = x + 5;
817
993
  top = y + 7;
818
- if (width + left > document.body.clientWidth) {
994
+ if (width + left > window.innerWidth) {
819
995
  left = x - width - 5;
820
996
  }
821
- if (height + top > document.body.clientHeight) {
997
+ if (height + top > window.innerHeight) {
822
998
  top = y - height - 5;
823
999
  }
824
1000
  }
@@ -1322,6 +1498,12 @@ function create(opt) {
1322
1498
  },
1323
1499
  hide: function (fid) {
1324
1500
  clickgo.form.hide(fid !== null && fid !== void 0 ? fid : formId, taskId);
1501
+ },
1502
+ showLauncher: function () {
1503
+ clickgo.form.showLauncher();
1504
+ },
1505
+ hideLauncher: function () {
1506
+ clickgo.form.hideLauncher();
1325
1507
  }
1326
1508
  },
1327
1509
  'fs': {
@@ -1438,23 +1620,8 @@ function create(opt) {
1438
1620
  }
1439
1621
  },
1440
1622
  'native': {
1441
- getListeners: function () {
1442
- return clickgo.native.getListeners();
1443
- },
1444
- send: function (name, param, handler) {
1445
- return clickgo.native.send(name, param, handler, taskId);
1446
- },
1447
- on: function (name, handler, id, once = false) {
1448
- clickgo.native.on(name, handler, id, once, taskId);
1449
- },
1450
- once: function (name, handler, id) {
1451
- clickgo.native.once(name, handler, id, taskId);
1452
- },
1453
- off: function (name, handler) {
1454
- clickgo.native.off(name, handler, taskId);
1455
- },
1456
- clearListener: function () {
1457
- clickgo.native.clearListener(taskId);
1623
+ invoke: function (name, ...param) {
1624
+ return clickgo.native.invoke(name, ...param);
1458
1625
  },
1459
1626
  max: function () {
1460
1627
  clickgo.native.max();
@@ -2116,6 +2283,24 @@ function hide(formId, taskId) {
2116
2283
  form.vroot.$refs.form.$data.showData = false;
2117
2284
  }
2118
2285
  exports.hide = hide;
2286
+ function showLauncher() {
2287
+ elements.launcher.style.display = 'flex';
2288
+ requestAnimationFrame(function () {
2289
+ elements.launcher.classList.add('cg-show');
2290
+ });
2291
+ }
2292
+ exports.showLauncher = showLauncher;
2293
+ function hideLauncher() {
2294
+ elements.launcher.classList.remove('cg-show');
2295
+ setTimeout(function () {
2296
+ if (exports.launcherRoot.folderName !== '') {
2297
+ exports.launcherRoot.closeFolder();
2298
+ }
2299
+ exports.launcherRoot.name = '';
2300
+ elements.launcher.style.display = 'none';
2301
+ }, 300);
2302
+ }
2303
+ exports.hideLauncher = hideLauncher;
2119
2304
  window.addEventListener('resize', function () {
2120
2305
  task.refreshSystemPosition();
2121
2306
  });