clickgo 3.0.1-dev2 → 3.0.2-dev3

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.
@@ -16,6 +16,9 @@
16
16
  "/package/locale/ja": "ja"
17
17
  },
18
18
  "main": "/package/form/bar/bar",
19
+ "native": {
20
+ "state": "max"
21
+ },
19
22
 
20
23
  "files": [
21
24
  "/form/bar/bar.js",
package/dist/clickgo.js CHANGED
@@ -1,16 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zip = exports.tool = exports.theme = exports.task = exports.native = exports.fs = exports.form = exports.dom = exports.core = exports.control = exports.vue = exports.getCdn = exports.setCdn = exports.getSafe = exports.setSafe = exports.getNative = exports.getVersion = void 0;
3
+ exports.zip = exports.tool = exports.theme = exports.task = exports.native = exports.fs = exports.form = exports.dom = exports.core = exports.control = exports.vue = exports.getCdn = exports.setCdn = exports.getSafe = exports.setSafe = exports.getPlatform = exports.getNative = exports.getVersion = void 0;
4
4
  const version = '3.0.0';
5
5
  function getVersion() {
6
6
  return version;
7
7
  }
8
8
  exports.getVersion = getVersion;
9
- const native = navigator.userAgent.toLowerCase().includes('electron') ? true : false;
9
+ const native = navigator.userAgent.includes('electron') ? true : false;
10
10
  function getNative() {
11
11
  return native;
12
12
  }
13
13
  exports.getNative = getNative;
14
+ let platform = 'web';
15
+ if (native) {
16
+ const reg = /electron\/(.+?) (.+?)\//.exec(navigator.userAgent);
17
+ if (reg) {
18
+ platform = reg[2];
19
+ }
20
+ }
21
+ function getPlatform() {
22
+ return platform;
23
+ }
24
+ exports.getPlatform = getPlatform;
14
25
  let safe = true;
15
26
  function setSafe(val) {
16
27
  safe = val;
package/dist/clickgo.ts CHANGED
@@ -18,11 +18,22 @@ export function getVersion(): string {
18
18
  return version;
19
19
  }
20
20
 
21
- const native = navigator.userAgent.toLowerCase().includes('electron') ? true : false;
21
+ const native = navigator.userAgent.includes('electron') ? true : false;
22
22
  export function getNative(): boolean {
23
23
  return native;
24
24
  }
25
25
 
26
+ let platform: NodeJS.Platform | 'web' = 'web';
27
+ if (native) {
28
+ const reg = /electron\/(.+?) (.+?)\//.exec(navigator.userAgent);
29
+ if (reg) {
30
+ platform = reg[2] as any;
31
+ }
32
+ }
33
+ export function getPlatform(): NodeJS.Platform | 'web' {
34
+ return platform;
35
+ }
36
+
26
37
  let safe = true;
27
38
  export function setSafe(val: boolean): void {
28
39
  safe = val;
Binary file
Binary file
Binary file
Binary file
Binary file
package/dist/global.css CHANGED
@@ -1 +1 @@
1
- #cg-wrap{--cg:hsl(20, 100%, 70%);--success:hsl(150, 100%, 40%);--success-hover:hsl(150, 100%, 45%);--success-active:hsl(150, 100%, 30%);--success-focus:hsl(150, 100%, 35%);--success-disabled:hsl(150, 0%, 40%);--info:hsl(210, 100%, 50%);--info-hover:hsl(210, 100%, 60%);--info-active:hsl(210, 100%, 40%);--info-focus:hsl(210, 100%, 45%);--info-disabled:hsl(210, 0%, 50%);--warning:hsl(20, 100%, 70%);--warning-hover:hsl(20, 100%, 80%);--warning-active:hsl(20, 100%, 60%);--warning-focus:hsl(20, 100%, 65%);--warning-disabled:hsl(20, 0%, 70%);--danger:hsl(350, 100%, 50%);--danger-hover:hsl(350, 100%, 70%);--danger-active:hsl(350, 100%, 40%);--danger-focus:hsl(350, 100%, 45%);--danger-disabled:hsl(350, 0%, 50%);--system-color:hsl(0, 0%, 95%);--system-background:hsla(0, 0%, 0%, .5);--face:hsl(0, 0%, 95%);--g-color:hsl(0, 0%, 20%);--g-color-hover:hsl(0, 0%, 30%);--g-color-active:hsl(0, 0%, 10%);--g-color-focus:hsl(0, 0%, 15%);--g-color-disabled:hsl(0, 0%, 60%);--g-background:hsl(0, 0%, 95%);--g-background-hover:hsl(0, 0%, 100%);--g-background-active:hsl(0, 0%, 85%);--g-background-kp:hsl(0, 0%, 80%);--g-background-opacity:hsl(0, 0%, 50%, .2);--g-background-focus:hsl(0, 0%, 97.5%);--g-background-disabled:hsl(0, 0%, 75%);--g-border-color:hsl(0, 0%, 40%);--g-border-color-hover:hsl(0, 0%, 50%);--g-border-color-active:hsl(0, 0%, 30%);--g-border-color-focus:hsl(0, 0%, 35%);--g-border-color-disabled:hsl(0, 0%, 60%);--g-plain-color:var(--g-color);--g-plain-color-hover:var(--g-color-hover);--g-plain-color-active:var(--g-color-active);--g-plain-color-focus:var(--g-color-focus);--g-plain-color-disabled:var(--g-color-disabled);--g-plain-background:hsl(0, 0%, 100%);--g-plain-background-hover:hsl(0, 0%, 98%);--g-plain-background-active:hsl(0, 0%, 95%);--g-plain-background-focus:var(--g-plain-background);--g-plain-background-disabled:hsl(0, 0%, 95%);--g-plain-border-color:hsl(0, 0%, 70%);--g-plain-border-color-hover:hsl(0, 0%, 80%);--g-plain-border-color-active:hsl(0, 0%, 60%);--g-plain-border-color-focus:hsl(0, 0%, 65%);--g-plain-border-color-disabled:hsl(0, 0%, 60%)}#cg-form-list{z-index:20020000}#cg-pop-list{z-index:20020001}#cg-simpletask{z-index:20020002}#cg-system{z-index:20020003}#cg-rectangle{z-index:20020004;box-sizing:border-box;position:fixed;border-radius:3px;box-shadow:0 0 10px rgba(0,0,0,.25);background:rgba(255,255,255,.05);pointer-events:none;opacity:0}#cg-circular{z-index:20020004;box-sizing:border-box;position:fixed;border:solid 3px var(--cg);border-radius:50%;filter:drop-shadow(0 0 3px var(--cg));pointer-events:none;opacity:0}#cg-gesture{z-index:20020004;box-sizing:border-box;position:fixed;border-radius:50%;pointer-events:none;opacity:0;background:var(--system-background);box-shadow:0 5px 20px rgba(0,0,0,.25);transform:scale(0);width:20px;height:20px}#cg-gesture.done{background:rgba(255,255,255,.3);border:solid 3px rgba(0,0,0,.3)}#cg-drag{box-sizing:border-box;position:fixed;border-radius:3px;z-index:20020004;pointer-events:none;background:var(--system-background);box-shadow:0 5px 20px rgba(0,0,0,.25);opacity:0;display:flex;justify-content:center;align-items:center}[data-cg-pop]{position:fixed;box-shadow:0px 5px 20px rgba(0,0,0,.25);transition:.1s ease-out;transition-property:transform,opacity;transform:translateY(-10px);opacity:0}[data-cg-pop]:not([data-cg-open]){pointer-events:none}[data-cg-pop][data-cg-open]{transform:translateY(0px);opacity:1}.cg-system-notify{background:var(--system-background);position:fixed;padding:15px;border-radius:3px;right:0;top:0;width:280px;font-size:14px;display:flex;transition:.1s ease-out;transition-property:transform,opacity;overflow:hidden;color:#f6f6f6;box-shadow:0 5px 20px rgba(0,0,0,.25);-webkit-backdrop-filter:blur(30px) brightness(1.1);backdrop-filter:blur(30px) brightness(1.1)}.cg-system-icon{margin-right:10px;width:16px;height:16px;border-radius:50%}.cg-system-icon.cg-primary{background:var(--success)}.cg-system-icon.cg-info{background:var(--info)}.cg-system-icon.cg-warning{background:var(--warning)}.cg-system-icon.cg-danger{background:var(--danger)}.cg-system-icon.cg-progress{background:var(--cg)}.cg-system-notify-title{font-size:16px;font-weight:bold;padding-bottom:10px}.cg-system-notify-content{line-height:1.5;word-break:break-word}.cg-system-notify-progress{position:absolute;bottom:0;left:0;border-radius:1px;background:var(--cg);transition:width 1s ease-out;width:0%;height:2px}#cg-simpletask{bottom:-46px;width:100%;height:46px;top:initial;background:var(--system-background);-webkit-backdrop-filter:blur(30px) brightness(1.1);backdrop-filter:blur(30px) brightness(1.1);padding:5px 0 5px 5px;display:flex;color:var(--system-color);transition:bottom .1s ease-out;overflow-x:auto}#cg-simpletask::-webkit-scrollbar{display:none}.cg-simpletask-item{background:rgba(0,0,0,.05);border-radius:3px;padding:10px;display:flex;align-items:center;margin-right:5px}.cg-simpletask-item:hover{background:rgba(0,0,0,.1)}.cg-simpletask-item:active{background:rgba(0,0,0,.2)}.cg-simpletask-icon{margin-right:5px;background-size:cover;width:16px;height:16px}
1
+ #cg-wrap{--cg:hsl(20, 100%, 65%);--success:hsl(150, 100%, 40%);--success-hover:hsl(150, 100%, 45%);--success-active:hsl(150, 100%, 30%);--success-focus:hsl(150, 100%, 35%);--success-disabled:hsl(150, 0%, 40%);--info:hsl(210, 100%, 50%);--info-hover:hsl(210, 100%, 60%);--info-active:hsl(210, 100%, 40%);--info-focus:hsl(210, 100%, 45%);--info-disabled:hsl(210, 0%, 50%);--warning:hsl(20, 100%, 70%);--warning-hover:hsl(20, 100%, 80%);--warning-active:hsl(20, 100%, 60%);--warning-focus:hsl(20, 100%, 65%);--warning-disabled:hsl(20, 0%, 70%);--danger:hsl(350, 100%, 50%);--danger-hover:hsl(350, 100%, 70%);--danger-active:hsl(350, 100%, 40%);--danger-focus:hsl(350, 100%, 45%);--danger-disabled:hsl(350, 0%, 50%);--system-color:hsl(0, 0%, 95%);--system-background:hsla(0, 0%, 0%, .5);--face:hsl(0, 0%, 95%);--g-color:hsl(0, 0%, 20%);--g-color-hover:hsl(0, 0%, 30%);--g-color-active:hsl(0, 0%, 10%);--g-color-focus:hsl(0, 0%, 15%);--g-color-disabled:hsl(0, 0%, 60%);--g-background:hsl(0, 0%, 95%);--g-background-hover:hsl(0, 0%, 100%);--g-background-active:hsl(0, 0%, 85%);--g-background-kp:hsl(0, 0%, 80%);--g-background-opacity:hsl(0, 0%, 50%, .2);--g-background-focus:hsl(0, 0%, 97.5%);--g-background-disabled:hsl(0, 0%, 75%);--g-border-color:hsl(0, 0%, 40%);--g-border-color-hover:hsl(0, 0%, 50%);--g-border-color-active:hsl(0, 0%, 30%);--g-border-color-focus:hsl(0, 0%, 35%);--g-border-color-disabled:hsl(0, 0%, 60%);--g-plain-color:var(--g-color);--g-plain-color-hover:var(--g-color-hover);--g-plain-color-active:var(--g-color-active);--g-plain-color-focus:var(--g-color-focus);--g-plain-color-disabled:var(--g-color-disabled);--g-plain-background:hsl(0, 0%, 100%);--g-plain-background-hover:hsl(0, 0%, 98%);--g-plain-background-active:hsl(0, 0%, 95%);--g-plain-background-focus:var(--g-plain-background);--g-plain-background-disabled:hsl(0, 0%, 95%);--g-plain-border-color:hsl(0, 0%, 70%);--g-plain-border-color-hover:hsl(0, 0%, 80%);--g-plain-border-color-active:hsl(0, 0%, 60%);--g-plain-border-color-focus:hsl(0, 0%, 65%);--g-plain-border-color-disabled:hsl(0, 0%, 60%)}#cg-form-list{z-index:20020000}#cg-pop-list{z-index:20020001}#cg-simpletask{z-index:20020002}#cg-system{z-index:20020003}#cg-rectangle{z-index:20020004;box-sizing:border-box;position:fixed;border-radius:3px;box-shadow:0 0 10px rgba(0,0,0,.25);background:rgba(255,255,255,.05);pointer-events:none;opacity:0}#cg-circular{z-index:20020004;box-sizing:border-box;position:fixed;border:solid 3px var(--cg);border-radius:50%;filter:drop-shadow(0 0 3px var(--cg));pointer-events:none;opacity:0}#cg-gesture{z-index:20020004;box-sizing:border-box;position:fixed;border-radius:50%;pointer-events:none;opacity:0;background:var(--system-background);box-shadow:0 5px 20px rgba(0,0,0,.25);transform:scale(0);width:20px;height:20px}#cg-gesture.done{background:rgba(255,255,255,.3);border:solid 3px rgba(0,0,0,.3)}#cg-drag{box-sizing:border-box;position:fixed;border-radius:3px;z-index:20020004;pointer-events:none;background:var(--system-background);box-shadow:0 5px 20px rgba(0,0,0,.25);opacity:0;display:flex;justify-content:center;align-items:center}[data-cg-pop]{position:fixed;box-shadow:0px 5px 20px rgba(0,0,0,.25);transition:.1s ease-out;transition-property:transform,opacity;transform:translateY(-10px);opacity:0}[data-cg-pop]:not([data-cg-open]){pointer-events:none}[data-cg-pop][data-cg-open]{transform:translateY(0px);opacity:1}.cg-system-notify{background:var(--system-background);position:fixed;padding:15px;border-radius:3px;right:0;top:0;width:280px;font-size:14px;display:flex;transition:.1s ease-out;transition-property:transform,opacity;overflow:hidden;color:#f6f6f6;box-shadow:0 5px 20px rgba(0,0,0,.25);-webkit-backdrop-filter:blur(30px) brightness(1.1);backdrop-filter:blur(30px) brightness(1.1)}.cg-system-icon{margin-right:10px;width:16px;height:16px;border-radius:50%}.cg-system-icon.cg-primary{background:var(--success)}.cg-system-icon.cg-info{background:var(--info)}.cg-system-icon.cg-warning{background:var(--warning)}.cg-system-icon.cg-danger{background:var(--danger)}.cg-system-icon.cg-progress{background:var(--cg)}.cg-system-notify-title{font-size:16px;font-weight:bold;padding-bottom:10px}.cg-system-notify-content{line-height:1.5;word-break:break-word}.cg-system-notify-progress{position:absolute;bottom:0;left:0;border-radius:1px;background:var(--cg);transition:width 1s ease-out;width:0%;height:2px}#cg-simpletask{bottom:-46px;width:100%;height:46px;top:initial;background:var(--system-background);-webkit-backdrop-filter:blur(30px) brightness(1.1);backdrop-filter:blur(30px) brightness(1.1);padding:5px 0 5px 5px;display:flex;color:var(--system-color);transition:bottom .1s ease-out;overflow-x:auto}#cg-simpletask::-webkit-scrollbar{display:none}.cg-simpletask-item{background:rgba(0,0,0,.05);border-radius:3px;padding:10px;display:flex;align-items:center;margin-right:5px}.cg-simpletask-item:hover{background:rgba(0,0,0,.1)}.cg-simpletask-item:active{background:rgba(0,0,0,.2)}.cg-simpletask-icon{margin-right:5px;background-size:cover;width:16px;height:16px}
package/dist/index.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.init = exports.getCdn = exports.setCdn = exports.getSafe = exports.setSafe = exports.getNative = exports.getVersion = exports.vue = exports.zip = exports.tool = exports.theme = exports.task = exports.native = exports.fs = exports.form = exports.dom = exports.core = exports.control = exports.clickgo = void 0;
12
+ exports.init = exports.getCdn = exports.setCdn = exports.getSafe = exports.setSafe = exports.getPlatform = exports.getNative = exports.getVersion = exports.vue = exports.zip = exports.tool = exports.theme = exports.task = exports.native = exports.fs = exports.form = exports.dom = exports.core = exports.control = exports.clickgo = void 0;
13
13
  function getVersion() {
14
14
  return exports.clickgo.getVersion();
15
15
  }
@@ -18,6 +18,10 @@ function getNative() {
18
18
  return exports.clickgo.getNative();
19
19
  }
20
20
  exports.getNative = getNative;
21
+ function getPlatform() {
22
+ return exports.clickgo.getPlatform();
23
+ }
24
+ exports.getPlatform = getPlatform;
21
25
  function setSafe(val) {
22
26
  exports.clickgo.setSafe(val);
23
27
  }
package/dist/index.ts CHANGED
@@ -22,6 +22,10 @@ export function getNative(): boolean {
22
22
  return clickgo.getNative();
23
23
  }
24
24
 
25
+ export function getPlatform(): NodeJS.Platform | 'web' {
26
+ return clickgo.getPlatform();
27
+ }
28
+
25
29
  export function setSafe(val: boolean): void {
26
30
  clickgo.setSafe(val);
27
31
  }
package/dist/lib/core.js CHANGED
@@ -515,32 +515,28 @@ function fetchApp(url, opt = {}) {
515
515
  }
516
516
  }
517
517
  if (cga) {
518
- if (opt.notifyId) {
518
+ try {
519
519
  const blob = yield fs.getContent(url, {
520
520
  'current': current,
521
- progress: (loaded, total) => {
522
- form.notifyProgress(opt.notifyId, loaded / total);
521
+ 'progress': (loaded, total) => {
522
+ if (opt.notifyId) {
523
+ form.notifyProgress(opt.notifyId, loaded / total);
524
+ }
525
+ if (opt.progress) {
526
+ opt.progress(loaded, total);
527
+ }
523
528
  }
524
529
  });
525
- if ((blob === null) || (typeof blob === 'string')) {
530
+ if ((blob === null) || typeof blob === 'string') {
526
531
  return null;
527
532
  }
528
- form.notifyProgress(opt.notifyId, 1);
533
+ if (opt.notifyId) {
534
+ form.notifyProgress(opt.notifyId, 1);
535
+ }
529
536
  return (yield readApp(blob)) || null;
530
537
  }
531
- else {
532
- try {
533
- const blob = yield fs.getContent(url, {
534
- 'current': current
535
- });
536
- if ((blob === null) || typeof blob === 'string') {
537
- return null;
538
- }
539
- return (yield readApp(blob)) || null;
540
- }
541
- catch (_a) {
542
- return null;
543
- }
538
+ catch (_a) {
539
+ return null;
544
540
  }
545
541
  }
546
542
  let config;
package/dist/lib/core.ts CHANGED
@@ -577,32 +577,28 @@ export async function fetchApp(url: string, opt: types.ICoreFetchAppOptions = {}
577
577
 
578
578
  // --- 如果是 cga 文件,直接读取并交给 readApp 函数处理 ---
579
579
  if (cga) {
580
- if (opt.notifyId) {
580
+ try {
581
581
  const blob = await fs.getContent(url, {
582
582
  'current': current,
583
- progress: (loaded, total): void => {
584
- form.notifyProgress(opt.notifyId!, loaded / total);
583
+ 'progress': (loaded: number, total: number): void => {
584
+ if (opt.notifyId) {
585
+ form.notifyProgress(opt.notifyId, loaded / total);
586
+ }
587
+ if (opt.progress) {
588
+ opt.progress(loaded, total) as unknown;
589
+ }
585
590
  }
586
591
  });
587
- if ((blob === null) || (typeof blob === 'string')) {
592
+ if ((blob === null) || typeof blob === 'string') {
588
593
  return null;
589
594
  }
590
- form.notifyProgress(opt.notifyId, 1);
595
+ if (opt.notifyId) {
596
+ form.notifyProgress(opt.notifyId, 1);
597
+ }
591
598
  return await readApp(blob) || null;
592
599
  }
593
- else {
594
- try {
595
- const blob = await fs.getContent(url, {
596
- 'current': current
597
- });
598
- if ((blob === null) || typeof blob === 'string') {
599
- return null;
600
- }
601
- return await readApp(blob) || null;
602
- }
603
- catch {
604
- return null;
605
- }
600
+ catch {
601
+ return null;
606
602
  }
607
603
  }
608
604
  // --- 加载目录 ---
package/dist/lib/dom.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fullscreen = exports.siblingsData = exports.siblings = exports.findParentByClass = exports.findParentByData = exports.bindResize = exports.bindMove = exports.is = exports.bindDrag = exports.bindLong = exports.allowEvent = exports.bindGesture = exports.bindDown = exports.isWatchStyle = exports.watchStyle = exports.clearWatch = exports.unwatch = exports.watch = exports.clearWatchSize = exports.unwatchSize = exports.watchSize = exports.getSize = exports.getStyleCount = exports.removeStyle = exports.pushStyle = exports.removeFromStyleList = exports.createToStyleList = exports.hasTouchButMouse = exports.setGlobalCursor = void 0;
4
+ const clickgo = require("../clickgo");
4
5
  const form = require("./form");
5
6
  const core = require("./core");
6
7
  const topClass = ['#cg-form-list', '#cg-pop-list', '#cg-system', '#cg-simpletask'];
@@ -16,7 +17,8 @@ styleList.style.display = 'none';
16
17
  document.getElementsByTagName('body')[0].appendChild(styleList);
17
18
  styleList.insertAdjacentHTML('beforeend', '<style id=\'cg-global-cursor\'></style>');
18
19
  styleList.insertAdjacentHTML('beforeend', `<style id='cg-global'>
19
- ${classUnfold()} {-webkit-user-select: none; user-select: none; position: fixed; left: 0; top: 0; width: 0; height: 0; cursor: default; box-sizing: border-box;}
20
+ ${classUnfold()} {-webkit-user-select: none; user-select: none; position: fixed; cursor: default; box-sizing: border-box;}
21
+ ${topClass.slice(0, 3).join(', ')} {left: 0; top: 0; width: 0; height: 0;}
20
22
  ${classUnfold('img')} {vertical-align: bottom;}
21
23
  ${classUnfold('::selection')} {background-color: rgba(0, 0, 0, .1);}
22
24
  ${classUnfold('*')}, ${classUnfold('*::after')}, ${classUnfold('*::before')} {box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}
@@ -1001,7 +1003,7 @@ function bindDrag(e, opt) {
1001
1003
  });
1002
1004
  }
1003
1005
  exports.bindDrag = bindDrag;
1004
- exports.is = Vue.reactive({
1006
+ exports.is = clickgo.vue.reactive({
1005
1007
  'move': false,
1006
1008
  'shift': false,
1007
1009
  'ctrl': false
package/dist/lib/dom.ts CHANGED
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import * as types from '../../types';
17
+ import * as clickgo from '../clickgo';
17
18
  import * as form from './form';
18
19
  import * as core from './core';
19
20
 
@@ -36,7 +37,8 @@ styleList.style.display = 'none';
36
37
  document.getElementsByTagName('body')[0].appendChild(styleList);
37
38
  styleList.insertAdjacentHTML('beforeend', '<style id=\'cg-global-cursor\'></style>');
38
39
  styleList.insertAdjacentHTML('beforeend', `<style id='cg-global'>
39
- ${classUnfold()} {-webkit-user-select: none; user-select: none; position: fixed; left: 0; top: 0; width: 0; height: 0; cursor: default; box-sizing: border-box;}
40
+ ${classUnfold()} {-webkit-user-select: none; user-select: none; position: fixed; cursor: default; box-sizing: border-box;}
41
+ ${topClass.slice(0, 3).join(', ')} {left: 0; top: 0; width: 0; height: 0;}
40
42
  ${classUnfold('img')} {vertical-align: bottom;}
41
43
  ${classUnfold('::selection')} {background-color: rgba(0, 0, 0, .1);}
42
44
  ${classUnfold('*')}, ${classUnfold('*::after')}, ${classUnfold('*::before')} {box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}
@@ -1217,7 +1219,7 @@ export function bindDrag(e: MouseEvent | TouchEvent, opt: { 'el': HTMLElement; '
1217
1219
  }
1218
1220
 
1219
1221
  /** --- 目前是否已绑定了 bindMove --- */
1220
- export const is = Vue.reactive({
1222
+ export const is = clickgo.vue.reactive({
1221
1223
  'move': false,
1222
1224
  'shift': false,
1223
1225
  'ctrl': false
package/dist/lib/form.js CHANGED
@@ -67,12 +67,18 @@ const elements = {
67
67
  'init': function () {
68
68
  this.wrap.id = 'cg-wrap';
69
69
  document.getElementsByTagName('body')[0].appendChild(this.wrap);
70
- if (clickgo.getNative()) {
70
+ if (clickgo.getNative() && (clickgo.getPlatform() === 'win32')) {
71
71
  this.wrap.addEventListener('mouseenter', function () {
72
- native.send('cg-mouse-ignore', 'false');
72
+ native.send('cg-mouse-ignore', JSON.stringify({
73
+ 'token': native.getToken(),
74
+ 'param': false
75
+ }));
73
76
  });
74
77
  this.wrap.addEventListener('mouseleave', function () {
75
- native.send('cg-mouse-ignore', 'true');
78
+ native.send('cg-mouse-ignore', JSON.stringify({
79
+ 'token': native.getToken(),
80
+ 'param': true
81
+ }));
76
82
  });
77
83
  }
78
84
  this.list.id = 'cg-form-list';
@@ -123,7 +129,7 @@ const elements = {
123
129
  }, {
124
130
  'passive': false
125
131
  });
126
- this.simpleSystemtask.id = 'cg-simplesystemtask';
132
+ this.simpleSystemtask.id = 'cg-simpletask';
127
133
  this.simpleSystemtask.addEventListener('contextmenu', function (e) {
128
134
  e.preventDefault();
129
135
  });
@@ -133,8 +139,8 @@ const elements = {
133
139
  }, {
134
140
  'passive': false
135
141
  });
136
- const simpleSystemtaskApp = clickgo.vue.createApp({
137
- 'template': '<div v-for="(item, formId) of forms" class="cg-simplesystemtask-item" @click="click(parseInt(formId))"><div v-if="item.icon" class="cg-simplesystemtask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',
142
+ const simpletaskApp = clickgo.vue.createApp({
143
+ 'template': '<div v-for="(item, formId) of forms" class="cg-simpletask-item" @click="click(parseInt(formId))"><div v-if="item.icon" class="cg-simpletask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',
138
144
  'data': function () {
139
145
  return {
140
146
  'forms': {}
@@ -169,7 +175,7 @@ const elements = {
169
175
  exports.simpleSystemTaskRoot = this;
170
176
  }
171
177
  });
172
- simpleSystemtaskApp.mount('#cg-simplesystemtask');
178
+ simpletaskApp.mount('#cg-simpletask');
173
179
  }
174
180
  };
175
181
  elements.init();
@@ -1089,6 +1095,9 @@ function create(opt) {
1089
1095
  getNative() {
1090
1096
  return clickgo.getNative();
1091
1097
  },
1098
+ getPlatform() {
1099
+ return clickgo.getPlatform();
1100
+ },
1092
1101
  getSafe() {
1093
1102
  return clickgo.getSafe();
1094
1103
  },
@@ -1448,6 +1457,18 @@ function create(opt) {
1448
1457
  },
1449
1458
  clearListener: function () {
1450
1459
  clickgo.native.clearListener(taskId);
1460
+ },
1461
+ max: function () {
1462
+ clickgo.native.max();
1463
+ },
1464
+ min: function () {
1465
+ clickgo.native.min();
1466
+ },
1467
+ restore: function () {
1468
+ clickgo.native.restore();
1469
+ },
1470
+ size: function (width, height) {
1471
+ clickgo.native.size(width, height);
1451
1472
  }
1452
1473
  },
1453
1474
  'task': {
@@ -1468,6 +1489,7 @@ function create(opt) {
1468
1489
  },
1469
1490
  run: function (url, opt = {}) {
1470
1491
  opt.taskId = taskId;
1492
+ opt.main = false;
1471
1493
  return clickgo.task.run(url, opt);
1472
1494
  },
1473
1495
  end: function (tid) {
package/dist/lib/form.ts CHANGED
@@ -111,12 +111,18 @@ const elements: {
111
111
  /** --- clickgo 所有的 div wrap --- */
112
112
  this.wrap.id = 'cg-wrap';
113
113
  document.getElementsByTagName('body')[0].appendChild(this.wrap);
114
- if (clickgo.getNative()) {
114
+ if (clickgo.getNative() && (clickgo.getPlatform() === 'win32')) {
115
115
  this.wrap.addEventListener('mouseenter', function() {
116
- native.send('cg-mouse-ignore', 'false');
116
+ native.send('cg-mouse-ignore', JSON.stringify({
117
+ 'token': native.getToken(),
118
+ 'param': false
119
+ }));
117
120
  });
118
121
  this.wrap.addEventListener('mouseleave', function() {
119
- native.send('cg-mouse-ignore', 'true');
122
+ native.send('cg-mouse-ignore', JSON.stringify({
123
+ 'token': native.getToken(),
124
+ 'param': true
125
+ }));
120
126
  });
121
127
  }
122
128
 
@@ -187,8 +193,8 @@ const elements: {
187
193
  'passive': false
188
194
  });
189
195
 
190
- // --- 添加 cg-simplesystemtask 的 dom ---
191
- this.simpleSystemtask.id = 'cg-simplesystemtask';
196
+ // --- 添加 cg-simpletask 的 dom ---
197
+ this.simpleSystemtask.id = 'cg-simpletask';
192
198
  this.simpleSystemtask.addEventListener('contextmenu', function(e): void {
193
199
  e.preventDefault();
194
200
  });
@@ -199,8 +205,8 @@ const elements: {
199
205
  }, {
200
206
  'passive': false
201
207
  });
202
- const simpleSystemtaskApp = clickgo.vue.createApp({
203
- 'template': '<div v-for="(item, formId) of forms" class="cg-simplesystemtask-item" @click="click(parseInt(formId))"><div v-if="item.icon" class="cg-simplesystemtask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',
208
+ const simpletaskApp = clickgo.vue.createApp({
209
+ 'template': '<div v-for="(item, formId) of forms" class="cg-simpletask-item" @click="click(parseInt(formId))"><div v-if="item.icon" class="cg-simpletask-icon" :style="{\'background-image\': \'url(\' + item.icon + \')\'}"></div><div>{{item.title}}</div></div>',
204
210
  'data': function() {
205
211
  return {
206
212
  'forms': {}
@@ -235,7 +241,7 @@ const elements: {
235
241
  simpleSystemTaskRoot = this;
236
242
  }
237
243
  });
238
- simpleSystemtaskApp.mount('#cg-simplesystemtask');
244
+ simpletaskApp.mount('#cg-simpletask');
239
245
  }
240
246
  };
241
247
  elements.init();
@@ -1365,6 +1371,9 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
1365
1371
  getNative(): boolean {
1366
1372
  return clickgo.getNative();
1367
1373
  },
1374
+ getPlatform(): string {
1375
+ return clickgo.getPlatform();
1376
+ },
1368
1377
  getSafe(): boolean {
1369
1378
  return clickgo.getSafe();
1370
1379
  },
@@ -1762,6 +1771,18 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
1762
1771
  },
1763
1772
  clearListener: function(): void {
1764
1773
  clickgo.native.clearListener(taskId);
1774
+ },
1775
+ max: function(): void {
1776
+ clickgo.native.max();
1777
+ },
1778
+ min: function(): void {
1779
+ clickgo.native.min();
1780
+ },
1781
+ restore: function(): void {
1782
+ clickgo.native.restore();
1783
+ },
1784
+ size: function(width: number, height: number): void {
1785
+ clickgo.native.size(width, height);
1765
1786
  }
1766
1787
  },
1767
1788
  'task': {
@@ -1789,6 +1810,7 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
1789
1810
  },
1790
1811
  run: function(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
1791
1812
  opt.taskId = taskId;
1813
+ opt.main = false;
1792
1814
  return clickgo.task.run(url, opt);
1793
1815
  },
1794
1816
  end: function(tid: number): boolean {
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cgInnerReceive = exports.cgInnerGetSends = exports.clearListener = exports.off = exports.once = exports.on = exports.send = exports.getListeners = void 0;
3
+ exports.cgInnerReceive = exports.cgInnerGetSends = exports.size = exports.restore = exports.min = exports.max = exports.clearListener = exports.off = exports.once = exports.on = exports.send = exports.getListeners = exports.getToken = void 0;
4
4
  const clickgo = require("../clickgo");
5
5
  let sendId = 0;
6
6
  let sendList = [];
7
7
  const listeners = {};
8
+ const token = (Math.random() * 100000000000000 * (100 + Math.round(Math.random() * (999 - 100)))).toString(32);
9
+ function getToken() {
10
+ return token;
11
+ }
12
+ exports.getToken = getToken;
8
13
  function getListeners() {
9
14
  const list = [];
10
15
  for (const name in listeners) {
@@ -93,6 +98,35 @@ function clearListener(taskId) {
93
98
  }
94
99
  }
95
100
  exports.clearListener = clearListener;
101
+ function max() {
102
+ send('cg-set-state', JSON.stringify({
103
+ 'token': token,
104
+ 'state': 'max'
105
+ }));
106
+ }
107
+ exports.max = max;
108
+ function min() {
109
+ send('cg-set-state', JSON.stringify({
110
+ 'token': token,
111
+ 'state': 'min'
112
+ }));
113
+ }
114
+ exports.min = min;
115
+ function restore() {
116
+ send('cg-set-state', JSON.stringify({
117
+ 'token': token,
118
+ 'state': 'restore'
119
+ }));
120
+ }
121
+ exports.restore = restore;
122
+ function size(width, height) {
123
+ send('cg-set-size', JSON.stringify({
124
+ 'token': token,
125
+ 'width': width,
126
+ 'height': height
127
+ }));
128
+ }
129
+ exports.size = size;
96
130
  function cgInnerGetSends() {
97
131
  const json = JSON.stringify(sendList);
98
132
  sendList = [];
@@ -15,6 +15,7 @@
15
15
  */
16
16
  import * as clickgo from '../clickgo';
17
17
 
18
+ /** --- 最后一个 send ID --- */
18
19
  let sendId = 0;
19
20
  // --- sendList 一定会被清理 ---
20
21
  let sendList: Array<{
@@ -31,6 +32,14 @@ const listeners: Record<string, Array<{
31
32
  'handler': (param?: string) => void | Promise<void>;
32
33
  }>> = {};
33
34
 
35
+ const token = (Math.random() * 100000000000000 * (100 + Math.round(Math.random() * (999 - 100)))).toString(32);
36
+ /**
37
+ * --- 获取 native 通讯 token,app 模式下无效 ---
38
+ */
39
+ export function getToken(): string {
40
+ return token;
41
+ }
42
+
34
43
  /**
35
44
  * --- 获取已经创建的监听列表 ---
36
45
  */
@@ -123,7 +132,7 @@ export function once(
123
132
  }
124
133
 
125
134
  /**
126
- * --- 取消监听 native 指令
135
+ * --- 取消监听 native 指令 ---
127
136
  * @param name 指令名
128
137
  * @param handler 绑定监听时的回调函数
129
138
  * @param taskId 校验 taskId,为空则不校验,但 App 模式下无效
@@ -170,6 +179,34 @@ export function clearListener(taskId?: number): void {
170
179
  }
171
180
  }
172
181
 
182
+ // --- 常见操作 ---
183
+
184
+ export function max(): void {
185
+ send('cg-set-state', JSON.stringify({
186
+ 'token': token,
187
+ 'state': 'max'
188
+ }));
189
+ }
190
+ export function min(): void {
191
+ send('cg-set-state', JSON.stringify({
192
+ 'token': token,
193
+ 'state': 'min'
194
+ }));
195
+ }
196
+ export function restore(): void {
197
+ send('cg-set-state', JSON.stringify({
198
+ 'token': token,
199
+ 'state': 'restore'
200
+ }));
201
+ }
202
+ export function size(width: number, height: number): void {
203
+ send('cg-set-size', JSON.stringify({
204
+ 'token': token,
205
+ 'width': width,
206
+ 'height': height
207
+ }));
208
+ }
209
+
173
210
  // --- 以下为供 native 调用的内部函数 ---
174
211
 
175
212
  // --- 将 send 值全部提交给 native ---
package/dist/lib/task.js CHANGED
@@ -145,7 +145,7 @@ function getList() {
145
145
  }
146
146
  exports.getList = getList;
147
147
  function run(url, opt = {}) {
148
- var _a, _b, _c;
148
+ var _a, _b, _c, _d;
149
149
  return __awaiter(this, void 0, void 0, function* () {
150
150
  let ntask = null;
151
151
  if (opt.taskId) {
@@ -158,10 +158,10 @@ function run(url, opt = {}) {
158
158
  if (opt.icon) {
159
159
  icon = opt.icon;
160
160
  }
161
- if (opt.progress === undefined) {
162
- opt.progress = true;
161
+ if (opt.notify === undefined) {
162
+ opt.notify = true;
163
163
  }
164
- const notifyId = opt.progress ? form.notify({
164
+ const notifyId = opt.notify ? form.notify({
165
165
  'title': (_b = (_a = localeData[core.config.locale]) === null || _a === void 0 ? void 0 : _a.loading) !== null && _b !== void 0 ? _b : localeData['en'].loading,
166
166
  'content': url,
167
167
  'icon': icon,
@@ -196,6 +196,7 @@ function run(url, opt = {}) {
196
196
  'icon': (_c = app.icon) !== null && _c !== void 0 ? _c : icon,
197
197
  'path': url,
198
198
  'files': files,
199
+ 'main': (_d = opt.main) !== null && _d !== void 0 ? _d : false,
199
200
  'permissions': {},
200
201
  'forms': {},
201
202
  'objectURLs': [],
@@ -259,7 +260,7 @@ function run(url, opt = {}) {
259
260
  const data = JSON.parse(lcontent);
260
261
  loadLocaleData(locale, data, '', task.id);
261
262
  }
262
- catch (_d) {
263
+ catch (_e) {
263
264
  }
264
265
  }
265
266
  }
@@ -275,6 +276,13 @@ function run(url, opt = {}) {
275
276
  core.trigger('taskEnded', task.id);
276
277
  return f - 100;
277
278
  }
279
+ if (clickgo.getNative() && opt.sync) {
280
+ f.vroot.$refs.form.isNativeSync = true;
281
+ window.addEventListener('resize', function () {
282
+ f.vroot.$refs.form.setPropData('width', window.innerWidth);
283
+ f.vroot.$refs.form.setPropData('height', window.innerHeight);
284
+ });
285
+ }
278
286
  if (app.config.style && app.files[app.config.style + '.css']) {
279
287
  const style = app.files[app.config.style + '.css'];
280
288
  const r = tool.stylePrepend(style, 'cg-task' + task.id.toString() + '_');
@@ -302,6 +310,9 @@ function run(url, opt = {}) {
302
310
  yield theme.load(undefined, task.id);
303
311
  }
304
312
  }
313
+ if (task.id === 1) {
314
+ clickgo.native.send('cg-init', clickgo.native.getToken());
315
+ }
305
316
  return task.id;
306
317
  });
307
318
  }
@@ -311,6 +322,11 @@ function end(taskId) {
311
322
  if (!task) {
312
323
  return true;
313
324
  }
325
+ if (clickgo.getNative() && task.main) {
326
+ clickgo.native.send('cg-main-close', JSON.stringify({
327
+ 'token': clickgo.native.getToken()
328
+ }));
329
+ }
314
330
  const fid = form.getMaxZIndexID({
315
331
  'taskIds': [task.id]
316
332
  });
package/dist/lib/task.ts CHANGED
@@ -193,7 +193,7 @@ export function getList(): Record<string, types.ITaskInfo> {
193
193
  /**
194
194
  * --- 运行一个应用 ---
195
195
  * @param url app 路径(以 / 为结尾的路径或以 .cga 结尾的文件)
196
- * @param opt 选项,icon:图标,progress:显示进度条,taskId:所属任务,App 模式下无效
196
+ * @param opt 选项,icon:图标,progress:显示进度条,main:native模式下的主进程,App 模式下无效,taskId:所属任务,App 模式下无效
197
197
  */
198
198
  export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
199
199
  /** --- 是否是在任务当中启动的任务 --- */
@@ -210,10 +210,10 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
210
210
  if (opt.icon) {
211
211
  icon = opt.icon;
212
212
  }
213
- if (opt.progress === undefined) {
214
- opt.progress = true;
213
+ if (opt.notify === undefined) {
214
+ opt.notify = true;
215
215
  }
216
- const notifyId: number | undefined = opt.progress ? form.notify({
216
+ const notifyId: number | undefined = opt.notify ? form.notify({
217
217
  'title': localeData[core.config.locale]?.loading ?? localeData['en'].loading,
218
218
  'content': url,
219
219
  'icon': icon,
@@ -250,6 +250,7 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
250
250
  'icon': app.icon ?? icon,
251
251
  'path': url,
252
252
  'files': files,
253
+ 'main': opt.main ?? false,
253
254
 
254
255
  'permissions': {},
255
256
  'forms': {},
@@ -338,6 +339,13 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
338
339
  core.trigger('taskEnded', task.id);
339
340
  return f - 100;
340
341
  }
342
+ if (clickgo.getNative() && opt.sync) {
343
+ f.vroot.$refs.form.isNativeSync = true;
344
+ window.addEventListener('resize', function(): void {
345
+ f.vroot.$refs.form.setPropData('width', window.innerWidth);
346
+ f.vroot.$refs.form.setPropData('height', window.innerHeight);
347
+ });
348
+ }
341
349
  // --- 设置 global style(如果 form 创建失败,就不设置 global style 了) ---
342
350
  if (app.config.style && app.files[app.config.style + '.css']) {
343
351
  const style = app.files[app.config.style + '.css'] as string;
@@ -368,6 +376,10 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
368
376
  await theme.load(undefined, task.id);
369
377
  }
370
378
  }
379
+ // --- 给 native 发送任务启动成功的消息 ---
380
+ if (task.id === 1) {
381
+ clickgo.native.send('cg-init', clickgo.native.getToken());
382
+ }
371
383
  return task.id;
372
384
  }
373
385
 
@@ -380,6 +392,12 @@ export function end(taskId: number): boolean {
380
392
  if (!task) {
381
393
  return true;
382
394
  }
395
+ // --- 如果是 native 模式 ---
396
+ if (clickgo.getNative() && task.main) {
397
+ clickgo.native.send('cg-main-close', JSON.stringify({
398
+ 'token': clickgo.native.getToken()
399
+ }));
400
+ }
383
401
  // --- 获取最大的 z index 窗体,并让他获取焦点 ---
384
402
  const fid = form.getMaxZIndexID({
385
403
  'taskIds': [task.id]
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickgo",
3
- "version": "3.0.1-dev2",
3
+ "version": "3.0.2-dev3",
4
4
  "description": "Background interface, software interface, mobile phone APP interface operation library.",
5
5
  "keywords": [
6
6
  "deskrt",
@@ -12,14 +12,17 @@
12
12
  "license": "Apache-2.0",
13
13
  "types": "./types/index.d.ts",
14
14
  "scripts": {
15
- "native": "electron ./dist/test/native"
15
+ "native": "electron ./dist/test/native",
16
+ "native2": "electron ./dist/test/native/index2",
17
+ "native3": "electron ./dist/test/native/index3",
18
+ "native4": "electron ./dist/test/native/index4"
16
19
  },
17
20
  "devDependencies": {
18
21
  "@litert/loader": "^3.2.0",
19
22
  "@types/node": "^17.0.21",
20
23
  "@typescript-eslint/eslint-plugin": "^5.17.0",
21
24
  "@typescript-eslint/parser": "^5.17.0",
22
- "electron": "^18.3.4",
25
+ "electron": "^19.0.8",
23
26
  "eslint": "^8.12.0",
24
27
  "typescript": "^4.6.4"
25
28
  },
package/types/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export let zip: typeof import('../dist/lib/zip');
11
11
 
12
12
  export function getVersion(): string;
13
13
  export function getNative(): boolean;
14
+ export function getPlatform(): NodeJS.Platform | 'web';
14
15
  export function setSafe(val: boolean): void;
15
16
  export function getSafe(): boolean;
16
17
  export function setCdn(val: string): void;
@@ -84,6 +85,7 @@ export type TGlobalEvent = 'error' | 'screenResize' | 'configChanged' | 'formCre
84
85
  export interface ICoreFetchAppOptions {
85
86
  'notifyId'?: number;
86
87
  'current'?: string;
88
+ 'progress'?: (loaded: number, total: number) => void | Promise<void>;
87
89
  }
88
90
 
89
91
  /** --- 应用文件包 --- */
@@ -341,7 +343,10 @@ export interface ISystemTaskInfo {
341
343
 
342
344
  export interface ITaskRunOptions {
343
345
  'icon'?: string;
344
- 'progress'?: boolean;
346
+ 'progress'?: (loaded: number, total: number) => void | Promise<void>;
347
+ 'notify'?: boolean;
348
+ 'main'?: boolean;
349
+ 'sync'?: boolean;
345
350
  'taskId'?: number;
346
351
  }
347
352
 
@@ -367,6 +372,7 @@ export interface ITask {
367
372
  /** --- 当前 app 运行路径,末尾包含 / --- */
368
373
  'path': string;
369
374
  'files': Record<string, Blob | string>;
375
+ 'main': boolean;
370
376
 
371
377
  /** --- 已申请的权限列表 --- */
372
378
  'permissions': Record<string, any>;