feat: 新增份量等比缩放条,可等比例调整所有食材重量 - #210
Open
huiihao wants to merge 1 commit into
Open
Conversation
- 新增 markdown-it 插件:渲染时把「数字+单位」包成 <span class="qty">,不改动任何源 .md 文件 - 新增 QuantityScaler 组件:滑杆 + 快捷档位(¼/½/1/2 份),范围 0.1×~2×,可一键重置 - 支持重量/体积(g/kg/ml/升/斤/两…)与计数单位(个/只/片/根/块/…/份)等比缩放 - 自动跳过营养成分表、长度(cm)、时间、热量(Kcal)等不可缩放内容
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
老乡鸡菜谱的分量基本是中央厨房批量出品的规格(如 200g 大豆油、575g 鸡蛋液、1800g 西红柿),在家照做时量太大。本 PR 给每道菜加一个可调滑杆,把页面里所有食材/调料的重量按比例等比缩放。
效果
200g 大豆油 → 20g、575g 鸡蛋液 → 57.5g、1800g 西红柿 → 180g。实现
.vitepress/quantity-markdown.mjs):渲染时把正文里的「数字+单位」包成<span class="qty" data-qty="…" data-unit="…">。不改动任何源.md文件。QuantityScaler:滑杆 + 档位,读取页面所有.qty按比例改写文字。缩放范围(单位)
g / kg / ml / l / 克 / 千克 / 毫升 / 升 / 斤 / 两个 / 只 / 片 / 根 / 块 / 瓣 / 朵 / 条 / 份 / 颗 / 粒 / 段 / 节 / 勺 / 匙 / 滴 / 杯 / 碗 / 把cm、时间「分钟/秒」、包装单位「包/袋/盒/瓶」测试
vitepress build通过;产出 HTML 中.qtyspan 正确生成、营养成分表保持原样、缩放组件正常打包。