首页工具默认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

@@ -7,7 +7,7 @@
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>兜爸心选 · 孕育陪伴</title>
<!-- V:26110102 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
<!-- V:26110103 缓存版本标记:改 css/js 时同步 bump 该值(与 js/app.js 的 VER 同源),静态资源按 mtime 走 ETag 自动刷新 -->
<link rel="stylesheet" href="mama-box.css">
<link rel="stylesheet" href="night.css">
<!-- 夜晚模式:首屏绘制前就按上次的选择加 class,避免先白后黑闪一下(开关在首页右上角 #nightBtn,逻辑见 app.js) -->
@@ -297,6 +297,11 @@
.tg-ic.lg{display:block;width:50px;height:50px;padding:0;background:none;box-shadow:none;border-radius:0}
.tg-ic.lg img{display:block;margin:0;position:static;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 5px 8px rgba(120,80,70,.18))}
.tg-n{font-size:13px;font-weight:600;color:#3B2A2A;white-space:nowrap}
/* 末尾「添加」格:虚线描边的浅底方块,比工具图标弱一档 */
.tg-add .tg-ic{box-sizing:border-box;width:50px;height:50px;border-radius:15px;background:#FFF7F3;border:1.5px dashed #F0B9A6;box-shadow:none;color:#E8735A}
.tg-add .tg-ic svg{width:22px;height:22px}
.tg-add .tg-n{color:#8A6F69}
.tg-add .tg-s{background:#FBEDE7;color:#C2674F}
.tg-s{max-width:100%;padding:1px 8px;border-radius:99px;font-size:11px;line-height:17px;font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:var(--tg-pl);color:var(--tg-tx)}
.tg-s b{font-weight:800}
.tg-s small{margin-left:1px;font-size:9.5px}
@@ -1881,7 +1886,7 @@
<div class="hts-head">
<div>
<h2 id="htsT">编辑首页工具</h2>
<p id="htsSub">长按拖动排序,首页最多放 8 个</p>
<p id="htsSub">长按拖动排序,首页最多放 7 个</p>
</div>
<button class="sheet-close" id="htsX" type="button" aria-label="关闭"><svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true"><path d="M3.5 3.5l9 9M12.5 3.5l-9 9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg></button>
</div>
@@ -2316,7 +2321,7 @@
<!-- 2026-10-05 首页头图:宝宝时不时动一动小手小脚(独立文件,删掉这一行即下线) -->
<script src="js/baby-limbs.js?v=26101201"></script>
<script src="js/coach.js?v=26101211"></script>
<script src="js/birth-flow.js?v=26110102"></script>
<script src="js/birth-flow.js?v=26110103"></script>
<!-- 禁止下拉回弹(2026-10-11 统一规则,与孕期体重同一段):竖向拖动时从手指下往上找还能朝该方向滚的容器,找不到才拦;横滑、双指、可滚列表不受影响 -->
<script>

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 => {