From b43441946945e3a92a89bb49ecb13f9b24af4fcb Mon Sep 17 00:00:00 2001 From: Treecat Date: Thu, 27 Apr 2023 14:58:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=97=A0jira=20fix:AsyncTree?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/demo/src/demo/base/tree/demo.sync_tree.js | 6 +++--- packages/fineui/src/case/ztree/asynctree.js | 2 +- packages/fineui/src/case/ztree/list/listparttree.js | 2 +- packages/fineui/src/case/ztree/parttree.js | 4 ++-- .../src/widget/multiselecttree/multiselecttree.popup.js | 4 ++-- packages/fineui/src/widget/multitree/multi.tree.popup.js | 6 +++--- scripts/lib/fui.component.json | 2 +- scripts/lib/fui.export.txt | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/demo/src/demo/base/tree/demo.sync_tree.js b/packages/demo/src/demo/base/tree/demo.sync_tree.js index f2534ab56..7fb153bb3 100644 --- a/packages/demo/src/demo/base/tree/demo.sync_tree.js +++ b/packages/demo/src/demo/base/tree/demo.sync_tree.js @@ -1,5 +1,5 @@ -import { VTapeLayout, Label, Asynctree, shortcut, Widget, isNull } from "@fui/core" +import { VTapeLayout, Label, AsyncTree, shortcut, Widget, isNull } from "@fui/core" @shortcut() @@ -33,7 +33,7 @@ export class SyncTreeDemo extends Widget { text: "可以异步获取数据的树", }, { - type: Asynctree.xtype, + type: AsyncTree.xtype, ref(_ref) { self.syncTree1 = _ref; }, @@ -78,7 +78,7 @@ export class SyncTreeDemo extends Widget { text: "showIcon属性搭配节点iconCls,可以显示图标", }, { - type: Asynctree.xtype, + type: AsyncTree.xtype, ref(_ref) { self.syncTree2 = _ref; }, diff --git a/packages/fineui/src/case/ztree/asynctree.js b/packages/fineui/src/case/ztree/asynctree.js index 9903bfbe5..f9b5bf6b6 100644 --- a/packages/fineui/src/case/ztree/asynctree.js +++ b/packages/fineui/src/case/ztree/asynctree.js @@ -4,7 +4,7 @@ import { TreeRenderPageService } from "./treerender.page.service"; import $ from "jquery"; @shortcut() -export class Asynctree extends TreeView { +export class AsyncTree extends TreeView { static xtype = "bi.async_tree"; _defaultConfig() { diff --git a/packages/fineui/src/case/ztree/list/listparttree.js b/packages/fineui/src/case/ztree/list/listparttree.js index 640390b5d..9ec25d2f0 100644 --- a/packages/fineui/src/case/ztree/list/listparttree.js +++ b/packages/fineui/src/case/ztree/list/listparttree.js @@ -7,7 +7,7 @@ import $ from "jquery"; * guy * 局部树,两个请求树, 第一个请求构造树,第二个请求获取节点 * @class ListPartTree - * @extends Asynctree + * @extends AsyncTree */ @shortcut() diff --git a/packages/fineui/src/case/ztree/parttree.js b/packages/fineui/src/case/ztree/parttree.js index 5bc75b7ba..2a93dd7bb 100644 --- a/packages/fineui/src/case/ztree/parttree.js +++ b/packages/fineui/src/case/ztree/parttree.js @@ -1,5 +1,5 @@ import { isEmpty, shortcut, extend, deepClone, each, isNotEmptyArray, Events, delay, isNull } from "@/core"; -import { Asynctree } from "./asynctree"; +import { AsyncTree } from "./asynctree"; import { TreeView } from "./treeview"; import $ from "jquery"; @@ -11,7 +11,7 @@ import $ from "jquery"; */ @shortcut() -export class PartTree extends Asynctree { +export class PartTree extends AsyncTree { static xtype = "bi.part_tree"; static EVENT_CLICK_TREE_NODE = "EVENT_CLICK_TREE_NODE"; diff --git a/packages/fineui/src/widget/multiselecttree/multiselecttree.popup.js b/packages/fineui/src/widget/multiselecttree/multiselecttree.popup.js index 7c67d1d6f..3782d209b 100644 --- a/packages/fineui/src/widget/multiselecttree/multiselecttree.popup.js +++ b/packages/fineui/src/widget/multiselecttree/multiselecttree.popup.js @@ -1,5 +1,5 @@ import { shortcut, Widget, extend, emptyFn, createWidget } from "@/core"; -import { TreeView, Asynctree } from "@/case"; +import { TreeView, AsyncTree } from "@/case"; @shortcut() export class MultiSelectTreePopup extends Widget { @@ -20,7 +20,7 @@ export class MultiSelectTreePopup extends Widget { const self = this, o = this.options; this.popup = createWidget({ - type: Asynctree.xtype, + type: AsyncTree.xtype, showLine: o.showLine, element: this, itemsCreator: o.itemsCreator, diff --git a/packages/fineui/src/widget/multitree/multi.tree.popup.js b/packages/fineui/src/widget/multitree/multi.tree.popup.js index ad450a7cd..44c91a591 100644 --- a/packages/fineui/src/widget/multitree/multi.tree.popup.js +++ b/packages/fineui/src/widget/multitree/multi.tree.popup.js @@ -1,6 +1,6 @@ import { shortcut, extend, emptyFn, createWidget, i18nText } from "@/core"; import { Pane } from "@/base"; -import { Asynctree, MultiPopupView, TreeView } from "@/case"; +import { AsyncTree, MultiPopupView, TreeView } from "@/case"; @shortcut() export class MultiTreePopup extends Pane { @@ -19,7 +19,7 @@ export class MultiTreePopup extends Pane { maxHeight: 400, onLoaded: emptyFn, el: { - type: Asynctree.xtype, + type: AsyncTree.xtype, }, }); } @@ -34,7 +34,7 @@ export class MultiTreePopup extends Pane { this.selectedValues = {}; this.tree = createWidget(opts.el, { - type: Asynctree.xtype, + type: AsyncTree.xtype, showLine: opts.showLine, height: 400, cls: "popup-view-tree", diff --git a/scripts/lib/fui.component.json b/scripts/lib/fui.component.json index fd25ca2dc..35bfe7cc1 100644 --- a/scripts/lib/fui.component.json +++ b/scripts/lib/fui.component.json @@ -166,7 +166,7 @@ "bi.select_text_trigger": "SelectTextTrigger", "bi.small_select_text_trigger": "SmallSelectTextTrigger", "bi.small_text_trigger": "SmallTextTrigger", - "bi.async_tree": "Asynctree", + "bi.async_tree": "AsyncTree", "bi.list_async_tree": "Listasynctree", "bi.list_part_tree": "ListPartTree", "bi.list_tree_view": "Listtreeview", diff --git a/scripts/lib/fui.export.txt b/scripts/lib/fui.export.txt index b4fa01d49..ef18cb6a8 100644 --- a/scripts/lib/fui.export.txt +++ b/scripts/lib/fui.export.txt @@ -17,7 +17,7 @@ AllCountPager AllValueMultiTextValueCombo ArrowNode ArrowTreeGroupNodeCheckbox -Asynctree +AsyncTree AutoVerticalTapeLayout Axis BarPopover From 7f752c02d86748d673a5de38c5126fcfa0aef6b2 Mon Sep 17 00:00:00 2001 From: Treecat Date: Thu, 27 Apr 2023 15:07:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=97=A0jira=20fix:=E6=8A=8A=20worker=20?= =?UTF-8?q?=E7=A7=BB=E5=87=BA=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fineui/bin/cli/cli.js | 21 ----- packages/fineui/bin/cli/worker/cli.worker.js | 76 ------------------- .../cli/worker/template/main_thread.helper.t | 48 ------------ .../action/action.worker_ability_test.t | 13 ---- .../worker/template/main_thread/main_thread.t | 13 ---- .../cli/worker/template/utils/action_type.t | 8 -- .../cli/worker/template/utils/payload_type.t | 13 ---- .../action/action.worker_ability_test.t | 24 ------ .../template/worker_thread/worker_thread.t | 12 --- 9 files changed, 228 deletions(-) delete mode 100644 packages/fineui/bin/cli/cli.js delete mode 100644 packages/fineui/bin/cli/worker/cli.worker.js delete mode 100644 packages/fineui/bin/cli/worker/template/main_thread.helper.t delete mode 100644 packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t delete mode 100644 packages/fineui/bin/cli/worker/template/main_thread/main_thread.t delete mode 100644 packages/fineui/bin/cli/worker/template/utils/action_type.t delete mode 100644 packages/fineui/bin/cli/worker/template/utils/payload_type.t delete mode 100644 packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t delete mode 100644 packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t diff --git a/packages/fineui/bin/cli/cli.js b/packages/fineui/bin/cli/cli.js deleted file mode 100644 index 513024023..000000000 --- a/packages/fineui/bin/cli/cli.js +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env node -const yargs = require('yargs/yargs'); -const { hideBin } = require('yargs/helpers'); - -const workerCmd = require('./worker/cli.worker'); - -const argv = yargs(hideBin(process.argv)).argv; - -const cmd = argv._[0]; - -const cmds = new Map([ - ['worker', workerCmd], -]); - -if (!cmd) throw new Error('Command is undefined!'); - -if (cmds.has(cmd)) { - cmds.get(cmd)?.exec(argv); -} else { - throw new Error(`Command ${cmd} not supported`); -} diff --git a/packages/fineui/bin/cli/worker/cli.worker.js b/packages/fineui/bin/cli/worker/cli.worker.js deleted file mode 100644 index b67513fbb..000000000 --- a/packages/fineui/bin/cli/worker/cli.worker.js +++ /dev/null @@ -1,76 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -function first2UpperCase(str) { - return str.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase()); -} - -function scanAndCreate(structure, workerName, root) { - Object.keys(structure) - .forEach(name => { - if (typeof structure[name] === 'object') { - fs.mkdirSync(path.resolve(root, name)); - - scanAndCreate(structure[name], workerName, path.resolve(root, `./${name}`)); - } else if (structure[name] === '') { - fs.appendFileSync(path.resolve(root, name), ''); - } else if (typeof structure[name] === 'string') { - let content = fs.readFileSync(structure[name]).toString(); - - content = content - .replace(/\${WorkerName}/g, first2UpperCase(workerName)) - .replace(/\${workerName}/g, workerName); - - fs.appendFileSync(path.resolve(root, name), content); - } - }); -} - -module.exports = { - exec: async args => { - if (!args.init) { - throw new Error(`Command init not found in args`); - } - - if (!args.name) { - throw new Error('Command --name=... not found in args'); - } - - const name = args.name; - - const structure = { - [`${name}_worker`]: { - 'main_thread': { - action: { - 'action.worker_ability_test.ts': path.resolve(__dirname, './template/main_thread/action/action.worker_ability_test.t'), - }, - [`${name}_main_thread.ts`]: path.resolve(__dirname, './template/main_thread/main_thread.t'), - }, - utils: { - 'action_type.ts': path.resolve(__dirname, './template/utils/action_type.t'), - 'payload_type.ts': path.resolve(__dirname, './template/utils/payload_type.t'), - }, - 'worker_thread': { - action: { - 'action.worker_ability_test.ts': path.resolve(__dirname, './template/worker_thread/action/action.worker_ability_test.t'), - }, - [`${name}_worker_thread.ts`]: path.resolve(__dirname, './template/worker_thread/worker_thread.t'), - }, - [`${name}_main_thread.helper.ts`]: path.resolve(__dirname, './template/main_thread.helper.t'), - }, - }; - - scanAndCreate(structure, name, args.where ? path.resolve(args.where) : process.cwd()); - }, -}; - -// 结构 -// -xxx_worker -// -|--main_thread -// -|--|--action -// -|--|--xxx_main_thread.ts -// -|--utils -// -|--|--action_type.ts -// -|--worker_thread -// -|--|--action -// -|--|--worker_main_thread.ts diff --git a/packages/fineui/bin/cli/worker/template/main_thread.helper.t b/packages/fineui/bin/cli/worker/template/main_thread.helper.t deleted file mode 100644 index 2ee06acb7..000000000 --- a/packages/fineui/bin/cli/worker/template/main_thread.helper.t +++ /dev/null @@ -1,48 +0,0 @@ -import { ${WorkerName}MainThreadWorker } from './main_thread/${workerName}_main_thread'; -// 不需要一起打包的话则不需要引入这行 -// FuiWorkerPlugin中的属性会同步到fui-worker中,同时支持loader行内传入属性 -// 根据实际需求传入inline,返回格式 true -> blob url,false -> servicePath -import workerUrl from 'fui-worker!./worker_thread/${workerName}_worker_thread'; - -export class ${WorkerName}WorkerHelper { - private worker: ${WorkerName}MainThreadWorker; - - /** - * 拿到helper中的worker - */ - public getWorker() { - if (this.worker) { - return this.worker; - } - - this.worker = BI.Workers.createWorker(${WorkerName}MainThreadWorker, { - workerUrl: this.urlFormatter(workerUrl), - workerName: BI.UUID(), - }); - - return this.worker; - } - - /** - * 格式化worker url,比如补充一些环境信息到参数里 - * 可通过 #hash 将参数传入blob url - * @param url worker url - */ - private urlFormatter(url: string) { - return url; - } - - /** - * 终止worker - */ - public terminate() { - this.worker?.terminate(); - } -} - -// 使用示例 -// const workerHelper = new ${WorkerName}WorkerHelper(); - -// workerHelper.getWorker() -// .testCommunication() -// .then(res => console.log(res)); diff --git a/packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t b/packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t deleted file mode 100644 index 42425b859..000000000 --- a/packages/fineui/bin/cli/worker/template/main_thread/action/action.worker_ability_test.t +++ /dev/null @@ -1,13 +0,0 @@ -import { WorkerAbilityTestActionType } from '../../utils/action_type'; -import { WorkerAbilityTestPayload, WorkerAbilityTestReponse } from '../../utils/payload_type'; - -export class WorkerAbilityTestMainThreadAction extends BI.Workers.WorkerBaseAction { - /** - * 通信能力检测 - */ - public communicationTest(): Promise { - const mainThreadPostTime: WorkerAbilityTestPayload['CommunicationTest'] = Date.now(); - - return this.controller.requestPromise(WorkerAbilityTestActionType.CommunicationTest, mainThreadPostTime); - } -} diff --git a/packages/fineui/bin/cli/worker/template/main_thread/main_thread.t b/packages/fineui/bin/cli/worker/template/main_thread/main_thread.t deleted file mode 100644 index 00fb09177..000000000 --- a/packages/fineui/bin/cli/worker/template/main_thread/main_thread.t +++ /dev/null @@ -1,13 +0,0 @@ -import { WorkerAbilityTestMainThreadAction } from './action/action.worker_ability_test'; - -export class ${WorkerName}MainThreadWorker extends BI.Workers.MainThreadWorker { - private communicationTest: WorkerAbilityTestMainThreadAction; - - public initActions(): void { - this.communicationTest = this.createAction(WorkerAbilityTestMainThreadAction); - } - - public testCommunication() { - return this.communicationTest.communicationTest(); - } -} diff --git a/packages/fineui/bin/cli/worker/template/utils/action_type.t b/packages/fineui/bin/cli/worker/template/utils/action_type.t deleted file mode 100644 index c92de897a..000000000 --- a/packages/fineui/bin/cli/worker/template/utils/action_type.t +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Worker 事务标识 - * 每类事务有命名空间, 包含多个具体事务 - */ - -export const enum WorkerAbilityTestActionType { - CommunicationTest = 'CommunicationTest', -} diff --git a/packages/fineui/bin/cli/worker/template/utils/payload_type.t b/packages/fineui/bin/cli/worker/template/utils/payload_type.t deleted file mode 100644 index 6b9a71509..000000000 --- a/packages/fineui/bin/cli/worker/template/utils/payload_type.t +++ /dev/null @@ -1,13 +0,0 @@ -/** - * 跨线程通信各事务的发送数据类型声明 - */ -export interface WorkerAbilityTestPayload { - CommunicationTest: number; -} - -/** - * 跨线程通信各事务的响应数据类型声明 - */ -export interface WorkerAbilityTestReponse { - CommunicationTest: number; -} diff --git a/packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t b/packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t deleted file mode 100644 index f7d1248f4..000000000 --- a/packages/fineui/bin/cli/worker/template/worker_thread/action/action.worker_ability_test.t +++ /dev/null @@ -1,24 +0,0 @@ -import { WorkerAbilityTestActionType } from '../../utils/action_type'; -import { WorkerAbilityTestPayload, WorkerAbilityTestReponse } from '../../utils/payload_type'; - -export class WorkerAbilityTestWorkerThreadAction extends BI.Workers.WorkerBaseAction { - protected addActionHandler(): void { - this.controller.addActionHandler( - WorkerAbilityTestActionType.CommunicationTest, - this.communicationTest.bind(this) - ); - } - - /** - * 通信能力检测的处理器 - */ - private communicationTest( - payload: WorkerAbilityTestPayload['CommunicationTest'] - ): WorkerAbilityTestReponse['CommunicationTest'] { - const mainThreadPostTime = payload; - // 收到主线程信息的耗时 - const workerGetMessageDuration = Date.now() - mainThreadPostTime; - - return workerGetMessageDuration; - } -} diff --git a/packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t b/packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t deleted file mode 100644 index f437bbc23..000000000 --- a/packages/fineui/bin/cli/worker/template/worker_thread/worker_thread.t +++ /dev/null @@ -1,12 +0,0 @@ -// TODO: 这边需要先import fineui资源 -import { WorkerAbilityTestWorkerThreadAction } from './action/action.worker_ability_test'; - -class ${WorkerName}WorkerTreadWorker extends BI.Workers.WorkerThreadWorker { - public communicationTest: WorkerAbilityTestWorkerThreadAction; - - public initActions(): void { - this.communicationTest = this.createAction(WorkerAbilityTestWorkerThreadAction); - } -} - -export const ${workerName}WorkerTreadWorker = BI.Workers.createWorker(${WorkerName}WorkerTreadWorker);