From 63eb0a012c3a5c6c16155ff105cb6f907e7b66ed Mon Sep 17 00:00:00 2001 From: RSS1102 Date: Sun, 4 Jan 2026 19:28:35 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=99=A8=E4=B8=AD=E7=9A=84=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复颜色面板中类型判断错误 - 修复字体面板中数组遍历方法 - 修复行高面板中条件判断逻辑 - 重构阴影面板的数据结构和状态管理 - 添加尺寸面板的默认值重置功能 - 修复尺寸显示组件的数值解析 --- .../theme-generator/src/color-panel/index.vue | 2 +- .../theme-generator/src/common/i18n/en-US.js | 2 + .../theme-generator/src/common/i18n/zh-CN.js | 2 + .../font-panel/components/FontSizeAdjust.vue | 4 +- .../components/LineHeightAdjust.vue | 2 +- .../src/shadow-panel/built-in/shadow-map.js | 51 ++++---- .../src/shadow-panel/index.vue | 113 +++++++++--------- .../src/size-panel/built-in/size-map.js | 20 ++++ .../src/size-panel/components/SizeAdjust.vue | 5 +- .../src/size-panel/components/SizeDisplay.vue | 9 +- .../theme-generator/src/size-panel/index.vue | 48 +++++++- 11 files changed, 171 insertions(+), 87 deletions(-) diff --git a/packages/theme-generator/src/color-panel/index.vue b/packages/theme-generator/src/color-panel/index.vue index 5b9573cd..161adb0c 100644 --- a/packages/theme-generator/src/color-panel/index.vue +++ b/packages/theme-generator/src/color-panel/index.vue @@ -394,7 +394,7 @@ export default { errorMainColor: getOptionFromLocal('error') || getTokenValue('--td-error-color'), warningMainColor: getOptionFromLocal('warning') || getTokenValue('--td-warning-color'), generationMode: getOptionFromLocal('recommend') === 'true' ? 'recommend' : 'remain', // remain: 保留输入, recommend: 智能推荐 - isGrayRelatedToTheme: getOptionFromLocal('neutral') == 'true', + isGrayRelatedToTheme: getOptionFromLocal('neutral') === 'true', isMoreVisible: false, }; }, diff --git a/packages/theme-generator/src/common/i18n/en-US.js b/packages/theme-generator/src/common/i18n/en-US.js index df24689f..35c63e70 100644 --- a/packages/theme-generator/src/common/i18n/en-US.js +++ b/packages/theme-generator/src/common/i18n/en-US.js @@ -45,6 +45,8 @@ export default { yPadding: 'vertical Padding', popupPadding: 'popup Padding', margin: 'margin', + resetDefault: 'Reset', + resetConfirm: 'Are you sure to reset size to default?', }, borerRadius: { title: 'Border', diff --git a/packages/theme-generator/src/common/i18n/zh-CN.js b/packages/theme-generator/src/common/i18n/zh-CN.js index e8052583..2f6b9a6d 100644 --- a/packages/theme-generator/src/common/i18n/zh-CN.js +++ b/packages/theme-generator/src/common/i18n/zh-CN.js @@ -45,6 +45,8 @@ export default { yPadding: '组件上下边距', popupPadding: '弹出层边距', margin: '组件间距', + resetDefault: '恢复默认', + resetConfirm: '确定恢复尺寸默认值吗?', }, borerRadius: { title: '圆角', diff --git a/packages/theme-generator/src/font-panel/components/FontSizeAdjust.vue b/packages/theme-generator/src/font-panel/components/FontSizeAdjust.vue index 5e23961d..fe858dd4 100644 --- a/packages/theme-generator/src/font-panel/components/FontSizeAdjust.vue +++ b/packages/theme-generator/src/font-panel/components/FontSizeAdjust.vue @@ -165,7 +165,7 @@ export default { if (!FONT_SIZE_STEPS[v]) return; const newSteps = FONT_SIZE_STEPS[v]; - newSteps.map(({ name, value }) => { + newSteps.forEach(({ name, value }) => { modifyToken(name, value, isCustom); const i = this.tokenTypeList.findIndex((v) => v.label === name); if (i !== -1) this.tokenTypeList[i].value = value; @@ -236,7 +236,7 @@ export default { this.ladderTypeList[idx].value = res; if (parseInt(this.initLadderList[idx].value, 10) !== parseInt(res, 10)) this.segmentSelectionDisabled = true; - fontSizeList.map((tokenName) => { + fontSizeList.forEach((tokenName) => { const i = this.tokenTypeList.findIndex((v) => v.label === tokenName); if (i !== -1) this.tokenTypeList[i].value = res; }); diff --git a/packages/theme-generator/src/font-panel/components/LineHeightAdjust.vue b/packages/theme-generator/src/font-panel/components/LineHeightAdjust.vue index 9331e654..544cbebb 100644 --- a/packages/theme-generator/src/font-panel/components/LineHeightAdjust.vue +++ b/packages/theme-generator/src/font-panel/components/LineHeightAdjust.vue @@ -149,7 +149,7 @@ export default { } else { this.lineHeightValue = defaultVal; } - updateLocalOption('line-height', this.step == 3 ? `${type}_${this.lineHeightValue}` : null); + updateLocalOption('line-height', this.step !== 3 ? `${type}_${this.lineHeightValue}` : null); updateLineHeightTokens(this.lineHeightValue, type); }, }, diff --git a/packages/theme-generator/src/shadow-panel/built-in/shadow-map.js b/packages/theme-generator/src/shadow-panel/built-in/shadow-map.js index f0f12ba0..473c07c6 100644 --- a/packages/theme-generator/src/shadow-panel/built-in/shadow-map.js +++ b/packages/theme-generator/src/shadow-panel/built-in/shadow-map.js @@ -1,48 +1,55 @@ export const ShadowSelectType = { - Super_Light: 0, - Light: 1, - Default: 2, - Deep: 3, - Super_Deep: 4, - Self_Defined: 5, + Super_Light: 1, + Light: 2, + Default: 3, + Deep: 4, + Super_Deep: 5, + Self_Defined: 6, }; -export const ShadowSelectDetail = { - [ShadowSelectType.Super_Light]: [ +export const ShadowSelect = [ + { label: '超轻', enLabel: 'lighter', value: ShadowSelectType.Super_Light }, + { label: '轻', enLabel: 'light', value: ShadowSelectType.Light }, + { label: '默认', enLabel: 'default', value: ShadowSelectType.Default }, + { label: '深', enLabel: 'deep', value: ShadowSelectType.Deep }, + { label: '超深', enLabel: 'deeper', value: ShadowSelectType.Super_Deep }, + { label: '自定义', enLabel: 'customized', value: ShadowSelectType.Self_Defined, disabled: true }, +]; + +export const ShadowLabels = Object.fromEntries(ShadowSelect.map((item) => [item.value, item.label])); + +// 预设阴影值数组,索引对应 step - 1 +export const ShadowStepArray = [ + // Super_Light (step=1) + [ '0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 2px rgba(0, 0, 0, 0.03), 0 1px 2px rgba(0, 0, 0, 0.05)', '0 2px 6px rgba(0, 0, 0, 0.02), 0 4px 6px rgba(0, 0, 0, 0.05), 0 3px 3px rgba(0, 0, 0, 0.06)', '0 4px 10px 3px rgba(0, 0, 0, 0.05), 0 4px 6px 2px rgba(0, 0, 0, 0.04), 0 2px 3px -3px rgba(0, 0, 0, 0.08)', ], - [ShadowSelectType.Light]: [ + // Light (step=2) + [ '0 1px 6px rgba(0, 0, 0, 0.05), 0 3px 4px rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.08)', '0 3px 10px 2px rgba(0, 0, 0, 0.04), 0 6px 8px rgba(0, 0, 0, 0.05), 0 4px 4px -2px rgba(0, 0, 0, 0.08)', '0 4px 18px 5px rgba(0, 0, 0, 0.05), 0 10px 9px 2px rgba(0, 0, 0, 0.04), 0 3px 5px -3px rgba(0, 0, 0, 0.08)', ], - [ShadowSelectType.Default]: [ + // Default (step=3) + [ '0 1px 10px rgba(0, 0, 0, 0.05), 0 4px 5px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.12)', '0 3px 14px 2px rgba(0, 0, 0, 0.05), 0 8px 10px 1px rgba(0, 0, 0, 0.06), 0 5px 5px -3px rgba(0, 0, 0, 0.1)', '0 6px 30px 5px rgba(0, 0, 0, 0.05), 0 16px 24px 2px rgba(0, 0, 0, 0.04), 0 8px 10px -5px rgba(0, 0, 0, 0.08)', ], - [ShadowSelectType.Deep]: [ + // Deep (step=4) + [ '0 3px 18px rgba(0, 0, 0, 0.06), 0 4px 7px rgba(0, 0, 0, 0.1), 0 2px 7px -1px rgba(0, 0, 0, 0.14)', '0 5px 18px 2px rgba(0, 0, 0, 0.07), 0 10px 15px 1px rgba(0, 0, 0, 0.1), 0 6px 10px -4px rgba(0, 0, 0, 0.14)', '0 8px 33px 5px rgba(0, 0, 0, 0.07), 0 18px 28px 2px rgba(0, 0, 0, 0.07), 0 10px 12px -6px rgba(0, 0, 0, 0.17)', ], - [ShadowSelectType.Super_Deep]: [ + // Super_Deep (step=5) + [ '0 5px 20px rgba(0, 0, 0, 0.08), 0 5px 8px rgba(0, 0, 0, 0.12), 0 5px 10px -1px rgba(0, 0, 0, 0.18)', '0 7px 23px 2px rgba(0, 0, 0, 0.09), 0 12px 17px 1px rgba(0, 0, 0, 0.1), 0 8px 14px -4px rgba(0, 0, 0, 0.18)', '0 11px 37px 5px rgba(0, 0, 0, 0.1), 0 21px 31px 2px rgba(0, 0, 0, 0.12), 0 14px 20px -6px rgba(0, 0, 0, 0.16)', ], - [ShadowSelectType.Self_Defined]: ['', '', ''], -}; - -export const ShadowSelect = [ - { label: '超轻', enLabel: 'lighter', value: ShadowSelectType.Super_Light }, - { label: '轻', enLabel: 'light', value: ShadowSelectType.Light }, - { label: '默认', enLabel: 'default', value: ShadowSelectType.Default }, - { label: '深', enLabel: 'deep', value: ShadowSelectType.Deep }, - { label: '超深', enLabel: 'deeper', value: ShadowSelectType.Super_Deep }, - { label: '自定义', enLabel: 'customized', value: ShadowSelectType.Self_Defined, disabled: true }, ]; export const ShadowTypeDetail = [ diff --git a/packages/theme-generator/src/shadow-panel/index.vue b/packages/theme-generator/src/shadow-panel/index.vue index 48402291..cff3a510 100644 --- a/packages/theme-generator/src/shadow-panel/index.vue +++ b/packages/theme-generator/src/shadow-panel/index.vue @@ -14,7 +14,7 @@ v-model="step" :selectOptions="selectOptions" :suspendedLabels="suspendedLabels" - :disabled="forbidden" + :disabled="segmentSelectionDisabled" > diff --git a/packages/theme-generator/src/common/components/Collapse/index.vue b/packages/theme-generator/src/common/components/Collapse/index.vue index ada7d07a..84b9a29c 100644 --- a/packages/theme-generator/src/common/components/Collapse/index.vue +++ b/packages/theme-generator/src/common/components/Collapse/index.vue @@ -1,144 +1,29 @@ - - diff --git a/packages/theme-generator/src/common/components/CollapseBase/index.vue b/packages/theme-generator/src/common/components/CollapseBase/index.vue new file mode 100644 index 00000000..08e90f09 --- /dev/null +++ b/packages/theme-generator/src/common/components/CollapseBase/index.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/packages/theme-generator/src/common/components/index.js b/packages/theme-generator/src/common/components/index.js index 6dade961..124597f0 100644 --- a/packages/theme-generator/src/common/components/index.js +++ b/packages/theme-generator/src/common/components/index.js @@ -1,3 +1,4 @@ +export { default as CollapseBase } from './CollapseBase'; export { default as CommonCollapse } from './Collapse'; export { default as ColorPicker } from './ColorPicker'; export { default as SegmentSelection } from './SegmentSelection';