From fdcc2caf60f761d49fd8f0d22cf8e10cdf1803cc Mon Sep 17 00:00:00 2001 From: enncy <877526278@qq.com> Date: Mon, 4 Dec 2023 19:18:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(core):=20=E4=BF=AE=E5=A4=8D=20attrs=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=9A=84=20style=20=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=8D=E7=94=9F=E6=95=88=E7=9A=84BUG?= =?UTF-8?q?=EF=BC=8C=20=E5=B0=86=E6=AF=8F=E4=B8=AA=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=A1=86=E8=AE=BE=E7=BD=AE=E6=9C=80=E5=B0=8F=E7=9A=84=E5=AE=BD?= =?UTF-8?q?=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/elements/config.ts | 8 ++++++-- packages/scripts/src/projects/common.ts | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/core/src/elements/config.ts b/packages/core/src/elements/config.ts index 6c304b2f..24b14953 100644 --- a/packages/core/src/elements/config.ts +++ b/packages/core/src/elements/config.ts @@ -1,5 +1,5 @@ import { $creator } from '../utils/creator'; -import { el } from '../utils/dom'; +import { CustomElementStyleAttrs, el } from '../utils/dom'; import { $store } from '../utils/store'; import { ConfigTagMap } from './configs/interface'; @@ -21,7 +21,7 @@ export class ConfigElement extends IElem /** 将本地修改后的值同步到元素中 */ sync?: boolean; /** 元素属性 */ - attrs?: Partial; + attrs?: CustomElementStyleAttrs>; /** tag 为 select 时的选项 */ options?: string[][] | { label: string; value: string; title?: string }[]; _onload?: (this: ConfigTagMap[T], el: this) => void; @@ -117,6 +117,10 @@ export class ConfigElement extends IElem // 合并元素属性 for (const key in this.attrs) { + if (key === 'style') { + Object.assign(this.provider.style, this.attrs[key]); + continue; + } if (Object.prototype.hasOwnProperty.call(this.attrs, key)) { Reflect.set(this.provider, key, Reflect.get(this.attrs, key)); } diff --git a/packages/scripts/src/projects/common.ts b/packages/scripts/src/projects/common.ts index fe1002bb..f6e6c355 100644 --- a/packages/scripts/src/projects/common.ts +++ b/packages/scripts/src/projects/common.ts @@ -290,7 +290,7 @@ export const CommonProject = Project.create({ defaultValue: ['不会', '不知道', '不清楚', '不懂', '不会写'].join('\n'), label: '(仅超星)随机填空文案', tag: 'textarea', - attrs: { title: '每行一个,随机填入' } + attrs: { title: '每行一个,随机填入', style: { minWidth: '200px', minHeight: '50px' } } }, redundanceWordsText: { defaultValue: [ @@ -306,7 +306,10 @@ export const CommonProject = Project.create({ ].join('\n'), label: '题目冗余字段自动删除', tag: 'textarea', - attrs: { title: '在搜题的时候自动删除多余的文字,以便提高搜题的准确度,每行一个。' } + attrs: { + title: '在搜题的时候自动删除多余的文字,以便提高搜题的准确度,每行一个。', + style: { minWidth: '200px', minHeight: '50px' } + } } }, methods() {