首页工具默认6个+末尾「添加」格点开编辑,最多7个 v26110103

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
deploy
2026-11-01 04:08:51 +00:00
parent cb1201df42
commit 4b474d755b
2 changed files with 21 additions and 7 deletions

View File

@@ -3,7 +3,7 @@
(function () {
'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26110102';
var VER = '26110103';
const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
@@ -426,7 +426,7 @@
· 一个模块两层,二者完全解耦(同日二改,用户看过预览后定):
① #vitals 数据卡 = 「用过哪个记录类工具」:有真实记录就出,最近记录的在前,最多露 4 张、多的折叠(renderVitals);
一条真实记录都没有 → 胎动 / 体重 / 血压 / 血糖 4 张示例数卡。访客 / 产后不出。
② #htGrid 图标宫格 = 「编辑」列表:显示哪些、什么顺序,最多 HT_MAX=8 个(4×2),记录类工具也以图标出现。
② #htGrid 图标宫格 = 「编辑」列表:显示哪些、什么顺序,最多 HT_MAX=7 个 + 末尾「添加」格(4×2),记录类工具也以图标出现。
「全部工具」不占格子,在标题右侧「全部 ›」。
· 顺序 = localStorage HT_KEY(identifier 数组)。没存过 = HT_DEFAULT + 孕周替补(原 swapHomeCards 规则:没到门槛的坑位按 SWAP_POOL 换);
存过 = 完全以用户为准,没到门槛的不替换,显示「孕N周开放」、点了由 jumpApp 弹原提示。
@@ -434,8 +434,8 @@
回来后下架的自动不出现(不在前端写名单)。
· 7 个老格子(data-mini)和 6 张数据卡的 DOM 一直都在,只挪位置 / 显隐 —— 卡片接口回填、此刻 tapMini 点它们照旧能用。 */
const HT_KEY = 'mmbox.homeTools.v1', HT_META_KEY = 'mmbox.homeTools.meta.v1';
const HT_MAX = 8, HT_MIN = 1, VT_SHOW = 4;
const HT_DEFAULT = ['taidong', 'yunqitizhong', 'chanjianrili', 'taierguzhong', 'gongsuopinlv', 'yun', 'yunqixuetang', 'yunqinengbuchi'];
const HT_MAX = 7, HT_MIN = 1, VT_SHOW = 4; /* 2026-11-01 用户:默认 6 个 + 末尾「添加」格(点开编辑),最多 7 个工具 + 添加格 = 4×2 */
const HT_DEFAULT = ['taidong', 'yunqitizhong', 'chanjianrili', 'taierguzhong', 'gongsuopinlv', 'yun'];
const VT_ORDER = ['kick', 'weight', 'bp', 'glu', 'curve', 'fweight'];
const VT_TOOL = { kick: 'taidong', weight: 'yunqitizhong', bp: 'yun', glu: 'yunqixuetang', curve: 'gongsuopinlv', fweight: 'taierguzhong' }; /* 拿不到记录时间时的兜底顺序;前 4 个也是「没有任何记录」时的示例卡 */
const HT_DATA = { taidong: 'kick', yunqitizhong: 'weight', yun: 'bp', yunqixuetang: 'glu', gongsuopinlv: 'curve', taierguzhong: 'fweight' };
@@ -546,6 +546,15 @@
grid.appendChild(t);
});
$$('.tg[data-tool]', grid).forEach(t => t.classList.toggle('hide', !shown.has(t)));
/* 末尾「添加」格:始终在最后,点开编辑弹层(同「编辑」按钮) */
let add = grid.querySelector('.tg-add');
if (!add) {
add = document.createElement('button');
add.type = 'button'; add.className = 'tg tg-add ripple'; add.setAttribute('aria-label', '添加首页工具');
add.innerHTML = '<i class="tg-ic"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg></i><span class="tg-n">添加</span><span class="tg-s">编辑</span>';
add.addEventListener('click', e => { e.stopPropagation(); const b = $('#htEdit'); if (b) b.click(); });
}
grid.appendChild(add);
/* 孕周门槛角标:只有用户自己放上来的才会锁着出现(默认列表里锁着的已经换成替补) */
let anyLock = false;
$$('.tg[data-tool]', grid).forEach(el => {