From 3358221da9b8cce5c4ab9ee8cf27a8967e968479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E5=A4=A7=E8=83=86?= <1101282782@qq.com> Date: Tue, 19 Aug 2025 13:58:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E6=9C=AC=E6=A1=86?= =?UTF-8?q?=E7=9A=84=E4=BC=A0=E5=85=A5=E5=92=8C=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Obj/Base/TextBox/index.js | 27 +++++++++++++++++++++++++-- src/YJEarth/index.js | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Obj/Base/TextBox/index.js b/src/Obj/Base/TextBox/index.js index b97613b..44ddb84 100644 --- a/src/Obj/Base/TextBox/index.js +++ b/src/Obj/Base/TextBox/index.js @@ -4,15 +4,31 @@ import Base from "../index"; import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' class TextBox extends Base { - constructor(sdk, options = {}) { + /** + * @constructor + * @param sdk + * @description 文本框 + * @param options {object} 属性 + * @param options.id=id + * @param options.positions=[]位置 + * @param options.text=文本框内容 + * @param options.show=true {boolean}是否显示 + * @param Dialog {object} 弹框对象 + * @param Dialog.confirmCallBack {function} 弹框确认时的回调 + * */ + constructor(sdk, options = {}, callback = null) { // this.sdk = { ...sdk } // this.options = { ...options } super(sdk, options) + this.options.positions = options.positions || [] + this.options.text = options.text || '' + this.options.show = (options.show || options.show === false) ? options.show : true this.clickTextDom = undefined this.handler = undefined this.textDom = undefined this.create(this) this.sdk.addIncetance(this.options.id, this) + this.callback = callback } async create(that) { @@ -24,11 +40,13 @@ class TextBox extends Base { // 创建textarea元素 var textarea = document.createElement('textarea'); textarea.className = 'textarea' + textarea.value = that.options.text; // 设置textarea的属性,例如行数和列数 textarea.rows = 6; textarea.style.resize = 'none' // 将textarea添加到div中 dom.appendChild(textarea); + (!that.options.show) && (dom.style.display = 'none') // 将div添加到body中 // document.body.appendChild(dom); @@ -48,7 +66,8 @@ class TextBox extends Base { } } viewer.scene.postRender.addEventListener(that.handler); - that.textDom = dom + that.textDom = dom; + } async setHandeler(data) { let that = this @@ -81,6 +100,10 @@ class TextBox extends Base { that.sdk.viewer.scene.postRender.addEventListener(that.handler); } } + async getwords(words) { + this.options.text = words + this.callback(this.options) + } async returnFun() { return this.handler } diff --git a/src/YJEarth/index.js b/src/YJEarth/index.js index 27a1dad..0f5df67 100644 --- a/src/YJEarth/index.js +++ b/src/YJEarth/index.js @@ -485,6 +485,7 @@ class YJEarth { _this.clickTextDom.removeEventListener('mousedown', mousedown); document.removeEventListener('mousemove', mousemove); document.removeEventListener('mouseup', mouseup); + _this.entityMap.get(_this.clickTextDom.id).getwords(_this.clickTextDom.getElementsByTagName('textarea')[0].value) _this.clickTextDom.style['pointer-events'] = 'none' _this.clickTextDom = undefined