Skip to content

Commit

Permalink
fix(core): 修复 attrs 属性的 style 特殊字段不生效的BUG, 将每个文本框设置最小的宽高
Browse files Browse the repository at this point in the history
  • Loading branch information
enncy committed Dec 4, 2023
1 parent 8958910 commit fdcc2ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/elements/config.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,7 +21,7 @@ export class ConfigElement<T extends keyof ConfigTagMap = 'input'> extends IElem
/** 将本地修改后的值同步到元素中 */
sync?: boolean;
/** 元素属性 */
attrs?: Partial<ConfigTagMap[T]>;
attrs?: CustomElementStyleAttrs<Partial<ConfigTagMap[T]>>;
/** tag 为 select 时的选项 */
options?: string[][] | { label: string; value: string; title?: string }[];
_onload?: (this: ConfigTagMap[T], el: this) => void;
Expand Down Expand Up @@ -117,6 +117,10 @@ export class ConfigElement<T extends keyof ConfigTagMap = 'input'> 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));
}
Expand Down
7 changes: 5 additions & 2 deletions packages/scripts/src/projects/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -306,7 +306,10 @@ export const CommonProject = Project.create({
].join('\n'),
label: '题目冗余字段自动删除',
tag: 'textarea',
attrs: { title: '在搜题的时候自动删除多余的文字,以便提高搜题的准确度,每行一个。' }
attrs: {
title: '在搜题的时候自动删除多余的文字,以便提高搜题的准确度,每行一个。',
style: { minWidth: '200px', minHeight: '50px' }
}
}
},
methods() {
Expand Down

0 comments on commit fdcc2ca

Please sign in to comment.