clickgo 3.1.4-dev13 → 3.1.5-dev14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/app/demo/app.js +1 -1
- package/dist/app/demo/config.json +5 -2
- package/dist/app/demo/form/control/text/text.js +1 -0
- package/dist/app/demo/form/control/text/text.xml +1 -1
- package/dist/app/demo/form/main.js +47 -52
- package/dist/app/demo/form/method/aform/aform.js +1 -13
- package/dist/app/demo/form/method/aform/aform.xml +0 -1
- package/dist/app/demo/form/method/aform/sd.js +1 -4
- package/dist/app/demo/form/method/form/form.js +5 -6
- package/dist/app/demo/form/method/form/form.xml +1 -0
- package/dist/app/demo/form/method/{aform → form}/test.xml +0 -0
- package/dist/app/demo/form/method/fs/fs.js +1 -4
- package/dist/app/demo/form/method/tool/tool.js +3 -0
- package/dist/app/demo/form/method/tool/tool.xml +1 -0
- package/dist/app/demo/form/method/zip/zip.js +1 -4
- package/dist/app/task/app.js +1 -1
- package/dist/control/common.cgc +0 -0
- package/dist/lib/core.js +0 -5
- package/dist/lib/core.ts +1 -7
- package/dist/lib/form.js +163 -182
- package/dist/lib/form.ts +200 -212
- package/dist/lib/fs.js +1 -1
- package/dist/lib/fs.ts +1 -1
- package/dist/lib/task.js +16 -3
- package/dist/lib/task.ts +24 -3
- package/dist/lib/tool.js +39 -1
- package/dist/lib/tool.ts +45 -0
- package/package.json +2 -2
- package/types/index.d.ts +9 -36
package/dist/lib/form.ts
CHANGED
|
@@ -81,89 +81,6 @@ const info: {
|
|
|
81
81
|
/** --- 窗体的抽象类 --- */
|
|
82
82
|
export abstract class AbstractForm {
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
* --- 创建窗体工厂函数 ---
|
|
86
|
-
* @param data 要传递的对象
|
|
87
|
-
* @param layout 是否使用此参数替换 layout 值
|
|
88
|
-
*/
|
|
89
|
-
public static async create(data?: Record<string, any>, layout?: string): Promise<AbstractForm | number> {
|
|
90
|
-
const frm: AbstractForm = new (this as any)();
|
|
91
|
-
/** --- 要挂载的 vue 参数 --- */
|
|
92
|
-
const code: types.IFormCreateCode = {
|
|
93
|
-
'data': {},
|
|
94
|
-
'methods': {},
|
|
95
|
-
'computed': {},
|
|
96
|
-
|
|
97
|
-
beforeCreate: (frm as any).onBeforeCreate,
|
|
98
|
-
created: function(this: types.IVue) {
|
|
99
|
-
this.onCreated();
|
|
100
|
-
},
|
|
101
|
-
beforeMount: function(this: types.IVue) {
|
|
102
|
-
this.onBeforeMount();
|
|
103
|
-
},
|
|
104
|
-
mounted: function(this: types.IVue, data?: Record<string, any>) {
|
|
105
|
-
// await this.$nextTick();
|
|
106
|
-
// --- form 不用 nextTick,因为全部处理完后才会主动调用本方法 ---
|
|
107
|
-
this.onMounted(data);
|
|
108
|
-
},
|
|
109
|
-
beforeUpdate: function(this: types.IVue) {
|
|
110
|
-
this.onBeforeUpdate();
|
|
111
|
-
},
|
|
112
|
-
updated: async function(this: types.IVue) {
|
|
113
|
-
await this.$nextTick();
|
|
114
|
-
this.onUpdated();
|
|
115
|
-
},
|
|
116
|
-
beforeUnmount: function(this: types.IVue) {
|
|
117
|
-
this.onBeforeUnmount();
|
|
118
|
-
},
|
|
119
|
-
unmounted: async function(this: types.IVue) {
|
|
120
|
-
await this.$nextTick();
|
|
121
|
-
this.onUnmounted();
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
/** --- class 对象类的属性列表 --- */
|
|
125
|
-
const cdata = Object.entries(frm);
|
|
126
|
-
for (const item of cdata) {
|
|
127
|
-
if (item[0] === 'access') {
|
|
128
|
-
// --- access 属性不放在 data 当中 ---
|
|
129
|
-
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
code.data![item[0]] = item[1];
|
|
133
|
-
}
|
|
134
|
-
if (!layout) {
|
|
135
|
-
const l = task.list[frm.taskId].app.files[frm.filename.slice(0, -2) + 'xml'];
|
|
136
|
-
if (typeof l !== 'string') {
|
|
137
|
-
return 0;
|
|
138
|
-
}
|
|
139
|
-
layout = l;
|
|
140
|
-
}
|
|
141
|
-
const prot = tool.getClassPrototype(frm);
|
|
142
|
-
code.methods = prot.method;
|
|
143
|
-
code.computed = prot.access;
|
|
144
|
-
// --- 窗体样式 ---
|
|
145
|
-
let style: string | undefined = undefined;
|
|
146
|
-
const fstyle = task.list[frm.taskId].app.files[frm.filename.slice(0, -2) + 'css'];
|
|
147
|
-
if (typeof fstyle === 'string') {
|
|
148
|
-
style = fstyle;
|
|
149
|
-
}
|
|
150
|
-
const fid = await create({
|
|
151
|
-
'code': code,
|
|
152
|
-
'layout': layout,
|
|
153
|
-
'style': style,
|
|
154
|
-
|
|
155
|
-
'path': frm.filename.slice(0, frm.filename.lastIndexOf('/')),
|
|
156
|
-
'data': data,
|
|
157
|
-
'taskId': frm.taskId
|
|
158
|
-
});
|
|
159
|
-
if (fid > 0) {
|
|
160
|
-
return task.list[frm.taskId].forms[fid].vroot as any;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return fid;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
84
|
/** --- 当前文件路径 --- */
|
|
168
85
|
public get filename(): string {
|
|
169
86
|
// --- require 时系统自动在继承类中重写本函数 ---
|
|
@@ -304,26 +221,6 @@ export abstract class AbstractForm {
|
|
|
304
221
|
|
|
305
222
|
// --- 以下为窗体有,但 control 没有 ---
|
|
306
223
|
|
|
307
|
-
/**
|
|
308
|
-
* --- 无 js 文件的窗体创建 ---
|
|
309
|
-
* @param path 包内相对于本窗体的路径或包内绝对路径,不含扩展名
|
|
310
|
-
* @param data 要传递的值
|
|
311
|
-
*/
|
|
312
|
-
public async createForm(path: string, data?: Record<string, any>): Promise<AbstractForm | number> {
|
|
313
|
-
path = tool.urlResolve(this.filename, path);
|
|
314
|
-
const taskId = this.taskId;
|
|
315
|
-
const cls = class extends AbstractForm {
|
|
316
|
-
public get filename(): string {
|
|
317
|
-
return path + '.js';
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
public get taskId(): number {
|
|
321
|
-
return taskId;
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
return cls.create(data);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
224
|
/** --- 是否是置顶 --- */
|
|
328
225
|
public get topMost(): boolean {
|
|
329
226
|
// --- 将在初始化时系统自动重写本函数 ---
|
|
@@ -362,8 +259,7 @@ export abstract class AbstractForm {
|
|
|
362
259
|
*/
|
|
363
260
|
public show(): void {
|
|
364
261
|
// --- 创建成功的窗体,可以直接显示 ---
|
|
365
|
-
const v = this as
|
|
366
|
-
v.$refs.form.$data.isShow = true;
|
|
262
|
+
const v = this as unknown as types.IVue;
|
|
367
263
|
if (this._firstShow) {
|
|
368
264
|
this._firstShow = false;
|
|
369
265
|
// --- 将窗体居中 ---
|
|
@@ -379,6 +275,9 @@ export abstract class AbstractForm {
|
|
|
379
275
|
v.$refs.form.$data.isShow = true;
|
|
380
276
|
changeFocus(this.formId);
|
|
381
277
|
}
|
|
278
|
+
else {
|
|
279
|
+
v.$refs.form.$data.isShow = true;
|
|
280
|
+
}
|
|
382
281
|
}
|
|
383
282
|
|
|
384
283
|
/**
|
|
@@ -1937,63 +1836,112 @@ function getForm(taskId: number, formId: number): types.IForm | null {
|
|
|
1937
1836
|
}
|
|
1938
1837
|
|
|
1939
1838
|
/**
|
|
1940
|
-
* ---
|
|
1941
|
-
* @param
|
|
1839
|
+
* --- 创建一个窗体 ---
|
|
1840
|
+
* @param cls 路径字符串或 AbstractForm 类
|
|
1841
|
+
* @param data 要传递的对象
|
|
1842
|
+
* @param opt 其他替换选项
|
|
1843
|
+
* @param taskId App 模式下无效
|
|
1942
1844
|
*/
|
|
1943
|
-
export async function create
|
|
1944
|
-
|
|
1945
|
-
|
|
1845
|
+
export async function create<T extends AbstractForm>(
|
|
1846
|
+
cls: string | (new () => T),
|
|
1847
|
+
data?: Record<string, any>,
|
|
1848
|
+
opt: {
|
|
1849
|
+
'layout'?: string;
|
|
1850
|
+
'style'?: string;
|
|
1851
|
+
/** --- cls 为 string 时,path 参数才有效,为基准路径,如果不以 / 结尾则以最后一个 / 字符为准 --- */
|
|
1852
|
+
'path'?: string;
|
|
1853
|
+
} = {},
|
|
1854
|
+
taskId?: number
|
|
1855
|
+
): Promise<T> {
|
|
1856
|
+
if (!taskId) {
|
|
1857
|
+
const err = new Error('form.create: -1');
|
|
1858
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1859
|
+
throw err;
|
|
1946
1860
|
}
|
|
1947
1861
|
/** --- 当前的 task 对象 --- */
|
|
1948
|
-
const t = task.list[
|
|
1862
|
+
const t = task.list[taskId];
|
|
1949
1863
|
if (!t) {
|
|
1950
|
-
|
|
1864
|
+
const err = new Error('form.create: -2');
|
|
1865
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1866
|
+
throw err;
|
|
1867
|
+
}
|
|
1868
|
+
/** --- 布局内容 --- */
|
|
1869
|
+
let layout: string = '';
|
|
1870
|
+
if (opt.layout) {
|
|
1871
|
+
layout = opt.layout;
|
|
1872
|
+
}
|
|
1873
|
+
/** --- 样式内容 --- */
|
|
1874
|
+
let style: string = '';
|
|
1875
|
+
if (opt.style) {
|
|
1876
|
+
style = opt.style;
|
|
1951
1877
|
}
|
|
1878
|
+
/** --- 样式前缀 --- */
|
|
1879
|
+
let prep = '';
|
|
1880
|
+
/** --- 文件在包内的路径,不以 / 结尾 --- */
|
|
1881
|
+
let filename = '';
|
|
1882
|
+
if (typeof cls === 'string') {
|
|
1883
|
+
filename = tool.urlResolve(opt.path ?? '/', cls);
|
|
1884
|
+
if (!layout) {
|
|
1885
|
+
const l = t.app.files[filename + '.xml'];
|
|
1886
|
+
if (typeof l !== 'string') {
|
|
1887
|
+
const err = new Error('form.create: -3');
|
|
1888
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1889
|
+
throw err;
|
|
1890
|
+
}
|
|
1891
|
+
layout = l;
|
|
1892
|
+
}
|
|
1893
|
+
if (!style) {
|
|
1894
|
+
const s = t.app.files[filename + '.css'];
|
|
1895
|
+
if (typeof s === 'string') {
|
|
1896
|
+
style = s;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
cls = class extends AbstractForm {
|
|
1900
|
+
public get filename(): string {
|
|
1901
|
+
return filename + '.js';
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
public get taskId(): number {
|
|
1905
|
+
return t.id;
|
|
1906
|
+
}
|
|
1907
|
+
} as (new () => T);
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1952
1910
|
// --- 申请 formId ---
|
|
1953
1911
|
const formId = ++info.lastId;
|
|
1954
|
-
|
|
1955
|
-
const
|
|
1956
|
-
if (!
|
|
1957
|
-
|
|
1958
|
-
}
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
let updated: (() => void) | undefined = undefined;
|
|
1970
|
-
let beforeUnmount: (() => void) | undefined = undefined;
|
|
1971
|
-
let unmounted: (() => void) | undefined = undefined;
|
|
1972
|
-
if (opt.code) {
|
|
1973
|
-
data = opt.code.data ?? {};
|
|
1974
|
-
access = opt.code.access ?? {};
|
|
1975
|
-
methods = opt.code.methods;
|
|
1976
|
-
computed = opt.code.computed ?? {};
|
|
1977
|
-
beforeCreate = opt.code.beforeCreate;
|
|
1978
|
-
created = opt.code.created;
|
|
1979
|
-
beforeMount = opt.code.beforeMount;
|
|
1980
|
-
mounted = opt.code.mounted;
|
|
1981
|
-
beforeUpdate = opt.code.beforeUpdate;
|
|
1982
|
-
updated = opt.code.updated;
|
|
1983
|
-
beforeUnmount = opt.code.beforeUnmount;
|
|
1984
|
-
unmounted = opt.code.unmounted;
|
|
1985
|
-
}
|
|
1986
|
-
// --- 应用样式表 ---
|
|
1987
|
-
let style = '';
|
|
1988
|
-
let prep = '';
|
|
1989
|
-
if (opt.style) {
|
|
1912
|
+
/** --- 要新建的窗体类对象 --- */
|
|
1913
|
+
const frm = new cls();
|
|
1914
|
+
if (!filename) {
|
|
1915
|
+
filename = frm.filename;
|
|
1916
|
+
}
|
|
1917
|
+
const lio = filename.lastIndexOf('/');
|
|
1918
|
+
const path = filename.slice(0, lio);
|
|
1919
|
+
// --- 样式 ---
|
|
1920
|
+
if (!style) {
|
|
1921
|
+
const s = t.app.files[filename.slice(0, -2) + 'css'];
|
|
1922
|
+
if (typeof s === 'string') {
|
|
1923
|
+
style = s;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
if (style) {
|
|
1990
1927
|
// --- 将 style 中的 tag 标签转换为 class,如 button 变为 .tag-button,然后将 class 进行标准程序,添加 prep 进行区分隔离 ---
|
|
1991
|
-
const r = tool.stylePrepend(
|
|
1928
|
+
const r = tool.stylePrepend(style);
|
|
1992
1929
|
prep = r.prep;
|
|
1993
|
-
style = await tool.styleUrl2DataUrl(
|
|
1930
|
+
style = await tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
|
|
1931
|
+
}
|
|
1932
|
+
|
|
1933
|
+
// --- 布局 ---
|
|
1934
|
+
if (!layout) {
|
|
1935
|
+
const l = t.app.files[frm.filename.slice(0, -2) + 'xml'];
|
|
1936
|
+
if (typeof l !== 'string') {
|
|
1937
|
+
const err = new Error('form.create: -4');
|
|
1938
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1939
|
+
throw err;
|
|
1940
|
+
}
|
|
1941
|
+
layout = l;
|
|
1994
1942
|
}
|
|
1995
|
-
// ---
|
|
1996
|
-
|
|
1943
|
+
// --- 纯净化 ---
|
|
1944
|
+
layout = tool.purify(layout);
|
|
1997
1945
|
// --- 标签增加 cg- 前缀,增加 class 为 tag-xxx ---
|
|
1998
1946
|
layout = tool.layoutAddTagClassAndReTagName(layout, true);
|
|
1999
1947
|
// --- 给所有控件传递窗体的 focus 信息 ---
|
|
@@ -2001,7 +1949,7 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2001
1949
|
'include': [/^cg-.+/]
|
|
2002
1950
|
});
|
|
2003
1951
|
// --- 给 layout 的 class 增加前置 ---
|
|
2004
|
-
const prepList = ['cg-task' +
|
|
1952
|
+
const prepList = ['cg-task' + t.id.toString() + '_'];
|
|
2005
1953
|
if (prep !== '') {
|
|
2006
1954
|
prepList.push(prep);
|
|
2007
1955
|
}
|
|
@@ -2017,17 +1965,37 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2017
1965
|
if (layout.includes('<teleport')) {
|
|
2018
1966
|
layout = tool.teleportGlue(layout, formId);
|
|
2019
1967
|
}
|
|
2020
|
-
// ---
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
1968
|
+
// --- 获取要定义的控件列表 ---
|
|
1969
|
+
const components = control.buildComponents(t.id, formId, path);
|
|
1970
|
+
if (!components) {
|
|
1971
|
+
const err = new Error('form.create: -5');
|
|
1972
|
+
core.trigger('error', 0, 0, err, err.message);
|
|
1973
|
+
throw err;
|
|
1974
|
+
}
|
|
1975
|
+
/** --- class 对象类的属性列表 --- */
|
|
1976
|
+
const idata: Record<string, any> = {};
|
|
1977
|
+
const cdata = Object.entries(frm);
|
|
1978
|
+
for (const item of cdata) {
|
|
1979
|
+
if (item[0] === 'access') {
|
|
1980
|
+
// --- access 属性不放在 data 当中 ---
|
|
1981
|
+
continue;
|
|
1982
|
+
}
|
|
1983
|
+
idata[item[0]] = item[1];
|
|
1984
|
+
}
|
|
1985
|
+
idata._formFocus = false;
|
|
1986
|
+
// --- 判断是否要与 native 实体窗体大小同步 ---
|
|
1987
|
+
if (clickgo.isNative() && (formId === 1) && !clickgo.isImmersion() && !clickgo.hasFrame()) {
|
|
1988
|
+
idata.isNativeSync = true;
|
|
1989
|
+
}
|
|
1990
|
+
/** --- class 对象的方法和 getter/setter 列表 --- */
|
|
1991
|
+
const prot = tool.getClassPrototype(frm);
|
|
1992
|
+
const methods = prot.method;
|
|
1993
|
+
const computed = prot.access;
|
|
2026
1994
|
computed.formId = {
|
|
2027
1995
|
get: function(): number {
|
|
2028
1996
|
return formId;
|
|
2029
1997
|
},
|
|
2030
|
-
set: function(): void {
|
|
1998
|
+
set: function(this: types.IVue): void {
|
|
2031
1999
|
notify({
|
|
2032
2000
|
'title': 'Error',
|
|
2033
2001
|
'content': `The software tries to modify the system variable "formId".\nPath: ${this.filename}`,
|
|
@@ -2036,12 +2004,11 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2036
2004
|
return;
|
|
2037
2005
|
}
|
|
2038
2006
|
};
|
|
2039
|
-
data._formFocus = false;
|
|
2040
2007
|
computed.path = {
|
|
2041
2008
|
get: function(): string {
|
|
2042
|
-
return
|
|
2009
|
+
return path;
|
|
2043
2010
|
},
|
|
2044
|
-
set: function(): void {
|
|
2011
|
+
set: function(this: types.IVue): void {
|
|
2045
2012
|
notify({
|
|
2046
2013
|
'title': 'Error',
|
|
2047
2014
|
'content': `The software tries to modify the system variable "path".\nPath: ${this.filename}`,
|
|
@@ -2054,7 +2021,7 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2054
2021
|
get: function(): string {
|
|
2055
2022
|
return prep;
|
|
2056
2023
|
},
|
|
2057
|
-
set: function(): void {
|
|
2024
|
+
set: function(this: types.IVue): void {
|
|
2058
2025
|
notify({
|
|
2059
2026
|
'title': 'Error',
|
|
2060
2027
|
'content': `The software tries to modify the system variable "cgPrep".\nPath: ${this.filename}`,
|
|
@@ -2064,9 +2031,9 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2064
2031
|
}
|
|
2065
2032
|
};
|
|
2066
2033
|
// --- 是否在顶层的窗体 ---
|
|
2067
|
-
|
|
2034
|
+
idata._topMost = false;
|
|
2068
2035
|
computed.topMost = {
|
|
2069
|
-
get: function(): number {
|
|
2036
|
+
get: function(this: types.IVue): number {
|
|
2070
2037
|
return this._topMost;
|
|
2071
2038
|
},
|
|
2072
2039
|
set: function(v: boolean): void {
|
|
@@ -2092,15 +2059,16 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2092
2059
|
return;
|
|
2093
2060
|
}
|
|
2094
2061
|
};
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
}
|
|
2099
|
-
// --- 挂载 style ---
|
|
2062
|
+
|
|
2063
|
+
// --- 插入 dom ---
|
|
2064
|
+
elements.list.insertAdjacentHTML('beforeend', `<div class="cg-form-wrap" data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
|
|
2065
|
+
elements.popList.insertAdjacentHTML('beforeend', `<div data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
|
|
2100
2066
|
if (style) {
|
|
2101
|
-
|
|
2102
|
-
dom.pushStyle(opt.taskId, style, 'form', formId);
|
|
2067
|
+
dom.pushStyle(t.id, style, 'form', formId);
|
|
2103
2068
|
}
|
|
2069
|
+
/** --- form wrap element 对象 --- */
|
|
2070
|
+
const el: HTMLElement = elements.list.children.item(elements.list.children.length - 1) as HTMLElement;
|
|
2071
|
+
|
|
2104
2072
|
// --- 创建 app 对象 ---
|
|
2105
2073
|
const rtn: {
|
|
2106
2074
|
'vapp': types.IVApp;
|
|
@@ -2109,17 +2077,21 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2109
2077
|
const vapp = clickgo.vue.createApp({
|
|
2110
2078
|
'template': layout.replace(/^<cg-form/, '<cg-form ref="form"'),
|
|
2111
2079
|
'data': function() {
|
|
2112
|
-
return tool.clone(
|
|
2080
|
+
return tool.clone(idata);
|
|
2113
2081
|
},
|
|
2114
2082
|
'methods': methods,
|
|
2115
2083
|
'computed': computed,
|
|
2116
2084
|
|
|
2117
|
-
'beforeCreate':
|
|
2085
|
+
'beforeCreate': (frm as any).onBeforeCreate,
|
|
2118
2086
|
'created': function(this: types.IVue) {
|
|
2119
|
-
|
|
2120
|
-
|
|
2087
|
+
if ((frm as any).access) {
|
|
2088
|
+
this.access = tool.clone((frm as any).access);
|
|
2089
|
+
}
|
|
2090
|
+
this.onCreated();
|
|
2091
|
+
},
|
|
2092
|
+
'beforeMount': function(this: types.IVue) {
|
|
2093
|
+
this.onBeforeMount();
|
|
2121
2094
|
},
|
|
2122
|
-
'beforeMount': beforeMount,
|
|
2123
2095
|
'mounted': async function(this: types.IVue) {
|
|
2124
2096
|
await this.$nextTick();
|
|
2125
2097
|
// --- 判断是否有 icon,对 icon 进行第一次读取 ---
|
|
@@ -2138,10 +2110,20 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2138
2110
|
'vroot': this
|
|
2139
2111
|
});
|
|
2140
2112
|
},
|
|
2141
|
-
'beforeUpdate':
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
'
|
|
2113
|
+
'beforeUpdate': function(this: types.IVue) {
|
|
2114
|
+
this.onBeforeUpdate();
|
|
2115
|
+
},
|
|
2116
|
+
'updated': async function(this: types.IVue) {
|
|
2117
|
+
await this.$nextTick();
|
|
2118
|
+
this.onUpdated();
|
|
2119
|
+
},
|
|
2120
|
+
'beforeUnmount': function(this: types.IVue) {
|
|
2121
|
+
this.onBeforeUnmount();
|
|
2122
|
+
},
|
|
2123
|
+
'unmounted': async function(this: types.IVue) {
|
|
2124
|
+
await this.$nextTick();
|
|
2125
|
+
this.onUnmounted();
|
|
2126
|
+
}
|
|
2145
2127
|
});
|
|
2146
2128
|
vapp.config.errorHandler = function(err: Error, vm: types.IVue, info: string): void {
|
|
2147
2129
|
notify({
|
|
@@ -2161,10 +2143,10 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2161
2143
|
catch (err: any) {
|
|
2162
2144
|
notify({
|
|
2163
2145
|
'title': 'Runtime Error',
|
|
2164
|
-
'content': `Message: ${err.message}\nTask id: ${
|
|
2146
|
+
'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
|
|
2165
2147
|
'type': 'danger'
|
|
2166
2148
|
});
|
|
2167
|
-
core.trigger('error',
|
|
2149
|
+
core.trigger('error', t.id, formId, err, err.message);
|
|
2168
2150
|
}
|
|
2169
2151
|
});
|
|
2170
2152
|
// --- 创建 form 信息对象 ---
|
|
@@ -2177,38 +2159,36 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2177
2159
|
t.forms[formId] = nform;
|
|
2178
2160
|
// --- 执行 mounted ---
|
|
2179
2161
|
await tool.sleep(34);
|
|
2180
|
-
|
|
2162
|
+
try {
|
|
2163
|
+
await frm.onMounted.call(rtn.vroot, data ?? {});
|
|
2164
|
+
}
|
|
2165
|
+
catch (err: any) {
|
|
2166
|
+
// --- 窗体创建失败,做垃圾回收 ---
|
|
2167
|
+
core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error: -7.');
|
|
2168
|
+
delete t.forms[formId];
|
|
2181
2169
|
try {
|
|
2182
|
-
|
|
2170
|
+
rtn.vapp.unmount();
|
|
2183
2171
|
}
|
|
2184
2172
|
catch (err: any) {
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
}
|
|
2191
|
-
|
|
2192
|
-
const msg = `Message: ${err.message}\nTask id: ${opt.taskId}\nForm id: ${formId}\nFunction: form.create, unmount.`;
|
|
2193
|
-
notify({
|
|
2194
|
-
'title': 'Form Unmount Error',
|
|
2195
|
-
'content': msg,
|
|
2196
|
-
'type': 'danger'
|
|
2197
|
-
});
|
|
2198
|
-
console.log('Form Unmount Error', msg, err);
|
|
2199
|
-
}
|
|
2200
|
-
rtn.vapp._container.remove();
|
|
2201
|
-
elements.popList.querySelector('[data-form-id="' + rtn.vroot.formId + '"]')?.remove();
|
|
2202
|
-
dom.clearWatchStyle(rtn.vroot.formId);
|
|
2203
|
-
dom.clearWatchProperty(rtn.vroot.formId);
|
|
2204
|
-
native.clear(formId, t.id);
|
|
2205
|
-
// --- 移除 style ---
|
|
2206
|
-
dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
|
|
2207
|
-
return -8;
|
|
2173
|
+
const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.create, unmount.`;
|
|
2174
|
+
notify({
|
|
2175
|
+
'title': 'Form Unmount Error',
|
|
2176
|
+
'content': msg,
|
|
2177
|
+
'type': 'danger'
|
|
2178
|
+
});
|
|
2179
|
+
console.log('Form Unmount Error', msg, err);
|
|
2208
2180
|
}
|
|
2181
|
+
rtn.vapp._container.remove();
|
|
2182
|
+
elements.popList.querySelector('[data-form-id="' + rtn.vroot.formId + '"]')?.remove();
|
|
2183
|
+
dom.clearWatchStyle(rtn.vroot.formId);
|
|
2184
|
+
dom.clearWatchProperty(rtn.vroot.formId);
|
|
2185
|
+
native.clear(formId, t.id);
|
|
2186
|
+
// --- 移除 style ---
|
|
2187
|
+
dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
|
|
2188
|
+
throw err;
|
|
2209
2189
|
}
|
|
2210
2190
|
// --- 触发 formCreated 事件 ---
|
|
2211
|
-
core.trigger('formCreated',
|
|
2191
|
+
core.trigger('formCreated', t.id, formId, rtn.vroot.$refs.form.title, rtn.vroot.$refs.form.iconDataUrl);
|
|
2212
2192
|
// --- 同步的窗体先进行同步一下 ---
|
|
2213
2193
|
if (rtn.vroot.isNativeSync) {
|
|
2214
2194
|
await native.invoke('cg-set-size', native.getToken(), rtn.vroot.$refs.form.$el.offsetWidth, rtn.vroot.$refs.form.$el.offsetHeight);
|
|
@@ -2217,7 +2197,7 @@ export async function create(opt: types.IFormCreateOptions): Promise<number> {
|
|
|
2217
2197
|
rtn.vroot.$refs.form.setPropData('height', window.innerHeight);
|
|
2218
2198
|
});
|
|
2219
2199
|
}
|
|
2220
|
-
return
|
|
2200
|
+
return rtn.vroot as any;
|
|
2221
2201
|
}
|
|
2222
2202
|
|
|
2223
2203
|
/**
|
|
@@ -2231,6 +2211,7 @@ export function dialog(opt: string | types.IFormDialogOptions): Promise<string>
|
|
|
2231
2211
|
'content': opt
|
|
2232
2212
|
};
|
|
2233
2213
|
}
|
|
2214
|
+
const filename = tool.urlResolve(opt.path ?? '/', './tmp' + (Math.random() * 100000000000000).toFixed() + '.js');
|
|
2234
2215
|
const nopt = opt;
|
|
2235
2216
|
const taskId = nopt.taskId;
|
|
2236
2217
|
if (!taskId) {
|
|
@@ -2249,6 +2230,10 @@ export function dialog(opt: string | types.IFormDialogOptions): Promise<string>
|
|
|
2249
2230
|
const cls = class extends AbstractForm {
|
|
2250
2231
|
public buttons = nopt.buttons;
|
|
2251
2232
|
|
|
2233
|
+
public get filename(): string {
|
|
2234
|
+
return filename;
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2252
2237
|
public get taskId(): number {
|
|
2253
2238
|
return taskId;
|
|
2254
2239
|
}
|
|
@@ -2267,7 +2252,10 @@ export function dialog(opt: string | types.IFormDialogOptions): Promise<string>
|
|
|
2267
2252
|
}
|
|
2268
2253
|
}
|
|
2269
2254
|
};
|
|
2270
|
-
|
|
2255
|
+
create(cls, undefined, {
|
|
2256
|
+
'layout': `<form title="${nopt.title ?? 'dialog'}" min="false" max="false" resize="false" height="0" width="0" border="${nopt.title ? 'normal' : 'plain'}" direction="v"><dialog :buttons="buttons" @select="select"${nopt.direction ? ` direction="${nopt.direction}"` : ''}>${nopt.content}</dialog></form>`,
|
|
2257
|
+
'style': nopt.style
|
|
2258
|
+
}, t.id).then((frm) => {
|
|
2271
2259
|
if (typeof frm === 'number') {
|
|
2272
2260
|
resolve('');
|
|
2273
2261
|
return;
|
package/dist/lib/fs.js
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.copyFile = exports.copyFolder = exports.readDir = exports.rename = exports.chmod = exports.rmdirDeep = exports.rmdir = exports.mkdir = exports.isFile = exports.isDir = exports.stats = exports.unlink = exports.symlink = exports.readLink = exports.putContent = exports.getContent = exports.unmount = exports.mount = void 0;
|
|
13
13
|
const tool = require("./tool");
|
|
14
14
|
const task = require("./task");
|
|
15
|
-
const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/other/', '/app/demo/form/event/other/other.js', '/app/demo/form/event/other/other.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/sd.js', '/app/demo/form/method/aform/sd.xml', '/app/demo/form/method/
|
|
15
|
+
const clickgoFiles = ['/app/', '/app/demo/', '/app/demo/app.js', '/app/demo/config.json', '/app/demo/form/', '/app/demo/form/control/', '/app/demo/form/control/block/', '/app/demo/form/control/block/block.css', '/app/demo/form/control/block/block.xml', '/app/demo/form/control/button/', '/app/demo/form/control/button/button.css', '/app/demo/form/control/button/button.js', '/app/demo/form/control/button/button.xml', '/app/demo/form/control/check/', '/app/demo/form/control/check/check.js', '/app/demo/form/control/check/check.xml', '/app/demo/form/control/dialog/', '/app/demo/form/control/dialog/dialog.js', '/app/demo/form/control/dialog/dialog.xml', '/app/demo/form/control/file/', '/app/demo/form/control/file/file.js', '/app/demo/form/control/file/file.xml', '/app/demo/form/control/flow/', '/app/demo/form/control/flow/flow.css', '/app/demo/form/control/flow/flow.js', '/app/demo/form/control/flow/flow.xml', '/app/demo/form/control/form/', '/app/demo/form/control/form/form.css', '/app/demo/form/control/form/form.js', '/app/demo/form/control/form/form.xml', '/app/demo/form/control/img/', '/app/demo/form/control/img/img.xml', '/app/demo/form/control/label/', '/app/demo/form/control/label/label.xml', '/app/demo/form/control/list/', '/app/demo/form/control/list/list.css', '/app/demo/form/control/list/list.js', '/app/demo/form/control/list/list.xml', '/app/demo/form/control/loading/', '/app/demo/form/control/loading/loading.xml', '/app/demo/form/control/marquee/', '/app/demo/form/control/marquee/marquee.js', '/app/demo/form/control/marquee/marquee.xml', '/app/demo/form/control/menu/', '/app/demo/form/control/menu/menu.js', '/app/demo/form/control/menu/menu.xml', '/app/demo/form/control/monaco/', '/app/demo/form/control/monaco/monaco.js', '/app/demo/form/control/monaco/monaco.xml', '/app/demo/form/control/property/', '/app/demo/form/control/property/property.js', '/app/demo/form/control/property/property.xml', '/app/demo/form/control/radio/', '/app/demo/form/control/radio/radio.js', '/app/demo/form/control/radio/radio.xml', '/app/demo/form/control/scroll/', '/app/demo/form/control/scroll/scroll.js', '/app/demo/form/control/scroll/scroll.xml', '/app/demo/form/control/select/', '/app/demo/form/control/select/select.js', '/app/demo/form/control/select/select.xml', '/app/demo/form/control/tab/', '/app/demo/form/control/tab/tab.js', '/app/demo/form/control/tab/tab.xml', '/app/demo/form/control/text/', '/app/demo/form/control/text/text.js', '/app/demo/form/control/text/text.xml', '/app/demo/form/control/vflow/', '/app/demo/form/control/vflow/vflow.css', '/app/demo/form/control/vflow/vflow.js', '/app/demo/form/control/vflow/vflow.xml', '/app/demo/form/event/', '/app/demo/form/event/form/', '/app/demo/form/event/form/form.css', '/app/demo/form/event/form/form.js', '/app/demo/form/event/form/form.xml', '/app/demo/form/event/other/', '/app/demo/form/event/other/other.js', '/app/demo/form/event/other/other.xml', '/app/demo/form/event/screen/', '/app/demo/form/event/screen/screen.js', '/app/demo/form/event/screen/screen.xml', '/app/demo/form/event/task/', '/app/demo/form/event/task/task.js', '/app/demo/form/event/task/task.xml', '/app/demo/form/main.css', '/app/demo/form/main.js', '/app/demo/form/main.xml', '/app/demo/form/method/', '/app/demo/form/method/aform/', '/app/demo/form/method/aform/aform.js', '/app/demo/form/method/aform/aform.xml', '/app/demo/form/method/aform/sd.js', '/app/demo/form/method/aform/sd.xml', '/app/demo/form/method/core/', '/app/demo/form/method/core/core.js', '/app/demo/form/method/core/core.xml', '/app/demo/form/method/dom/', '/app/demo/form/method/dom/dom.css', '/app/demo/form/method/dom/dom.js', '/app/demo/form/method/dom/dom.xml', '/app/demo/form/method/form/', '/app/demo/form/method/form/form.css', '/app/demo/form/method/form/form.js', '/app/demo/form/method/form/form.xml', '/app/demo/form/method/form/test.xml', '/app/demo/form/method/fs/', '/app/demo/form/method/fs/fs.js', '/app/demo/form/method/fs/fs.xml', '/app/demo/form/method/fs/text.js', '/app/demo/form/method/fs/text.xml', '/app/demo/form/method/native/', '/app/demo/form/method/native/native.js', '/app/demo/form/method/native/native.xml', '/app/demo/form/method/system/', '/app/demo/form/method/system/system.js', '/app/demo/form/method/system/system.xml', '/app/demo/form/method/task/', '/app/demo/form/method/task/locale1.json', '/app/demo/form/method/task/locale2.json', '/app/demo/form/method/task/task.js', '/app/demo/form/method/task/task.xml', '/app/demo/form/method/theme/', '/app/demo/form/method/theme/theme.js', '/app/demo/form/method/theme/theme.xml', '/app/demo/form/method/tool/', '/app/demo/form/method/tool/tool.js', '/app/demo/form/method/tool/tool.xml', '/app/demo/form/method/zip/', '/app/demo/form/method/zip/zip.js', '/app/demo/form/method/zip/zip.xml', '/app/demo/global.css', '/app/demo/res/', '/app/demo/res/icon.svg', '/app/demo/res/img.jpg', '/app/demo/res/r-1.svg', '/app/demo/res/r-2.svg', '/app/demo/res/sql.svg', '/app/demo/res/txt.svg', '/app/demo/res/zip.svg', '/app/task/', '/app/task/app.js', '/app/task/config.json', '/app/task/form/', '/app/task/form/bar/', '/app/task/form/bar/bar.js', '/app/task/form/bar/bar.xml', '/app/task/form/desktop/', '/app/task/form/desktop/desktop.xml', '/app/task/locale/', '/app/task/locale/en.json', '/app/task/locale/ja.json', '/app/task/locale/sc.json', '/app/task/locale/tc.json', '/clickgo.js', '/clickgo.ts', '/control/', '/control/common.cgc', '/control/form.cgc', '/control/monaco.cgc', '/control/property.cgc', '/control/task.cgc', '/global.css', '/icon.png', '/index.js', '/index.ts', '/lib/', '/lib/control.js', '/lib/control.ts', '/lib/core.js', '/lib/core.ts', '/lib/dom.js', '/lib/dom.ts', '/lib/form.js', '/lib/form.ts', '/lib/fs.js', '/lib/fs.ts', '/lib/native.js', '/lib/native.ts', '/lib/task.js', '/lib/task.ts', '/lib/theme.js', '/lib/theme.ts', '/lib/tool.js', '/lib/tool.ts', '/lib/zip.js', '/lib/zip.ts', '/theme/', '/theme/familiar.cgt'];
|
|
16
16
|
const mounts = {};
|
|
17
17
|
function getMountName(path) {
|
|
18
18
|
const io = path.slice(9).indexOf('/');
|