clickgo 3.1.1-dev10 → 3.1.2-dev11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/task.ts CHANGED
@@ -29,29 +29,6 @@ export const list: Record<number, types.ITask> = {};
29
29
  /** --- 最后一个 task id,App 模式下无效 --- */
30
30
  export let lastId: number = 0;
31
31
 
32
- /** --- 当前是否设置的主任务的任务 ID,全局只可设置一次 --- */
33
- let mainTaskId: number = 0;
34
-
35
- /**
36
- * --- 将一个任务设置为主任务,全局只可设置一次 ---
37
- * @param taskId 任务 ID
38
- */
39
- export function setMain(taskId: number): boolean {
40
- if (mainTaskId > 0) {
41
- return false;
42
- }
43
- mainTaskId = taskId;
44
- return true;
45
- }
46
-
47
- /**
48
- * --- 判断一个任务 ID 是不是主任务 ---
49
- * @param taskId 任务 ID
50
- */
51
- export function isMain(taskId: number): boolean {
52
- return taskId === mainTaskId;
53
- }
54
-
55
32
  /** --- task lib 用到的语言包 --- */
56
33
  const localeData: Record<string, {
57
34
  'loading': string;
@@ -347,12 +324,18 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
347
324
  getVersion: function(): string {
348
325
  return clickgo.getVersion();
349
326
  },
350
- getNative(): boolean {
351
- return clickgo.getNative();
327
+ isNative(): boolean {
328
+ return clickgo.isNative();
352
329
  },
353
330
  getPlatform(): string {
354
331
  return clickgo.getPlatform();
355
332
  },
333
+ isImmersion(): boolean {
334
+ return clickgo.isImmersion();
335
+ },
336
+ hasFrame(): boolean {
337
+ return clickgo.hasFrame();
338
+ },
356
339
  'control': {
357
340
  'AbstractControl': class extends control.AbstractControl {
358
341
  public get taskId(): number {
@@ -715,9 +698,6 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
715
698
  }
716
699
  },
717
700
  'task': {
718
- isMain(taskId: number): boolean {
719
- return isMain(taskId);
720
- },
721
701
  onFrame: function(fun: () => void | Promise<void>, opt: any = {}): number {
722
702
  opt.taskId = taskId;
723
703
  return clickgo.task.onFrame(fun, opt);
@@ -736,7 +716,6 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
736
716
  },
737
717
  run: function(url: string, opt: types.ITaskRunOptions = {}): Promise<number> {
738
718
  opt.taskId = taskId;
739
- opt.main = false;
740
719
  return clickgo.task.run(url, opt);
741
720
  },
742
721
  end: function(tid: number): boolean {
@@ -935,6 +914,12 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
935
914
  }
936
915
  // --- 创建 Task 总 style ---
937
916
  dom.createToStyleList(taskId);
917
+ // --- 触发 taskStarted 事件 ---
918
+ core.trigger('taskStarted', taskId);
919
+ // --- 第一个任务给 native 发送任务启动成功的消息 ---
920
+ if (taskId === 1) {
921
+ native.invoke('cg-init', native.getToken());
922
+ }
938
923
  // --- 执行 app ---
939
924
  const appCls: core.AbstractApp = new expo.default();
940
925
  await appCls.main();
@@ -943,25 +928,9 @@ export async function run(url: string, opt: types.ITaskRunOptions = {}): Promise
943
928
  // --- 结束任务 ---
944
929
  delete list[taskId];
945
930
  dom.removeFromStyleList(taskId);
931
+ core.trigger('taskEnded', taskId);
946
932
  return -4;
947
933
  }
948
- // --- 触发 taskStarted 事件 ---
949
- core.trigger('taskStarted', taskId);
950
- // --- 给 native 发送任务启动成功的消息 ---
951
- if (taskId === 1) {
952
- native.invoke('cg-init', native.getToken());
953
- }
954
- // --- 提交 sync ---
955
- /*
956
- if (clickgo.getNative() && opt.sync) {
957
- f.vroot.$refs.form.isNativeSync = true;
958
- native.invoke('cg-set-size', native.getToken(), f.vroot.$refs.form.widthData, f.vroot.$refs.form.heightData);
959
- window.addEventListener('resize', function(): void {
960
- f.vroot.$refs.form.setPropData('width', window.innerWidth);
961
- f.vroot.$refs.form.setPropData('height', window.innerHeight);
962
- });
963
- }
964
- */
965
934
  return taskId;
966
935
  }
967
936
 
@@ -975,7 +944,7 @@ export function end(taskId: number): boolean {
975
944
  return true;
976
945
  }
977
946
  // --- 如果是 native 模式 ---
978
- if (clickgo.getNative() && isMain(taskId)) {
947
+ if (clickgo.isNative() && (taskId === 1)) {
979
948
  native.invoke('cg-close', native.getToken());
980
949
  }
981
950
  // --- 获取最大的 z index 窗体,并让他获取焦点 ---
@@ -991,7 +960,7 @@ export function end(taskId: number): boolean {
991
960
  // --- 移除窗体 list ---
992
961
  for (const fid in task.forms) {
993
962
  const f = task.forms[fid];
994
- core.trigger('formRemoved', taskId, f.id, f.vroot.$refs.form.title, f.vroot.$refs.form.iconData);
963
+ core.trigger('formRemoved', taskId, f.id, f.vroot.$refs.form.title, f.vroot.$refs.form.iconDataUrl);
995
964
  try {
996
965
  f.vapp.unmount();
997
966
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clickgo",
3
- "version": "3.1.1-dev10",
3
+ "version": "3.1.2-dev11",
4
4
  "description": "Background interface, software interface, mobile phone APP interface operation library.",
5
5
  "keywords": [
6
6
  "deskrt",
package/types/index.d.ts CHANGED
@@ -10,8 +10,10 @@ export * as tool from '../dist/lib/tool';
10
10
  export * as zip from '../dist/lib/zip';
11
11
 
12
12
  export function getVersion(): string;
13
- export function getNative(): boolean;
13
+ export function isNative(): boolean;
14
14
  export function getPlatform(): NodeJS.Platform | 'web';
15
+ export function isImmersion(): boolean;
16
+ export function hasFrame(): boolean;
15
17
  // eslint-disable-next-line @typescript-eslint/naming-convention
16
18
  export const AbstractBoot: typeof import('../dist/index').AbstractBoot;
17
19
  export function launcher(boot: import('../dist/index').AbstractBoot): void;
@@ -400,10 +402,6 @@ export interface ITaskRunOptions {
400
402
  'progress'?: (loaded: number, total: number) => void | Promise<void>;
401
403
  /** --- 显示 notify 窗口 --- */
402
404
  'notify'?: boolean;
403
- /** --- 设置为主应用,整个运行时只能设置一次,因此 App 下不可能被设置 --- */
404
- 'main'?: boolean;
405
- /** --- native 下窗体与实体窗体大小同步,App 模式下无法设置 --- */
406
- 'sync'?: boolean;
407
405
  /** --- 所属任务,App 模式无法设置 --- */
408
406
  'taskId'?: number;
409
407
  /** --- 不禁止某些浏览器对象,App 模式下无法设置 --- */
@@ -1,5 +0,0 @@
1
- <form width="200" height="200" title="From path">
2
- <layout align-v="center" align-h="center" style="flex: 1; width: 0;">
3
- <label>Haha!</label>
4
- </layout>
5
- </form>