clickgo 3.0.1-dev2 → 3.0.4-dev5
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 +5 -5
- package/dist/app/task/config.json +3 -0
- package/dist/clickgo.js +13 -11
- package/dist/clickgo.ts +12 -9
- package/dist/control/common.cgc +0 -0
- package/dist/control/form.cgc +0 -0
- package/dist/control/monaco.cgc +0 -0
- package/dist/control/property.cgc +0 -0
- package/dist/control/task.cgc +0 -0
- package/dist/global.css +1 -1
- package/dist/index.js +11 -16
- package/dist/index.ts +10 -14
- package/dist/lib/core.js +18 -23
- package/dist/lib/core.ts +19 -23
- package/dist/lib/dom.js +4 -2
- package/dist/lib/dom.ts +4 -2
- package/dist/lib/form.js +30 -10
- package/dist/lib/form.ts +31 -11
- package/dist/lib/native.js +35 -1
- package/dist/lib/native.ts +38 -1
- package/dist/lib/task.js +21 -5
- package/dist/lib/task.ts +22 -4
- package/dist/theme/familiar.cgt +0 -0
- package/package.json +7 -4
- package/types/index.d.ts +8 -4
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/clickgo "Stable Version")
|
|
6
6
|
[](https://www.npmjs.com/package/clickgo "Development Version")
|
|
7
7
|
[](https://www.npmjs.com/package/clickgo "Beta Version")
|
|
8
|
-
[](https://github.com/maiyun/clickgo/blob/master/LICENSE)
|
|
9
|
+
[](https://github.com/maiyun/clickgo/issues)
|
|
10
|
+
[](https://github.com/maiyun/clickgo/releases "Stable Release")
|
|
11
|
+
[](https://github.com/maiyun/clickgo/releases "Pre-Release")
|
|
12
12
|
|
|
13
13
|
Quickly and easily create a beautiful console interface.
|
|
14
14
|
|
|
@@ -19,7 +19,7 @@ Load the module loader first, and then load it using the module loader.
|
|
|
19
19
|
**index.html**
|
|
20
20
|
|
|
21
21
|
```html
|
|
22
|
-
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.
|
|
22
|
+
<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.3.0/dist/loader.min.js?path=index&npm={'clickgo':'3.0.4-dev5'}"></script>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
**index.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.
|
|
3
|
+
exports.zip = exports.tool = exports.theme = exports.task = exports.native = exports.fs = exports.form = exports.dom = exports.core = exports.control = exports.vue = 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.
|
|
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;
|
|
@@ -20,15 +31,6 @@ function getSafe() {
|
|
|
20
31
|
return safe;
|
|
21
32
|
}
|
|
22
33
|
exports.getSafe = getSafe;
|
|
23
|
-
let cdn = '';
|
|
24
|
-
function setCdn(val) {
|
|
25
|
-
cdn = val;
|
|
26
|
-
}
|
|
27
|
-
exports.setCdn = setCdn;
|
|
28
|
-
function getCdn() {
|
|
29
|
-
return cdn;
|
|
30
|
-
}
|
|
31
|
-
exports.getCdn = getCdn;
|
|
32
34
|
exports.vue = window.Vue;
|
|
33
35
|
exports.control = require("./lib/control");
|
|
34
36
|
exports.core = require("./lib/core");
|
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.
|
|
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;
|
|
@@ -31,14 +42,6 @@ export function getSafe(): boolean {
|
|
|
31
42
|
return safe;
|
|
32
43
|
}
|
|
33
44
|
|
|
34
|
-
let cdn = '';
|
|
35
|
-
export function setCdn(val: string): void {
|
|
36
|
-
cdn = val;
|
|
37
|
-
}
|
|
38
|
-
export function getCdn(): string {
|
|
39
|
-
return cdn;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
45
|
export const vue: import('../types/index').IVueObject = (window as any).Vue;
|
|
43
46
|
|
|
44
47
|
export * as control from './lib/control';
|
package/dist/control/common.cgc
CHANGED
|
Binary file
|
package/dist/control/form.cgc
CHANGED
|
Binary file
|
package/dist/control/monaco.cgc
CHANGED
|
Binary file
|
|
Binary file
|
package/dist/control/task.cgc
CHANGED
|
Binary file
|
package/dist/global.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#cg-wrap{--cg:hsl(20, 100%,
|
|
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.
|
|
12
|
+
exports.init = 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
|
}
|
|
@@ -26,24 +30,16 @@ function getSafe() {
|
|
|
26
30
|
return exports.clickgo.getSafe();
|
|
27
31
|
}
|
|
28
32
|
exports.getSafe = getSafe;
|
|
29
|
-
function
|
|
30
|
-
exports.clickgo.setCdn(val);
|
|
31
|
-
}
|
|
32
|
-
exports.setCdn = setCdn;
|
|
33
|
-
function getCdn() {
|
|
34
|
-
return exports.clickgo.getCdn();
|
|
35
|
-
}
|
|
36
|
-
exports.getCdn = getCdn;
|
|
37
|
-
function init(cdn = 'https://cdn.jsdelivr.net') {
|
|
33
|
+
function init() {
|
|
38
34
|
var _a;
|
|
39
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
36
|
const paths = [
|
|
41
|
-
cdn + '/npm/vue@3.2.31/dist/vue.global.min.js'
|
|
37
|
+
loader.cdn + '/npm/vue@3.2.31/dist/vue.global.min.js'
|
|
42
38
|
];
|
|
43
39
|
let ro = true;
|
|
44
40
|
if (!(window.ResizeObserver)) {
|
|
45
41
|
ro = false;
|
|
46
|
-
paths.push(cdn + '/npm/@juggle/resize-observer@3.3.1/lib/exports/resize-observer.umd.min.js');
|
|
42
|
+
paths.push(loader.cdn + '/npm/@juggle/resize-observer@3.3.1/lib/exports/resize-observer.umd.min.js');
|
|
47
43
|
}
|
|
48
44
|
yield loader.loadScripts(paths);
|
|
49
45
|
if (!ro) {
|
|
@@ -51,22 +47,21 @@ function init(cdn = 'https://cdn.jsdelivr.net') {
|
|
|
51
47
|
window.ResizeObserver = window.ResizeObserver.ResizeObserver;
|
|
52
48
|
}
|
|
53
49
|
const map = {
|
|
54
|
-
'jszip': cdn + '/npm/jszip@3.10.0/dist/jszip.min'
|
|
50
|
+
'jszip': loader.cdn + '/npm/jszip@3.10.0/dist/jszip.min'
|
|
55
51
|
};
|
|
56
52
|
const after = '?' + Math.random().toString();
|
|
57
53
|
const files = yield loader.sniffFiles('clickgo.js', {
|
|
58
54
|
'dir': __dirname + '/',
|
|
59
55
|
'after': after,
|
|
60
|
-
'afterIgnore': new RegExp('^' + cdn.replace(/\./g, '\\.')),
|
|
56
|
+
'afterIgnore': new RegExp('^' + loader.cdn.replace(/\./g, '\\.')),
|
|
61
57
|
'map': map
|
|
62
58
|
});
|
|
63
59
|
const cg = loader.require('clickgo', files, {
|
|
64
60
|
'dir': __dirname + '/',
|
|
65
61
|
'map': map
|
|
66
62
|
})[0];
|
|
67
|
-
cg.setCdn(cdn);
|
|
68
63
|
try {
|
|
69
|
-
const style = yield (yield fetch(__dirname + '/global.css' + (!__dirname.startsWith(cdn) ? after : ''))).text();
|
|
64
|
+
const style = yield (yield fetch(__dirname + '/global.css' + (!__dirname.startsWith(loader.cdn) ? after : ''))).text();
|
|
70
65
|
(_a = document.getElementById('cg-global')) === null || _a === void 0 ? void 0 : _a.insertAdjacentHTML('afterbegin', style);
|
|
71
66
|
}
|
|
72
67
|
catch (_b) {
|
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
|
}
|
|
@@ -29,24 +33,17 @@ export function getSafe(): boolean {
|
|
|
29
33
|
return clickgo.getSafe();
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
export function
|
|
33
|
-
clickgo.setCdn(val);
|
|
34
|
-
}
|
|
35
|
-
export function getCdn(): string {
|
|
36
|
-
return clickgo.getCdn();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export async function init(cdn: string = 'https://cdn.jsdelivr.net'): Promise<void> {
|
|
36
|
+
export async function init(): Promise<void> {
|
|
40
37
|
// --- 通过标签加载库 ---
|
|
41
38
|
const paths: string[] = [
|
|
42
|
-
cdn + '/npm/vue@3.2.31/dist/vue.global.min.js'
|
|
39
|
+
loader.cdn + '/npm/vue@3.2.31/dist/vue.global.min.js'
|
|
43
40
|
];
|
|
44
41
|
// --- 判断 ResizeObserver 是否存在 ---
|
|
45
42
|
let ro = true;
|
|
46
43
|
// ResizeObserver = undefined;
|
|
47
44
|
if (!((window as any).ResizeObserver)) {
|
|
48
45
|
ro = false;
|
|
49
|
-
paths.push(cdn + '/npm/@juggle/resize-observer@3.3.1/lib/exports/resize-observer.umd.min.js');
|
|
46
|
+
paths.push(loader.cdn + '/npm/@juggle/resize-observer@3.3.1/lib/exports/resize-observer.umd.min.js');
|
|
50
47
|
}
|
|
51
48
|
// --- 加载 vue 以及必要库 ---
|
|
52
49
|
await loader.loadScripts(paths);
|
|
@@ -57,24 +54,23 @@ export async function init(cdn: string = 'https://cdn.jsdelivr.net'): Promise<vo
|
|
|
57
54
|
}
|
|
58
55
|
// --- map 加载库 ---
|
|
59
56
|
const map: Record<string, string> = {
|
|
60
|
-
'jszip': cdn + '/npm/jszip@3.10.0/dist/jszip.min'
|
|
57
|
+
'jszip': loader.cdn + '/npm/jszip@3.10.0/dist/jszip.min'
|
|
61
58
|
};
|
|
62
59
|
// --- 加载 clickgo 主程序 ---
|
|
63
60
|
const after = '?' + Math.random().toString();
|
|
64
61
|
const files = await loader.sniffFiles('clickgo.js', {
|
|
65
62
|
'dir': __dirname + '/',
|
|
66
63
|
'after': after,
|
|
67
|
-
'afterIgnore': new RegExp('^' + cdn.replace(/\./g, '\\.')),
|
|
64
|
+
'afterIgnore': new RegExp('^' + loader.cdn.replace(/\./g, '\\.')),
|
|
68
65
|
'map': map
|
|
69
66
|
});
|
|
70
67
|
const cg = loader.require('clickgo', files, {
|
|
71
68
|
'dir': __dirname + '/',
|
|
72
69
|
'map': map
|
|
73
70
|
})[0] as typeof import('../dist/clickgo');
|
|
74
|
-
cg.setCdn(cdn);
|
|
75
71
|
// --- 加载 clickgo 的 global css ---
|
|
76
72
|
try {
|
|
77
|
-
const style = await (await fetch(__dirname + '/global.css' + (!__dirname.startsWith(cdn) ? after : ''))).text();
|
|
73
|
+
const style = await (await fetch(__dirname + '/global.css' + (!__dirname.startsWith(loader.cdn) ? after : ''))).text();
|
|
78
74
|
document.getElementById('cg-global')?.insertAdjacentHTML('afterbegin', style);
|
|
79
75
|
}
|
|
80
76
|
catch {
|
package/dist/lib/core.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.getAvailArea = exports.fetchApp = exports.readApp = exports.trigger = exports.removeSystemEventListener = exports.setSystemEventListener = exports.globalEvents = exports.getModule = exports.initModules = exports.regModule = exports.config = void 0;
|
|
12
|
+
exports.getAvailArea = exports.fetchApp = exports.readApp = exports.trigger = exports.removeSystemEventListener = exports.setSystemEventListener = exports.globalEvents = exports.getModule = exports.initModules = exports.regModule = exports.cdn = exports.config = void 0;
|
|
13
13
|
const clickgo = require("../clickgo");
|
|
14
14
|
const fs = require("./fs");
|
|
15
15
|
const form = require("./form");
|
|
@@ -34,6 +34,7 @@ exports.config = clickgo.vue.reactive({
|
|
|
34
34
|
'desktop.wallpaper': null,
|
|
35
35
|
'desktop.path': null
|
|
36
36
|
});
|
|
37
|
+
exports.cdn = '';
|
|
37
38
|
clickgo.vue.watch(exports.config, function () {
|
|
38
39
|
for (const key in configOrigin) {
|
|
39
40
|
if (exports.config[key] !== undefined) {
|
|
@@ -87,7 +88,7 @@ const modules = {
|
|
|
87
88
|
func: function () {
|
|
88
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
90
|
return new Promise(function (resolve, reject) {
|
|
90
|
-
fetch(
|
|
91
|
+
fetch(loader.cdn + '/npm/monaco-editor@0.33.0/min/vs/loader.js').then(function (r) {
|
|
91
92
|
return r.blob();
|
|
92
93
|
}).then(function (b) {
|
|
93
94
|
return tool.blob2DataUrl(b);
|
|
@@ -496,7 +497,6 @@ function fetchApp(url, opt = {}) {
|
|
|
496
497
|
if (!opt.current.endsWith('/')) {
|
|
497
498
|
return null;
|
|
498
499
|
}
|
|
499
|
-
current = opt.current.slice(0, -1);
|
|
500
500
|
if (!url.startsWith('/')) {
|
|
501
501
|
url = '/current/' + url;
|
|
502
502
|
}
|
|
@@ -505,42 +505,37 @@ function fetchApp(url, opt = {}) {
|
|
|
505
505
|
if (!url.startsWith('/clickgo/') && !url.startsWith('/storage/') && !url.startsWith('/mounted/')) {
|
|
506
506
|
current = tool.urlResolve(window.location.href, url);
|
|
507
507
|
if (cga) {
|
|
508
|
-
current = current.slice(0, -cga.length
|
|
508
|
+
current = current.slice(0, -cga.length);
|
|
509
509
|
url = '/current/' + cga;
|
|
510
510
|
}
|
|
511
511
|
else {
|
|
512
|
-
current = current.slice(0, -1);
|
|
513
512
|
url = '/current/';
|
|
514
513
|
}
|
|
515
514
|
}
|
|
516
515
|
}
|
|
517
516
|
if (cga) {
|
|
518
|
-
|
|
517
|
+
try {
|
|
519
518
|
const blob = yield fs.getContent(url, {
|
|
520
519
|
'current': current,
|
|
521
|
-
progress: (loaded, total) => {
|
|
522
|
-
|
|
520
|
+
'progress': (loaded, total) => {
|
|
521
|
+
if (opt.notifyId) {
|
|
522
|
+
form.notifyProgress(opt.notifyId, loaded / total);
|
|
523
|
+
}
|
|
524
|
+
if (opt.progress) {
|
|
525
|
+
opt.progress(loaded, total);
|
|
526
|
+
}
|
|
523
527
|
}
|
|
524
528
|
});
|
|
525
|
-
if ((blob === null) ||
|
|
529
|
+
if ((blob === null) || typeof blob === 'string') {
|
|
526
530
|
return null;
|
|
527
531
|
}
|
|
528
|
-
|
|
532
|
+
if (opt.notifyId) {
|
|
533
|
+
form.notifyProgress(opt.notifyId, 1);
|
|
534
|
+
}
|
|
529
535
|
return (yield readApp(blob)) || null;
|
|
530
536
|
}
|
|
531
|
-
|
|
532
|
-
|
|
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
|
-
}
|
|
537
|
+
catch (_a) {
|
|
538
|
+
return null;
|
|
544
539
|
}
|
|
545
540
|
}
|
|
546
541
|
let config;
|
package/dist/lib/core.ts
CHANGED
|
@@ -40,6 +40,8 @@ export const config: types.IConfig = clickgo.vue.reactive({
|
|
|
40
40
|
'desktop.path': null
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
export const cdn = '';
|
|
44
|
+
|
|
43
45
|
clickgo.vue.watch(config, function() {
|
|
44
46
|
// --- 检测有没有缺少的 config key ---
|
|
45
47
|
for (const key in configOrigin) {
|
|
@@ -97,7 +99,7 @@ const modules: Record<string, { func: () => any | Promise<any>; 'obj': null | an
|
|
|
97
99
|
'monaco': {
|
|
98
100
|
func: async function() {
|
|
99
101
|
return new Promise(function(resolve, reject) {
|
|
100
|
-
fetch(
|
|
102
|
+
fetch(loader.cdn + '/npm/monaco-editor@0.33.0/min/vs/loader.js').then(function(r) {
|
|
101
103
|
return r.blob();
|
|
102
104
|
}).then(function(b) {
|
|
103
105
|
return tool.blob2DataUrl(b);
|
|
@@ -538,7 +540,7 @@ export async function readApp(blob: Blob): Promise<false | types.IApp> {
|
|
|
538
540
|
/**
|
|
539
541
|
* --- 从网址下载应用,App 模式下本方法不可用 ---
|
|
540
542
|
* @param url 对于当前网页的相对、绝对路径,以 / 结尾的目录或 .cga 结尾的文件 ---
|
|
541
|
-
* @param opt,notifyId:显示进度条的 notify id,current
|
|
543
|
+
* @param opt,notifyId:显示进度条的 notify id,current:设置则以设置的为准,以 / 结尾,否则以 location 为准 ---
|
|
542
544
|
*/
|
|
543
545
|
export async function fetchApp(url: string, opt: types.ICoreFetchAppOptions = {}): Promise<null | types.IApp> {
|
|
544
546
|
/** --- 若是 cga 文件,则是 cga 的文件名,含 .cga --- */
|
|
@@ -556,7 +558,6 @@ export async function fetchApp(url: string, opt: types.ICoreFetchAppOptions = {}
|
|
|
556
558
|
if (!opt.current.endsWith('/')) {
|
|
557
559
|
return null;
|
|
558
560
|
}
|
|
559
|
-
current = opt.current.slice(0, -1);
|
|
560
561
|
if (!url.startsWith('/')) {
|
|
561
562
|
url = '/current/' + url;
|
|
562
563
|
}
|
|
@@ -565,11 +566,10 @@ export async function fetchApp(url: string, opt: types.ICoreFetchAppOptions = {}
|
|
|
565
566
|
if (!url.startsWith('/clickgo/') && !url.startsWith('/storage/') && !url.startsWith('/mounted/')) {
|
|
566
567
|
current = tool.urlResolve(window.location.href, url);
|
|
567
568
|
if (cga) {
|
|
568
|
-
current = current.slice(0, -cga.length
|
|
569
|
+
current = current.slice(0, -cga.length);
|
|
569
570
|
url = '/current/' + cga;
|
|
570
571
|
}
|
|
571
572
|
else {
|
|
572
|
-
current = current.slice(0, -1);
|
|
573
573
|
url = '/current/';
|
|
574
574
|
}
|
|
575
575
|
}
|
|
@@ -577,32 +577,28 @@ export async function fetchApp(url: string, opt: types.ICoreFetchAppOptions = {}
|
|
|
577
577
|
|
|
578
578
|
// --- 如果是 cga 文件,直接读取并交给 readApp 函数处理 ---
|
|
579
579
|
if (cga) {
|
|
580
|
-
|
|
580
|
+
try {
|
|
581
581
|
const blob = await fs.getContent(url, {
|
|
582
582
|
'current': current,
|
|
583
|
-
progress: (loaded, total): void => {
|
|
584
|
-
|
|
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) ||
|
|
592
|
+
if ((blob === null) || typeof blob === 'string') {
|
|
588
593
|
return null;
|
|
589
594
|
}
|
|
590
|
-
|
|
595
|
+
if (opt.notifyId) {
|
|
596
|
+
form.notifyProgress(opt.notifyId, 1);
|
|
597
|
+
}
|
|
591
598
|
return await readApp(blob) || null;
|
|
592
599
|
}
|
|
593
|
-
|
|
594
|
-
|
|
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;
|
|
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 =
|
|
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;
|
|
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 =
|
|
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',
|
|
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',
|
|
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-
|
|
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
|
|
137
|
-
'template': '<div v-for="(item, formId) of forms" class="cg-
|
|
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
|
-
|
|
178
|
+
simpletaskApp.mount('#cg-simpletask');
|
|
173
179
|
}
|
|
174
180
|
};
|
|
175
181
|
elements.init();
|
|
@@ -1089,12 +1095,12 @@ 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
|
},
|
|
1095
|
-
getCdn() {
|
|
1096
|
-
return clickgo.getCdn();
|
|
1097
|
-
},
|
|
1098
1104
|
'control': {
|
|
1099
1105
|
read: function (blob) {
|
|
1100
1106
|
return clickgo.control.read(blob);
|
|
@@ -1102,6 +1108,7 @@ function create(opt) {
|
|
|
1102
1108
|
},
|
|
1103
1109
|
'core': {
|
|
1104
1110
|
'config': clickgo.core.config,
|
|
1111
|
+
'cdn': loader.cdn,
|
|
1105
1112
|
initModules: function (names) {
|
|
1106
1113
|
return clickgo.core.initModules(names);
|
|
1107
1114
|
},
|
|
@@ -1448,6 +1455,18 @@ function create(opt) {
|
|
|
1448
1455
|
},
|
|
1449
1456
|
clearListener: function () {
|
|
1450
1457
|
clickgo.native.clearListener(taskId);
|
|
1458
|
+
},
|
|
1459
|
+
max: function () {
|
|
1460
|
+
clickgo.native.max();
|
|
1461
|
+
},
|
|
1462
|
+
min: function () {
|
|
1463
|
+
clickgo.native.min();
|
|
1464
|
+
},
|
|
1465
|
+
restore: function () {
|
|
1466
|
+
clickgo.native.restore();
|
|
1467
|
+
},
|
|
1468
|
+
size: function (width, height) {
|
|
1469
|
+
clickgo.native.size(width, height);
|
|
1451
1470
|
}
|
|
1452
1471
|
},
|
|
1453
1472
|
'task': {
|
|
@@ -1468,6 +1487,7 @@ function create(opt) {
|
|
|
1468
1487
|
},
|
|
1469
1488
|
run: function (url, opt = {}) {
|
|
1470
1489
|
opt.taskId = taskId;
|
|
1490
|
+
opt.main = false;
|
|
1471
1491
|
return clickgo.task.run(url, opt);
|
|
1472
1492
|
},
|
|
1473
1493
|
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',
|
|
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',
|
|
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-
|
|
191
|
-
this.simpleSystemtask.id = 'cg-
|
|
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
|
|
203
|
-
'template': '<div v-for="(item, formId) of forms" class="cg-
|
|
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
|
-
|
|
244
|
+
simpletaskApp.mount('#cg-simpletask');
|
|
239
245
|
}
|
|
240
246
|
};
|
|
241
247
|
elements.init();
|
|
@@ -1365,12 +1371,12 @@ 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
|
},
|
|
1371
|
-
getCdn(): string {
|
|
1372
|
-
return clickgo.getCdn();
|
|
1373
|
-
},
|
|
1374
1380
|
'control': {
|
|
1375
1381
|
read: function(blob: Blob): Promise<false | types.TControl> {
|
|
1376
1382
|
return clickgo.control.read(blob);
|
|
@@ -1378,6 +1384,7 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
|
|
|
1378
1384
|
},
|
|
1379
1385
|
'core': {
|
|
1380
1386
|
'config': clickgo.core.config,
|
|
1387
|
+
'cdn': loader.cdn,
|
|
1381
1388
|
initModules: function(names: string | string[]): Promise<number> {
|
|
1382
1389
|
return clickgo.core.initModules(names);
|
|
1383
1390
|
},
|
|
@@ -1762,6 +1769,18 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
|
|
|
1762
1769
|
},
|
|
1763
1770
|
clearListener: function(): void {
|
|
1764
1771
|
clickgo.native.clearListener(taskId);
|
|
1772
|
+
},
|
|
1773
|
+
max: function(): void {
|
|
1774
|
+
clickgo.native.max();
|
|
1775
|
+
},
|
|
1776
|
+
min: function(): void {
|
|
1777
|
+
clickgo.native.min();
|
|
1778
|
+
},
|
|
1779
|
+
restore: function(): void {
|
|
1780
|
+
clickgo.native.restore();
|
|
1781
|
+
},
|
|
1782
|
+
size: function(width: number, height: number): void {
|
|
1783
|
+
clickgo.native.size(width, height);
|
|
1765
1784
|
}
|
|
1766
1785
|
},
|
|
1767
1786
|
'task': {
|
|
@@ -1789,6 +1808,7 @@ export async function create(opt: string | types.IFormCreateOptions): Promise<nu
|
|
|
1789
1808
|
},
|
|
1790
1809
|
run: function(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
|
|
1791
1810
|
opt.taskId = taskId;
|
|
1811
|
+
opt.main = false;
|
|
1792
1812
|
return clickgo.task.run(url, opt);
|
|
1793
1813
|
},
|
|
1794
1814
|
end: function(tid: number): boolean {
|
package/dist/lib/native.js
CHANGED
|
@@ -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 = [];
|
package/dist/lib/native.ts
CHANGED
|
@@ -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.
|
|
162
|
-
opt.
|
|
161
|
+
if (opt.notify === undefined) {
|
|
162
|
+
opt.notify = true;
|
|
163
163
|
}
|
|
164
|
-
const notifyId = opt.
|
|
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 (
|
|
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.
|
|
214
|
-
opt.
|
|
213
|
+
if (opt.notify === undefined) {
|
|
214
|
+
opt.notify = true;
|
|
215
215
|
}
|
|
216
|
-
const notifyId: number | undefined = opt.
|
|
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]
|
package/dist/theme/familiar.cgt
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clickgo",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4-dev5",
|
|
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
|
-
"@litert/loader": "^3.
|
|
21
|
+
"@litert/loader": "^3.3.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": "^
|
|
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,12 +11,11 @@ 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
|
-
export function setCdn(val: string): void;
|
|
17
|
-
export function getCdn(): string;
|
|
18
17
|
|
|
19
|
-
export function init(
|
|
18
|
+
export function init(): Promise<void>;
|
|
20
19
|
|
|
21
20
|
// --- core 核心 ---
|
|
22
21
|
|
|
@@ -84,6 +83,7 @@ export type TGlobalEvent = 'error' | 'screenResize' | 'configChanged' | 'formCre
|
|
|
84
83
|
export interface ICoreFetchAppOptions {
|
|
85
84
|
'notifyId'?: number;
|
|
86
85
|
'current'?: string;
|
|
86
|
+
'progress'?: (loaded: number, total: number) => void | Promise<void>;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/** --- 应用文件包 --- */
|
|
@@ -341,7 +341,10 @@ export interface ISystemTaskInfo {
|
|
|
341
341
|
|
|
342
342
|
export interface ITaskRunOptions {
|
|
343
343
|
'icon'?: string;
|
|
344
|
-
'progress'?:
|
|
344
|
+
'progress'?: (loaded: number, total: number) => void | Promise<void>;
|
|
345
|
+
'notify'?: boolean;
|
|
346
|
+
'main'?: boolean;
|
|
347
|
+
'sync'?: boolean;
|
|
345
348
|
'taskId'?: number;
|
|
346
349
|
}
|
|
347
350
|
|
|
@@ -367,6 +370,7 @@ export interface ITask {
|
|
|
367
370
|
/** --- 当前 app 运行路径,末尾包含 / --- */
|
|
368
371
|
'path': string;
|
|
369
372
|
'files': Record<string, Blob | string>;
|
|
373
|
+
'main': boolean;
|
|
370
374
|
|
|
371
375
|
/** --- 已申请的权限列表 --- */
|
|
372
376
|
'permissions': Record<string, any>;
|