This commit is contained in:
Your Name
2026-08-17 13:59:12 +08:00
parent 79601ea176
commit 49309b7c57
62 changed files with 82 additions and 47023 deletions
@@ -1,86 +1,2 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Math) {
TongjiIcon();
}
const TongjiIcon = () => "./TongjiIcon.js";
const _sfc_main = {
__name: "CelebrateBurst",
props: {
show: { type: Boolean, default: false },
title: { type: String, default: "" },
subtitle: { type: String, default: "" }
},
setup(__props) {
const props = __props;
const particles = common_vendor.ref([]);
const cardPop = common_vendor.ref(false);
const COLORS = ["#204E2B", "#386641", "#AFE2B3", "#FBBF24", "#727970", "#DC2626"];
function buildParticles() {
const list = [];
for (let i = 0; i < 18; i++) {
const left = 8 + Math.random() * 84;
const delay = Math.random() * 0.35;
const hue = COLORS[i % COLORS.length];
const size = 10 + Math.floor(Math.random() * 14);
list.push({
id: `${Date.now()}_${i}`,
style: {
left: `${left}%`,
width: `${size}rpx`,
height: `${size}rpx`,
background: hue,
animationDelay: `${delay}s`
}
});
}
return list;
}
common_vendor.watch(
() => props.show,
(v) => {
if (v) {
particles.value = buildParticles();
cardPop.value = false;
setTimeout(() => {
cardPop.value = true;
}, 30);
} else {
particles.value = [];
cardPop.value = false;
}
}
);
return (_ctx, _cache) => {
return common_vendor.e({
a: __props.show
}, __props.show ? common_vendor.e({
b: common_vendor.f(particles.value, (p, k0, i0) => {
return {
a: p.id,
b: common_vendor.s(p.style)
};
}),
c: __props.title
}, __props.title ? common_vendor.e({
d: common_vendor.p({
name: "sparkles",
size: "lg",
color: "#204E2B"
}),
e: common_vendor.t(__props.title),
f: __props.subtitle
}, __props.subtitle ? {
g: common_vendor.t(__props.subtitle)
} : {}, {
h: cardPop.value ? 1 : ""
}) : {}, {
i: common_vendor.o(() => {
}, "49")
}) : {});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-313f45d6"]]);
wx.createComponent(Component);
"use strict";const t=require("../../common/vendor.js");Math||h();const h=()=>"./TongjiIcon.js",m={__name:"CelebrateBurst",props:{show:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""}},setup(e){const f=e,s=t.ref([]),l=t.ref(!1),i=["#204E2B","#386641","#AFE2B3","#FBBF24","#727970","#DC2626"];function d(){const a=[];for(let n=0;n<18;n++){const o=8+Math.random()*84,c=Math.random()*.35,u=i[n%i.length],r=10+Math.floor(Math.random()*14);a.push({id:`${Date.now()}_${n}`,style:{left:`${o}%`,width:`${r}rpx`,height:`${r}rpx`,background:u,animationDelay:`${c}s`}})}return a}return t.watch(()=>f.show,a=>{a?(s.value=d(),l.value=!1,setTimeout(()=>{l.value=!0},30)):(s.value=[],l.value=!1)}),(a,n)=>t.e({a:e.show},e.show?t.e({b:t.f(s.value,(o,c,u)=>({a:o.id,b:t.s(o.style)})),c:e.title},e.title?t.e({d:t.p({name:"sparkles",size:"lg",color:"#204E2B"}),e:t.t(e.title),f:e.subtitle},e.subtitle?{g:t.t(e.subtitle)}:{},{h:l.value?1:""}):{},{i:t.o(()=>{},"49")}):{})}},b=t._export_sfc(m,[["__scopeId","data-v-313f45d6"]]);wx.createComponent(b);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/components/CelebrateBurst.js.map
@@ -1,95 +1 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.celebrate-root.data-v-313f45d6 {
position: fixed;
inset: 0;
z-index: 9999;
pointer-events: none;
overflow: hidden;
}
.celebrate-particle.data-v-313f45d6 {
position: absolute;
top: -20rpx;
border-radius: 4rpx;
opacity: 0.9;
animation: celebrate-fall-313f45d6 1.6s ease-in forwards;
}
@keyframes celebrate-fall-313f45d6 {
0% {
transform: translateY(0) rotate(0deg) scale(1);
opacity: 1;
}
100% {
transform: translateY(110vh) rotate(540deg) scale(0.4);
opacity: 0;
}
}
.celebrate-card.data-v-313f45d6 {
position: absolute;
left: 50%;
top: 38%;
transform: translate(-50%, -50%) scale(0.82);
width: 78%;
max-width: 560rpx;
padding: 36rpx 32rpx 32rpx;
background: rgba(255, 255, 255, 0.96);
border-radius: 28rpx;
box-shadow: 0 20rpx 60rpx rgba(8, 145, 178, 0.22);
border: 2rpx solid rgba(8, 145, 178, 0.12);
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
opacity: 0;
transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}
.celebrate-card.pop.data-v-313f45d6 {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.celebrate-card-glow.data-v-313f45d6 {
position: absolute;
inset: -20rpx;
border-radius: 36rpx;
background: radial-gradient(circle, rgba(34, 211, 238, 0.2), transparent 70%);
pointer-events: none;
}
.celebrate-card-title.data-v-313f45d6 {
position: relative;
z-index: 1;
margin-top: 16rpx;
font-size: 36rpx;
font-weight: 800;
color: #1b1c1a;
}
.celebrate-card-sub.data-v-313f45d6 {
position: relative;
z-index: 1;
margin-top: 10rpx;
font-size: 26rpx;
color: #475569;
line-height: 1.45;
}
.celebrate-root.data-v-313f45d6{position:fixed;top:0;right:0;bottom:0;left:0;z-index:9999;pointer-events:none;overflow:hidden}.celebrate-particle.data-v-313f45d6{position:absolute;top:-20rpx;border-radius:4rpx;opacity:.9;animation:celebrate-fall-313f45d6 1.6s ease-in forwards}@keyframes celebrate-fall-313f45d6{0%{transform:translateY(0) rotate(0) scale(1);opacity:1}to{transform:translateY(110vh) rotate(540deg) scale(.4);opacity:0}}.celebrate-card.data-v-313f45d6{position:absolute;left:50%;top:38%;transform:translate(-50%,-50%) scale(.82);width:78%;max-width:560rpx;padding:36rpx 32rpx 32rpx;background:rgba(255,255,255,.96);border-radius:28rpx;box-shadow:0 20rpx 60rpx rgba(8,145,178,.22);border:2rpx solid rgba(8,145,178,.12);display:flex;flex-direction:column;align-items:center;text-align:center;opacity:0;transition:transform .35s cubic-bezier(.34,1.56,.64,1),opacity .25s ease}.celebrate-card.pop.data-v-313f45d6{opacity:1;transform:translate(-50%,-50%) scale(1)}.celebrate-card-glow.data-v-313f45d6{position:absolute;top:-20rpx;right:-20rpx;bottom:-20rpx;left:-20rpx;border-radius:36rpx;background:radial-gradient(circle,rgba(34,211,238,.2),transparent 70%);pointer-events:none}.celebrate-card-title.data-v-313f45d6{position:relative;z-index:1;margin-top:16rpx;font-size:36rpx;font-weight:800;color:#1b1c1a}.celebrate-card-sub.data-v-313f45d6{position:relative;z-index:1;margin-top:10rpx;font-size:26rpx;color:#475569;line-height:1.45}
@@ -1,100 +1,13 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const tongji_utils_svgDataUrl = require("../utils/svgDataUrl.js");
const tongji_utils_treeLevels = require("../utils/treeLevels.js");
const _sfc_main = {
__name: "SugarTreeGraphic",
props: {
level: { type: Number, default: 0 },
size: { type: String, default: "md" },
watering: { type: Boolean, default: false }
},
setup(__props) {
const MAX_LEVEL = tongji_utils_treeLevels.TREE_MAX_LEVEL;
const treeUseFallback = common_vendor.ref(true);
const props = __props;
const clampedLevel = common_vendor.computed(() => Math.min(MAX_LEVEL, Math.max(0, Number(props.level) || 0)));
const visualTier = common_vendor.computed(() => {
const lv = clampedLevel.value;
if (lv <= 0)
return 0;
if (lv <= 2)
return 1;
if (lv <= 4)
return 2;
if (lv <= 6)
return 3;
if (lv <= 8)
return 4;
return 5;
});
const treeEmoji = common_vendor.computed(() => (tongji_utils_treeLevels.TREE_LEVELS[clampedLevel.value] || tongji_utils_treeLevels.TREE_LEVELS[0]).emoji);
function buildTreeSvg(level) {
const pot = `
"use strict";const c=require("../../common/vendor.js"),L=require("../utils/svgDataUrl.js"),v=require("../utils/treeLevels.js"),M={__name:"SugarTreeGraphic",props:{level:{type:Number,default:0},size:{type:String,default:"md"},watering:{type:Boolean,default:!1}},setup(n){const l=v.TREE_MAX_LEVEL,o=c.ref(!0),x=n,r=c.computed(()=>Math.min(l,Math.max(0,Number(x.level)||0))),y=c.computed(()=>{const t=r.value;return t<=0?0:t<=2?1:t<=4?2:t<=6?3:t<=8?4:5}),$=c.computed(()=>(v.TREE_LEVELS[r.value]||v.TREE_LEVELS[0]).emoji);function h(t){const s=`
<ellipse cx="24" cy="50" rx="15" ry="3" fill="#204e2b" opacity="0.12"/>
<path d="M11 46h26c1.2 0 2 1 2 2.2v3.8c0 1-.8 1.8-1.8 1.8H10.8c-1 0-1.8-.8-1.8-1.8v-3.8c0-1.2.8-2.2 2-2.2z" fill="#E7E5E4"/>
<path d="M12.5 46h23c.8 0 1.5.7 1.5 1.5v2.2c0 .6-.5 1.1-1.1 1.1H12.1c-.6 0-1.1-.5-1.1-1.1v-2.2c0-.8.7-1.5 1.5-1.5z" fill="#D6D3D1"/>
<ellipse cx="24" cy="46.5" rx="9" ry="1.6" fill="#A8A29E" opacity="0.35"/>
`;
const soil = `<ellipse cx="24" cy="44.5" rx="8" ry="2.2" fill="#386641" opacity="0.18"/>`;
if (level <= 0) {
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 56" fill="none">
${pot}${soil}
`,u='<ellipse cx="24" cy="44.5" rx="8" ry="2.2" fill="#386641" opacity="0.18"/>';if(t<=0)return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 56" fill="none">
${s}${u}
<circle cx="24" cy="41.5" r="2.2" fill="#a8a29e" opacity="0.7"/>
<path d="M24 41.5v3.5" stroke="#78716c" stroke-width="1" stroke-linecap="round"/>
</svg>`;
}
const trunkH = level >= 6 ? 16 : level >= 3 ? 14 : 10;
const trunkY = 46 - trunkH;
const trunk = `<rect x="22.2" y="${trunkY}" width="3.6" height="${trunkH}" rx="1.8" fill="#78716C"/>
<rect x="22.6" y="${trunkY + 1}" width="2.8" height="${trunkH - 1}" rx="1.4" fill="#A8A29E" opacity="0.35"/>`;
const leaf = (cx, cy, r, fill, opacity = 1) => `<circle cx="${cx}" cy="${cy}" r="${r}" fill="${fill}" opacity="${opacity}"/>
<circle cx="${cx - r * 0.25}" cy="${cy - r * 0.2}" r="${r * 0.35}" fill="#eef6ef" opacity="0.55"/>`;
const bloom = level >= 7 ? leaf(17, 18, 3, "#fda4af", 0.95) + leaf(31, 17, 2.8, "#f9a8d4", 0.9) + leaf(24, 13, 3.2, "#fb7185", 0.95) + `<circle cx="24" cy="12" r="1.3" fill="#fef3c7"/>` : "";
const crown = level >= 9 ? leaf(12, 22, 6, "#34d399", 0.9) + leaf(36, 22, 6, "#34d399", 0.9) + leaf(24, 10, 7, "#386641", 0.95) + bloom : bloom;
let canopy = "";
if (level === 1) {
canopy = leaf(24, 38, 4, "#afe2b3") + `<path d="M24 38v-5" stroke="#386641" stroke-width="1.2" stroke-linecap="round"/>`;
} else if (level === 2) {
canopy = leaf(24, 32, 5.5, "#34d399") + leaf(20, 34, 3.5, "#6ee7b7", 0.9);
} else if (level <= 4) {
canopy = leaf(24, 28, 7, "#34d399") + leaf(17, 30, 5, "#6ee7b7", 0.9) + leaf(31, 30, 5, "#6ee7b7", 0.9);
} else if (level <= 6) {
canopy = leaf(24, 24, 9, "#22c55e") + leaf(14, 26, 7, "#4ade80", 0.92) + leaf(34, 26, 7, "#4ade80", 0.92) + leaf(24, 16, 6, "#386641", 0.88);
} else {
canopy = leaf(24, 20, 10, "#204e2b") + leaf(13, 24, 8, "#34d399", 0.95) + leaf(35, 24, 8, "#34d399", 0.95) + crown;
}
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 56" fill="none">${pot}${soil}${trunk}${canopy}</svg>`;
}
const treeImageSrc = common_vendor.computed(() => tongji_utils_svgDataUrl.svgToDataUrl(buildTreeSvg(clampedLevel.value)));
return (_ctx, _cache) => {
return common_vendor.e({
a: clampedLevel.value >= 7
}, clampedLevel.value >= 7 ? {} : {}, {
b: !treeUseFallback.value
}, !treeUseFallback.value ? {
c: treeImageSrc.value,
d: common_vendor.o(($event) => treeUseFallback.value = true, "20")
} : {
e: common_vendor.t(treeEmoji.value)
}, {
f: clampedLevel.value >= 7
}, clampedLevel.value >= 7 ? {} : {}, {
g: clampedLevel.value >= 8
}, clampedLevel.value >= 8 ? {} : {}, {
h: clampedLevel.value >= common_vendor.unref(MAX_LEVEL)
}, clampedLevel.value >= common_vendor.unref(MAX_LEVEL) ? {} : {}, {
i: common_vendor.n(`lv-${clampedLevel.value}`),
j: common_vendor.n(`tier-${visualTier.value}`),
k: common_vendor.n(`size-${__props.size}`),
l: common_vendor.n({
watering: __props.watering,
"is-max": clampedLevel.value >= common_vendor.unref(MAX_LEVEL)
})
});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d91cb5e7"]]);
wx.createComponent(Component);
</svg>`;const f=t>=6?16:t>=3?14:10,d=46-f,w=`<rect x="22.2" y="${d}" width="3.6" height="${f}" rx="1.8" fill="#78716C"/>
<rect x="22.6" y="${d+1}" width="2.8" height="${f-1}" rx="1.4" fill="#A8A29E" opacity="0.35"/>`,e=(m,g,a,b,k=1)=>`<circle cx="${m}" cy="${g}" r="${a}" fill="${b}" opacity="${k}"/>
<circle cx="${m-a*.25}" cy="${g-a*.2}" r="${a*.35}" fill="#eef6ef" opacity="0.55"/>`,p=t>=7?e(17,18,3,"#fda4af",.95)+e(31,17,2.8,"#f9a8d4",.9)+e(24,13,3.2,"#fb7185",.95)+'<circle cx="24" cy="12" r="1.3" fill="#fef3c7"/>':"",_=t>=9?e(12,22,6,"#34d399",.9)+e(36,22,6,"#34d399",.9)+e(24,10,7,"#386641",.95)+p:p;let i="";return t===1?i=e(24,38,4,"#afe2b3")+'<path d="M24 38v-5" stroke="#386641" stroke-width="1.2" stroke-linecap="round"/>':t===2?i=e(24,32,5.5,"#34d399")+e(20,34,3.5,"#6ee7b7",.9):t<=4?i=e(24,28,7,"#34d399")+e(17,30,5,"#6ee7b7",.9)+e(31,30,5,"#6ee7b7",.9):t<=6?i=e(24,24,9,"#22c55e")+e(14,26,7,"#4ade80",.92)+e(34,26,7,"#4ade80",.92)+e(24,16,6,"#386641",.88):i=e(24,20,10,"#204e2b")+e(13,24,8,"#34d399",.95)+e(35,24,8,"#34d399",.95)+_,`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 56" fill="none">${s}${u}${w}${i}</svg>`}const E=c.computed(()=>L.svgToDataUrl(h(r.value)));return(t,s)=>c.e({a:r.value>=7},r.value>=7?{}:{},{b:!o.value},o.value?{e:c.t($.value)}:{c:E.value,d:c.o(u=>o.value=!0,"20")},{f:r.value>=7},r.value>=7?{}:{},{g:r.value>=8},r.value>=8?{}:{},{h:r.value>=c.unref(l)},r.value>=c.unref(l)?{}:{},{i:c.n(`lv-${r.value}`),j:c.n(`tier-${y.value}`),k:c.n(`size-${n.size}`),l:c.n({watering:n.watering,"is-max":r.value>=c.unref(l)})})}},T=c._export_sfc(M,[["__scopeId","data-v-d91cb5e7"]]);wx.createComponent(T);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/components/SugarTreeGraphic.js.map
@@ -1,153 +1 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.sugar-tree-graphic.data-v-d91cb5e7 {
position: relative;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.size-sm.data-v-d91cb5e7 {
width: 64rpx;
height: 72rpx;
}
.size-md.data-v-d91cb5e7 {
width: 80rpx;
height: 88rpx;
}
.size-lg.data-v-d91cb5e7 {
width: 112rpx;
height: 124rpx;
}
.stg-glow.data-v-d91cb5e7 {
position: absolute;
inset: 6%;
border-radius: 50%;
background: radial-gradient(circle, rgba(32, 78, 43, 0.22) 0%, transparent 68%);
pointer-events: none;
}
.lv-0 .stg-glow.data-v-d91cb5e7 {
background: radial-gradient(circle, rgba(148, 163, 184, 0.25) 0%, transparent 70%);
}
.tier-4 .stg-glow.data-v-d91cb5e7,
.tier-5 .stg-glow.data-v-d91cb5e7,
.is-max .stg-glow.data-v-d91cb5e7 {
background: radial-gradient(circle, rgba(251, 191, 36, 0.3) 0%, rgba(32, 78, 43, 0.15) 55%, transparent 72%);
}
.stg-aura.data-v-d91cb5e7 {
position: absolute;
inset: -8%;
border-radius: 50%;
border: 2rpx solid rgba(253, 224, 71, 0.35);
animation: stg-aura-pulse-d91cb5e7 2.4s ease-in-out infinite;
pointer-events: none;
}
@keyframes stg-aura-pulse-d91cb5e7 {
0%, 100% {
transform: scale(0.92);
opacity: 0.5;
}
50% {
transform: scale(1.05);
opacity: 1;
}
}
.stg-image.data-v-d91cb5e7 {
position: relative;
z-index: 1;
width: 100%;
height: 100%;
transition: transform 0.35s ease;
}
.sugar-tree-graphic.watering .stg-image.data-v-d91cb5e7,
.sugar-tree-graphic.watering .stg-emoji.data-v-d91cb5e7 {
animation: stg-water-bounce-d91cb5e7 0.65s ease;
}
.stg-emoji.data-v-d91cb5e7 {
position: relative;
z-index: 1;
line-height: 1;
font-size: 72rpx;
}
.size-sm .stg-emoji.data-v-d91cb5e7 {
font-size: 48rpx;
}
.size-md .stg-emoji.data-v-d91cb5e7 {
font-size: 60rpx;
}
.size-lg .stg-emoji.data-v-d91cb5e7 {
font-size: 88rpx;
}
@keyframes stg-water-bounce-d91cb5e7 {
0%, 100% {
transform: scale(1);
}
35% {
transform: scale(1.1) translateY(-6rpx);
}
60% {
transform: scale(0.96) translateY(2rpx);
}
}
.stg-sparkle.data-v-d91cb5e7 {
position: absolute;
z-index: 2;
width: 8rpx;
height: 8rpx;
border-radius: 50%;
background: #fde68a;
box-shadow: 0 0 6rpx rgba(253, 224, 71, 0.8);
pointer-events: none;
animation: stg-sparkle-twinkle-d91cb5e7 1.8s ease-in-out infinite;
}
.stg-sparkle-a.data-v-d91cb5e7 {
top: 4%;
right: 16%;
}
.stg-sparkle-b.data-v-d91cb5e7 {
top: 12%;
left: 10%;
width: 6rpx;
height: 6rpx;
animation-delay: 0.4s;
}
.stg-sparkle-c.data-v-d91cb5e7 {
top: 22%;
right: 28%;
width: 10rpx;
height: 10rpx;
animation-delay: 0.8s;
}
@keyframes stg-sparkle-twinkle-d91cb5e7 {
0%, 100% {
opacity: 0.4;
transform: scale(0.8);
}
50% {
opacity: 1;
transform: scale(1.2);
}
}
.sugar-tree-graphic.data-v-d91cb5e7{position:relative;display:flex;align-items:center;justify-content:center;box-sizing:border-box}.size-sm.data-v-d91cb5e7{width:64rpx;height:72rpx}.size-md.data-v-d91cb5e7{width:80rpx;height:88rpx}.size-lg.data-v-d91cb5e7{width:112rpx;height:124rpx}.stg-glow.data-v-d91cb5e7{position:absolute;top:6%;right:6%;bottom:6%;left:6%;border-radius:50%;background:radial-gradient(circle,rgba(32,78,43,.22) 0%,transparent 68%);pointer-events:none}.lv-0 .stg-glow.data-v-d91cb5e7{background:radial-gradient(circle,rgba(148,163,184,.25) 0%,transparent 70%)}.tier-4 .stg-glow.data-v-d91cb5e7,.tier-5 .stg-glow.data-v-d91cb5e7,.is-max .stg-glow.data-v-d91cb5e7{background:radial-gradient(circle,rgba(251,191,36,.3) 0%,rgba(32,78,43,.15) 55%,transparent 72%)}.stg-aura.data-v-d91cb5e7{position:absolute;top:-8%;right:-8%;bottom:-8%;left:-8%;border-radius:50%;border:2rpx solid rgba(253,224,71,.35);animation:stg-aura-pulse-d91cb5e7 2.4s ease-in-out infinite;pointer-events:none}@keyframes stg-aura-pulse-d91cb5e7{0%,to{transform:scale(.92);opacity:.5}50%{transform:scale(1.05);opacity:1}}.stg-image.data-v-d91cb5e7{position:relative;z-index:1;width:100%;height:100%;transition:transform .35s ease}.sugar-tree-graphic.watering .stg-image.data-v-d91cb5e7,.sugar-tree-graphic.watering .stg-emoji.data-v-d91cb5e7{animation:stg-water-bounce-d91cb5e7 .65s ease}.stg-emoji.data-v-d91cb5e7{position:relative;z-index:1;line-height:1;font-size:72rpx}.size-sm .stg-emoji.data-v-d91cb5e7{font-size:48rpx}.size-md .stg-emoji.data-v-d91cb5e7{font-size:60rpx}.size-lg .stg-emoji.data-v-d91cb5e7{font-size:88rpx}@keyframes stg-water-bounce-d91cb5e7{0%,to{transform:scale(1)}35%{transform:scale(1.1) translateY(-6rpx)}60%{transform:scale(.96) translateY(2rpx)}}.stg-sparkle.data-v-d91cb5e7{position:absolute;z-index:2;width:8rpx;height:8rpx;border-radius:50%;background:#fde68a;box-shadow:0 0 6rpx rgba(253,224,71,.8);pointer-events:none;animation:stg-sparkle-twinkle-d91cb5e7 1.8s ease-in-out infinite}.stg-sparkle-a.data-v-d91cb5e7{top:4%;right:16%}.stg-sparkle-b.data-v-d91cb5e7{top:12%;left:10%;width:6rpx;height:6rpx;animation-delay:.4s}.stg-sparkle-c.data-v-d91cb5e7{top:22%;right:28%;width:10rpx;height:10rpx;animation-delay:.8s}@keyframes stg-sparkle-twinkle-d91cb5e7{0%,to{opacity:.4;transform:scale(.8)}50%{opacity:1;transform:scale(1.2)}}
File diff suppressed because one or more lines are too long
@@ -1,75 +1 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.tj-icon-wrap.data-v-f41c6626 {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.tj-icon-wrap--sm.data-v-f41c6626 {
width: 32rpx;
height: 32rpx;
}
.tj-icon-wrap--md.data-v-f41c6626 {
width: 40rpx;
height: 40rpx;
}
.tj-icon-wrap--lg.data-v-f41c6626 {
width: 48rpx;
height: 48rpx;
}
.tj-icon-wrap--xl.data-v-f41c6626 {
width: 56rpx;
height: 56rpx;
}
.tj-icon.data-v-f41c6626 {
display: block;
width: 100%;
height: 100%;
}
/* Lucide send 路径重心偏右上,微调使圆形按钮内视觉居中 */
.tj-icon--send.data-v-f41c6626 {
transform: translate(-10%, 10%);
}
.tj-icon-fallback.data-v-f41c6626 {
display: block;
line-height: 1;
font-weight: 700;
text-align: center;
}
.tj-icon-fallback--sm.data-v-f41c6626 {
font-size: 24rpx;
}
.tj-icon-fallback--md.data-v-f41c6626 {
font-size: 30rpx;
}
.tj-icon-fallback--lg.data-v-f41c6626 {
font-size: 36rpx;
}
.tj-icon-fallback--xl.data-v-f41c6626 {
font-size: 42rpx;
}
.tj-icon-wrap.data-v-f41c6626{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.tj-icon-wrap--sm.data-v-f41c6626{width:32rpx;height:32rpx}.tj-icon-wrap--md.data-v-f41c6626{width:40rpx;height:40rpx}.tj-icon-wrap--lg.data-v-f41c6626{width:48rpx;height:48rpx}.tj-icon-wrap--xl.data-v-f41c6626{width:56rpx;height:56rpx}.tj-icon.data-v-f41c6626{display:block;width:100%;height:100%}.tj-icon--send.data-v-f41c6626{transform:translate(-10%,10%)}.tj-icon-fallback.data-v-f41c6626{display:block;line-height:1;font-weight:700;text-align:center}.tj-icon-fallback--sm.data-v-f41c6626{font-size:24rpx}.tj-icon-fallback--md.data-v-f41c6626{font-size:30rpx}.tj-icon-fallback--lg.data-v-f41c6626{font-size:36rpx}.tj-icon-fallback--xl.data-v-f41c6626{font-size:42rpx}
@@ -1,28 +1,2 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
__name: "VoiceSpeakMascot",
props: {
/** 正在按住说话 / 录音中 */
active: { type: Boolean, default: false },
/** 深色条背景上使用浅色卡通 */
onDark: { type: Boolean, default: false },
size: { type: String, default: "md" }
},
setup(__props) {
return (_ctx, _cache) => {
return common_vendor.e({
a: __props.active
}, __props.active ? {} : {}, {
b: common_vendor.n(`vsm--${__props.size}`),
c: common_vendor.n({
"vsm--active": __props.active,
"vsm--on-dark": __props.onDark
})
});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-e1de3b0a"]]);
wx.createComponent(Component);
"use strict";const t=require("../../common/vendor.js"),a={__name:"VoiceSpeakMascot",props:{active:{type:Boolean,default:!1},onDark:{type:Boolean,default:!1},size:{type:String,default:"md"}},setup(e){return(c,o)=>t.e({a:e.active},e.active?{}:{},{b:t.n(`vsm--${e.size}`),c:t.n({"vsm--active":e.active,"vsm--on-dark":e.onDark})})}},n=t._export_sfc(a,[["__scopeId","data-v-e1de3b0a"]]);wx.createComponent(n);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/components/VoiceSpeakMascot.js.map
@@ -1,230 +1 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.vsm.data-v-e1de3b0a {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.vsm--md.data-v-e1de3b0a {
width: 72rpx;
height: 72rpx;
}
.vsm--sm.data-v-e1de3b0a {
width: 64rpx;
height: 64rpx;
}
.vsm-body.data-v-e1de3b0a {
position: relative;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.vsm-leaf.data-v-e1de3b0a {
position: absolute;
top: 2rpx;
left: 50%;
width: 16rpx;
height: 16rpx;
margin-left: -8rpx;
border-radius: 0 100% 0 100%;
background: #34d399;
transform: rotate(-18deg);
z-index: 2;
}
.vsm--on-dark .vsm-leaf.data-v-e1de3b0a {
background: #a7f3d0;
}
.vsm-face.data-v-e1de3b0a {
position: relative;
width: 52rpx;
height: 52rpx;
border-radius: 50%;
background: #fef9c3;
border: 3rpx solid #047857;
box-shadow: 0 4rpx 10rpx rgba(4, 120, 87, 0.18);
z-index: 1;
}
.vsm--sm .vsm-face.data-v-e1de3b0a {
width: 46rpx;
height: 46rpx;
}
.vsm--on-dark .vsm-face.data-v-e1de3b0a {
background: #fffbeb;
border-color: rgba(255, 255, 255, 0.85);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.12);
}
.vsm-eye.data-v-e1de3b0a {
position: absolute;
top: 16rpx;
width: 6rpx;
height: 8rpx;
border-radius: 50%;
background: #064e3b;
}
.vsm--sm .vsm-eye.data-v-e1de3b0a {
top: 14rpx;
width: 5rpx;
height: 7rpx;
}
.vsm--on-dark .vsm-eye.data-v-e1de3b0a {
background: #134e4a;
}
.vsm-eye--l.data-v-e1de3b0a {
left: 12rpx;
}
.vsm-eye--r.data-v-e1de3b0a {
right: 12rpx;
}
.vsm--sm .vsm-eye--l.data-v-e1de3b0a {
left: 10rpx;
}
.vsm--sm .vsm-eye--r.data-v-e1de3b0a {
right: 10rpx;
}
.vsm-blush.data-v-e1de3b0a {
position: absolute;
top: 24rpx;
width: 10rpx;
height: 6rpx;
border-radius: 50%;
background: rgba(251, 113, 133, 0.45);
opacity: 0.85;
}
.vsm--sm .vsm-blush.data-v-e1de3b0a {
top: 21rpx;
width: 8rpx;
height: 5rpx;
}
.vsm-blush--l.data-v-e1de3b0a {
left: 6rpx;
}
.vsm-blush--r.data-v-e1de3b0a {
right: 6rpx;
}
.vsm--on-dark .vsm-blush.data-v-e1de3b0a {
background: rgba(255, 255, 255, 0.35);
}
.vsm-mouth.data-v-e1de3b0a {
position: absolute;
left: 50%;
bottom: 10rpx;
width: 18rpx;
height: 8rpx;
margin-left: -9rpx;
border-radius: 0 0 18rpx 18rpx;
background: #047857;
transform-origin: center top;
}
.vsm--sm .vsm-mouth.data-v-e1de3b0a {
bottom: 9rpx;
width: 16rpx;
height: 7rpx;
margin-left: -8rpx;
}
.vsm--on-dark .vsm-mouth.data-v-e1de3b0a {
background: #ecfdf5;
}
.vsm-waves.data-v-e1de3b0a {
position: absolute;
right: -2rpx;
top: 50%;
display: flex;
align-items: flex-end;
gap: 4rpx;
height: 28rpx;
margin-top: -14rpx;
z-index: 0;
}
.vsm-wave.data-v-e1de3b0a {
width: 5rpx;
border-radius: 4rpx;
background: #047857;
animation: vsm-wave-jump-e1de3b0a 0.72s ease-in-out infinite;
}
.vsm--on-dark .vsm-wave.data-v-e1de3b0a {
background: rgba(255, 255, 255, 0.9);
}
.vsm-wave--1.data-v-e1de3b0a {
height: 10rpx;
animation-delay: 0s;
}
.vsm-wave--2.data-v-e1de3b0a {
height: 18rpx;
animation-delay: 0.12s;
}
.vsm-wave--3.data-v-e1de3b0a {
height: 12rpx;
animation-delay: 0.24s;
}
.vsm--active .vsm-body.data-v-e1de3b0a {
animation: vsm-bob-e1de3b0a 0.9s ease-in-out infinite;
}
.vsm--active .vsm-mouth.data-v-e1de3b0a {
animation: vsm-talk-e1de3b0a 0.32s ease-in-out infinite alternate;
}
.vsm--active .vsm-eye.data-v-e1de3b0a {
animation: vsm-blink-e1de3b0a 2.4s ease-in-out infinite;
}
@keyframes vsm-bob-e1de3b0a {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-4rpx);
}
}
@keyframes vsm-talk-e1de3b0a {
0% {
transform: scaleY(0.45);
border-radius: 0 0 18rpx 18rpx;
}
100% {
transform: scaleY(1.15);
height: 12rpx;
border-radius: 50%;
}
}
@keyframes vsm-blink-e1de3b0a {
0%, 42%, 46%, 100% {
transform: scaleY(1);
}
44% {
transform: scaleY(0.15);
}
}
@keyframes vsm-wave-jump-e1de3b0a {
0%, 100% {
transform: scaleY(0.45);
opacity: 0.55;
}
50% {
transform: scaleY(1);
opacity: 1;
}
}
.vsm.data-v-e1de3b0a{display:flex;align-items:center;justify-content:center;flex-shrink:0}.vsm--md.data-v-e1de3b0a{width:72rpx;height:72rpx}.vsm--sm.data-v-e1de3b0a{width:64rpx;height:64rpx}.vsm-body.data-v-e1de3b0a{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.vsm-leaf.data-v-e1de3b0a{position:absolute;top:2rpx;left:50%;width:16rpx;height:16rpx;margin-left:-8rpx;border-radius:0 100%;background:#34d399;transform:rotate(-18deg);z-index:2}.vsm--on-dark .vsm-leaf.data-v-e1de3b0a{background:#a7f3d0}.vsm-face.data-v-e1de3b0a{position:relative;width:52rpx;height:52rpx;border-radius:50%;background:#fef9c3;border:3rpx solid #047857;box-shadow:0 4rpx 10rpx rgba(4,120,87,.18);z-index:1}.vsm--sm .vsm-face.data-v-e1de3b0a{width:46rpx;height:46rpx}.vsm--on-dark .vsm-face.data-v-e1de3b0a{background:#fffbeb;border-color:rgba(255,255,255,.85);box-shadow:0 4rpx 12rpx rgba(0,0,0,.12)}.vsm-eye.data-v-e1de3b0a{position:absolute;top:16rpx;width:6rpx;height:8rpx;border-radius:50%;background:#064e3b}.vsm--sm .vsm-eye.data-v-e1de3b0a{top:14rpx;width:5rpx;height:7rpx}.vsm--on-dark .vsm-eye.data-v-e1de3b0a{background:#134e4a}.vsm-eye--l.data-v-e1de3b0a{left:12rpx}.vsm-eye--r.data-v-e1de3b0a{right:12rpx}.vsm--sm .vsm-eye--l.data-v-e1de3b0a{left:10rpx}.vsm--sm .vsm-eye--r.data-v-e1de3b0a{right:10rpx}.vsm-blush.data-v-e1de3b0a{position:absolute;top:24rpx;width:10rpx;height:6rpx;border-radius:50%;background:rgba(251,113,133,.45);opacity:.85}.vsm--sm .vsm-blush.data-v-e1de3b0a{top:21rpx;width:8rpx;height:5rpx}.vsm-blush--l.data-v-e1de3b0a{left:6rpx}.vsm-blush--r.data-v-e1de3b0a{right:6rpx}.vsm--on-dark .vsm-blush.data-v-e1de3b0a{background:rgba(255,255,255,.35)}.vsm-mouth.data-v-e1de3b0a{position:absolute;left:50%;bottom:10rpx;width:18rpx;height:8rpx;margin-left:-9rpx;border-radius:0 0 18rpx 18rpx;background:#047857;transform-origin:center top}.vsm--sm .vsm-mouth.data-v-e1de3b0a{bottom:9rpx;width:16rpx;height:7rpx;margin-left:-8rpx}.vsm--on-dark .vsm-mouth.data-v-e1de3b0a{background:#ecfdf5}.vsm-waves.data-v-e1de3b0a{position:absolute;right:-2rpx;top:50%;display:flex;align-items:flex-end;gap:4rpx;height:28rpx;margin-top:-14rpx;z-index:0}.vsm-wave.data-v-e1de3b0a{width:5rpx;border-radius:4rpx;background:#047857;animation:vsm-wave-jump-e1de3b0a .72s ease-in-out infinite}.vsm--on-dark .vsm-wave.data-v-e1de3b0a{background:rgba(255,255,255,.9)}.vsm-wave--1.data-v-e1de3b0a{height:10rpx;animation-delay:0s}.vsm-wave--2.data-v-e1de3b0a{height:18rpx;animation-delay:.12s}.vsm-wave--3.data-v-e1de3b0a{height:12rpx;animation-delay:.24s}.vsm--active .vsm-body.data-v-e1de3b0a{animation:vsm-bob-e1de3b0a .9s ease-in-out infinite}.vsm--active .vsm-mouth.data-v-e1de3b0a{animation:vsm-talk-e1de3b0a .32s ease-in-out infinite alternate}.vsm--active .vsm-eye.data-v-e1de3b0a{animation:vsm-blink-e1de3b0a 2.4s ease-in-out infinite}@keyframes vsm-bob-e1de3b0a{0%,to{transform:translateY(0)}50%{transform:translateY(-4rpx)}}@keyframes vsm-talk-e1de3b0a{0%{transform:scaleY(.45);border-radius:0 0 18rpx 18rpx}to{transform:scaleY(1.15);height:12rpx;border-radius:50%}}@keyframes vsm-blink-e1de3b0a{0%,42%,46%,to{transform:scaleY(1)}44%{transform:scaleY(.15)}}@keyframes vsm-wave-jump-e1de3b0a{0%,to{transform:scaleY(.45);opacity:.55}50%{transform:scaleY(1);opacity:1}}
@@ -1,307 +1,2 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const tongji_utils_aiStreamRequest = require("../utils/aiStreamRequest.js");
const DIET_AI_PREFILL_KEY = "tongji_diet_ai_prefill";
const emptyDietAiRecommend = () => ({
breakfast: "",
drinks: "",
lunch: "",
dinner: "",
tips: "",
avoid: [],
analysis: [],
exercise: null,
disclaimer: "",
rules_summary: "",
source: "",
date: ""
});
function useDietAi(proxy, { diagnosisId, showUserToast, formatUserMessage }) {
const dietAiRecommend = common_vendor.ref(emptyDietAiRecommend());
const dietAiLoading = common_vendor.ref(false);
const dietAiStreaming = common_vendor.ref(false);
const dietAiReplacing = common_vendor.ref(false);
const dietAiStreamField = common_vendor.ref("");
let dietStreamBuffer = "";
const dietAiAskText = common_vendor.ref("");
const dietAiAsking = common_vendor.ref(false);
const dietAiAskResult = common_vendor.ref({ advice: "", level: "", level_label: "", portion: "", food: "" });
const hasDietAiMealContent = common_vendor.computed(() => {
const r = dietAiRecommend.value;
return !!(r.breakfast || r.drinks || r.lunch || r.dinner || r.tips);
});
function detectDietStreamField(text) {
const tail = String(text || "").match(/(?:^|\n)(早餐|喝的|午餐|晚餐|提示|少碰)[::]\s*([^\n]*)$/);
if (!tail)
return "breakfast";
const map = { "早餐": "breakfast", "喝的": "drinks", "午餐": "lunch", "晚餐": "dinner", "提示": "tips", "少碰": "tips" };
return map[tail[1]] || "breakfast";
}
function mergePartialDietFromStream() {
const partial = tongji_utils_aiStreamRequest.parsePartialDietPlainText(dietStreamBuffer);
const next = { ...dietAiRecommend.value };
for (const key of ["breakfast", "drinks", "lunch", "dinner", "tips"]) {
if (partial[key] != null)
next[key] = partial[key];
}
if (Array.isArray(partial.avoid))
next.avoid = partial.avoid;
dietAiRecommend.value = next;
dietAiStreamField.value = detectDietStreamField(dietStreamBuffer);
}
function applyDietRecommendPayload(payload) {
if (!payload)
return;
const prevAnalysis = dietAiRecommend.value.analysis;
const prevExercise = dietAiRecommend.value.exercise;
dietAiRecommend.value = {
...emptyDietAiRecommend(),
...payload,
avoid: Array.isArray(payload.avoid) ? payload.avoid : [],
analysis: Array.isArray(payload.analysis) && payload.analysis.length ? payload.analysis : Array.isArray(prevAnalysis) ? prevAnalysis : [],
exercise: payload.exercise && typeof payload.exercise === "object" ? payload.exercise : prevExercise || null
};
}
function resolveDietDonePayload(payload) {
if (!payload)
return payload;
if (payload.source !== "rule" || !dietStreamBuffer)
return payload;
const streamed = tongji_utils_aiStreamRequest.parsePartialDietPlainText(dietStreamBuffer);
if (!streamed.breakfast)
return payload;
return {
...emptyDietAiRecommend(),
...payload,
breakfast: streamed.breakfast,
drinks: streamed.drinks || payload.drinks || "",
lunch: streamed.lunch || payload.lunch || "",
dinner: streamed.dinner || payload.dinner || "",
tips: streamed.tips || payload.tips || "",
avoid: Array.isArray(streamed.avoid) && streamed.avoid.length ? streamed.avoid : payload.avoid || [],
source: "ai",
disclaimer: "AI 建议供参考,仍请结合医嘱与血糖监测。"
};
}
function onDietAiStreamEvent(event, payload) {
if (event === "analysis") {
if (Array.isArray(payload == null ? void 0 : payload.analysis)) {
dietAiRecommend.value = { ...dietAiRecommend.value, analysis: payload.analysis };
}
} else if (event === "exercise") {
if ((payload == null ? void 0 : payload.exercise) && typeof payload.exercise === "object") {
dietAiRecommend.value = { ...dietAiRecommend.value, exercise: payload.exercise };
}
} else if (event === "delta") {
dietAiStreaming.value = true;
if (payload.buffer != null) {
dietStreamBuffer = payload.buffer;
} else {
dietStreamBuffer += payload.text || "";
}
mergePartialDietFromStream();
} else if (event === "done") {
applyDietRecommendPayload(resolveDietDonePayload(payload));
dietStreamBuffer = "";
dietAiStreamField.value = "";
} else if (event === "error") {
showUserToast(formatUserMessage(payload == null ? void 0 : payload.message, "饮食建议加载失败"));
}
}
async function fetchDietAiRecommendFallback(refresh) {
const res = await proxy.apiUrl({
url: "/api/tcm/dailyDietAiRecommend",
method: "GET",
timeout: 35e3,
data: {
diagnosis_id: diagnosisId.value,
refresh: refresh ? 1 : 0,
...refresh ? { _t: Date.now() } : {}
}
}, false);
if ((res == null ? void 0 : res.code) === 1 && res.data) {
applyDietRecommendPayload(res.data);
} else if (res == null ? void 0 : res.msg) {
showUserToast(res.msg);
}
}
async function fetchDietAiRecommend(refresh = false) {
if (!diagnosisId.value || dietAiLoading.value)
return;
dietAiLoading.value = true;
dietAiStreaming.value = false;
dietAiReplacing.value = !!refresh;
dietStreamBuffer = "";
dietAiStreamField.value = "";
if (refresh) {
applyDietRecommendPayload(emptyDietAiRecommend());
}
try {
await tongji_utils_aiStreamRequest.requestAiStream({
baseUrl: proxy.$url,
url: "/api/tcm/dailyDietAiRecommendStream",
method: "GET",
data: {
diagnosis_id: diagnosisId.value,
refresh: refresh ? 1 : 0,
...refresh ? { _t: Date.now() } : {}
},
onEvent: onDietAiStreamEvent,
fallback: () => fetchDietAiRecommendFallback(refresh)
});
} catch (e) {
try {
await fetchDietAiRecommendFallback(refresh);
} catch (e2) {
showUserToast("饮食建议加载失败");
}
} finally {
dietAiLoading.value = false;
dietAiStreaming.value = false;
dietAiReplacing.value = false;
dietAiStreamField.value = "";
}
}
function refreshDietAiRecommend() {
if (dietAiLoading.value)
return;
fetchDietAiRecommend(true);
}
async function askDietAiFoodFallback(q) {
const res = await proxy.apiUrl({
url: "/api/tcm/dailyDietAiAsk",
method: "POST",
timeout: 35e3,
data: {
diagnosis_id: diagnosisId.value,
question: q
}
}, false);
if ((res == null ? void 0 : res.code) === 1 && res.data) {
dietAiAskResult.value = {
advice: res.data.advice || "",
level: res.data.level || "",
level_label: res.data.level_label || "",
portion: res.data.portion || "",
food: res.data.food || q
};
} else {
showUserToast(formatUserMessage(res == null ? void 0 : res.msg, "咨询失败"));
}
}
async function askDietAiFood() {
const q = String(dietAiAskText.value || "").trim();
if (!q) {
showUserToast("请输入想咨询的食物");
return;
}
if (!diagnosisId.value)
return;
dietAiAskText.value = "";
dietAiAsking.value = true;
dietAiAskResult.value = { advice: "", level: "", level_label: "", portion: "", food: "" };
try {
await tongji_utils_aiStreamRequest.requestAiStream({
baseUrl: proxy.$url,
url: "/api/tcm/dailyDietAiAskStream",
method: "POST",
data: {
diagnosis_id: diagnosisId.value,
question: q
},
onEvent: (event, payload) => {
if (event === "start" && !dietAiAskResult.value.advice) {
dietAiAskResult.value = { ...dietAiAskResult.value, advice: payload.message || "正在想…" };
} else if (event === "delta") {
dietAiAskResult.value = {
...dietAiAskResult.value,
advice: payload.advice || dietAiAskResult.value.advice
};
} else if (event === "done") {
dietAiAskResult.value = {
advice: payload.advice || "",
level: payload.level || "",
level_label: payload.level_label || "",
portion: payload.portion || "",
food: payload.food || q
};
} else if (event === "error") {
showUserToast(formatUserMessage(payload == null ? void 0 : payload.message, "咨询失败"));
}
},
fallback: () => askDietAiFoodFallback(q)
});
} catch (e) {
try {
await askDietAiFoodFallback(q);
} catch (e2) {
showUserToast("网络异常,请稍后再试");
}
} finally {
dietAiAsking.value = false;
}
}
function onDietAiAskInput(e) {
var _a;
dietAiAskText.value = ((_a = e == null ? void 0 : e.detail) == null ? void 0 : _a.value) ?? "";
}
function saveDietPrefillToStorage() {
const r = dietAiRecommend.value;
if (!r.breakfast)
return;
try {
common_vendor.index.setStorageSync(DIET_AI_PREFILL_KEY, {
breakfast: r.breakfast,
drinks: r.drinks || "",
lunch: r.lunch,
dinner: r.dinner,
tips: r.tips || ""
});
} catch (e) {
}
}
function goMoreDietForm(withPrefill = false) {
if (withPrefill)
saveDietPrefillToStorage();
common_vendor.index.navigateTo({ url: "/tongji/pages/more?openDiet=1" });
}
async function applyDietAiToForm() {
if (!dietAiRecommend.value.breakfast) {
await fetchDietAiRecommend(false);
}
goMoreDietForm(true);
}
function openDietForm() {
goMoreDietForm(false);
}
return {
dietAiRecommend,
dietAiLoading,
dietAiStreaming,
dietAiReplacing,
dietAiStreamField,
dietAiAskText,
dietAiAsking,
dietAiAskResult,
hasDietAiMealContent,
fetchDietAiRecommend,
refreshDietAiRecommend,
askDietAiFood,
onDietAiAskInput,
applyDietAiToForm,
openDietForm
};
}
function consumeDietAiPrefill() {
try {
const data = common_vendor.index.getStorageSync(DIET_AI_PREFILL_KEY);
common_vendor.index.removeStorageSync(DIET_AI_PREFILL_KEY);
if (data && typeof data === "object" && data.breakfast)
return data;
} catch (e) {
}
return null;
}
exports.consumeDietAiPrefill = consumeDietAiPrefill;
exports.useDietAi = useDietAi;
"use strict";const r=require("../../common/vendor.js"),d=require("../utils/aiStreamRequest.js"),_="tongji_diet_ai_prefill",A=()=>({breakfast:"",drinks:"",lunch:"",dinner:"",tips:"",avoid:[],analysis:[],exercise:null,disclaimer:"",rules_summary:"",source:"",date:""});function B(a,{diagnosisId:u,showUserToast:c,formatUserMessage:k}){const n=r.ref(A()),f=r.ref(!1),v=r.ref(!1),D=r.ref(!1),o=r.ref("");let s="";const m=r.ref(""),b=r.ref(!1),l=r.ref({advice:"",level:"",level_label:"",portion:"",food:""}),R=r.computed(()=>{const e=n.value;return!!(e.breakfast||e.drinks||e.lunch||e.dinner||e.tips)});function F(e){const i=String(e||"").match(/(?:^|\n)(早餐|喝的|午餐|晚餐|提示|少碰)[::]\s*([^\n]*)$/);return i&&{早餐:"breakfast",喝的:"drinks",午餐:"lunch",晚餐:"dinner",提示:"tips",少碰:"tips"}[i[1]]||"breakfast"}function E(){const e=d.parsePartialDietPlainText(s),i={...n.value};for(const t of["breakfast","drinks","lunch","dinner","tips"])e[t]!=null&&(i[t]=e[t]);Array.isArray(e.avoid)&&(i.avoid=e.avoid),n.value=i,o.value=F(s)}function g(e){if(!e)return;const i=n.value.analysis,t=n.value.exercise;n.value={...A(),...e,avoid:Array.isArray(e.avoid)?e.avoid:[],analysis:Array.isArray(e.analysis)&&e.analysis.length?e.analysis:Array.isArray(i)?i:[],exercise:e.exercise&&typeof e.exercise=="object"?e.exercise:t||null}}function q(e){if(!e||e.source!=="rule"||!s)return e;const i=d.parsePartialDietPlainText(s);return i.breakfast?{...A(),...e,breakfast:i.breakfast,drinks:i.drinks||e.drinks||"",lunch:i.lunch||e.lunch||"",dinner:i.dinner||e.dinner||"",tips:i.tips||e.tips||"",avoid:Array.isArray(i.avoid)&&i.avoid.length?i.avoid:e.avoid||[],source:"ai",disclaimer:"AI 建议供参考,仍请结合医嘱与血糖监测。"}:e}function j(e,i){e==="analysis"?Array.isArray(i==null?void 0:i.analysis)&&(n.value={...n.value,analysis:i.analysis}):e==="exercise"?i!=null&&i.exercise&&typeof i.exercise=="object"&&(n.value={...n.value,exercise:i.exercise}):e==="delta"?(v.value=!0,i.buffer!=null?s=i.buffer:s+=i.text||"",E()):e==="done"?(g(q(i)),s="",o.value=""):e==="error"&&c(k(i==null?void 0:i.message,"饮食建议加载失败"))}async function x(e){const i=await a.apiUrl({url:"/api/tcm/dailyDietAiRecommend",method:"GET",timeout:35e3,data:{diagnosis_id:u.value,refresh:e?1:0,...e?{_t:Date.now()}:{}}},!1);(i==null?void 0:i.code)===1&&i.data?g(i.data):i!=null&&i.msg&&c(i.msg)}async function S(e=!1){if(!(!u.value||f.value)){f.value=!0,v.value=!1,D.value=!!e,s="",o.value="",e&&g(A());try{await d.requestAiStream({baseUrl:a.$url,url:"/api/tcm/dailyDietAiRecommendStream",method:"GET",data:{diagnosis_id:u.value,refresh:e?1:0,...e?{_t:Date.now()}:{}},onEvent:j,fallback:()=>x(e)})}catch{try{await x(e)}catch{c("饮食建议加载失败")}}finally{f.value=!1,v.value=!1,D.value=!1,o.value=""}}}function T(){f.value||S(!0)}async function h(e){const i=await a.apiUrl({url:"/api/tcm/dailyDietAiAsk",method:"POST",timeout:35e3,data:{diagnosis_id:u.value,question:e}},!1);(i==null?void 0:i.code)===1&&i.data?l.value={advice:i.data.advice||"",level:i.data.level||"",level_label:i.data.level_label||"",portion:i.data.portion||"",food:i.data.food||e}:c(k(i==null?void 0:i.msg,"咨询失败"))}async function w(){const e=String(m.value||"").trim();if(!e){c("请输入想咨询的食物");return}if(u.value){m.value="",b.value=!0,l.value={advice:"",level:"",level_label:"",portion:"",food:""};try{await d.requestAiStream({baseUrl:a.$url,url:"/api/tcm/dailyDietAiAskStream",method:"POST",data:{diagnosis_id:u.value,question:e},onEvent:(i,t)=>{i==="start"&&!l.value.advice?l.value={...l.value,advice:t.message||"正在想…"}:i==="delta"?l.value={...l.value,advice:t.advice||l.value.advice}:i==="done"?l.value={advice:t.advice||"",level:t.level||"",level_label:t.level_label||"",portion:t.portion||"",food:t.food||e}:i==="error"&&c(k(t==null?void 0:t.message,"咨询失败"))},fallback:()=>h(e)})}catch{try{await h(e)}catch{c("网络异常,请稍后再试")}}finally{b.value=!1}}}function L(e){var i;m.value=((i=e==null?void 0:e.detail)==null?void 0:i.value)??""}function $(){const e=n.value;if(e.breakfast)try{r.index.setStorageSync(_,{breakfast:e.breakfast,drinks:e.drinks||"",lunch:e.lunch,dinner:e.dinner,tips:e.tips||""})}catch{}}function P(e=!1){e&&$(),r.index.navigateTo({url:"/tongji/pages/more?openDiet=1"})}async function G(){n.value.breakfast||await S(!1),P(!0)}function O(){P(!1)}return{dietAiRecommend:n,dietAiLoading:f,dietAiStreaming:v,dietAiReplacing:D,dietAiStreamField:o,dietAiAskText:m,dietAiAsking:b,dietAiAskResult:l,hasDietAiMealContent:R,fetchDietAiRecommend:S,refreshDietAiRecommend:T,askDietAiFood:w,onDietAiAskInput:L,applyDietAiToForm:G,openDietForm:O}}function C(){try{const a=r.index.getStorageSync(_);if(r.index.removeStorageSync(_),a&&typeof a=="object"&&a.breakfast)return a}catch{}return null}exports.consumeDietAiPrefill=C;exports.useDietAi=B;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/composables/useDietAi.js.map
@@ -1,291 +1,2 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const MIN_HOLD_MS = 280;
function isBenignSttError(msg, retcode) {
const m = String(msg || "").toLowerCase();
if (/internal voice data failed/i.test(m))
return true;
if (/voice data failed/i.test(m))
return true;
if (/recordfailed|record failed|record manager/i.test(m))
return true;
if (/please stop after start/i.test(m))
return true;
if (/no recognition|not start|未开始|无识别/i.test(m))
return true;
const code = Number(retcode);
if (code === -30002 || code === -30003 || code === -30012)
return true;
return false;
}
function friendlySttError(msg) {
const m = String(msg || "").trim();
if (!m || isBenignSttError(m))
return "";
if (/not allowed|auth|permission|权限|麦克风/i.test(m))
return "请允许使用麦克风";
if (/network|网络|timeout/i.test(m))
return "网络异常,请稍后再试";
return "语音识别失败,请重试";
}
let sharedManager = null;
let sharedManagerInited = false;
let sharedRecording = false;
let activeCtl = null;
function getSharedRecordManager() {
if (sharedManagerInited)
return sharedManager;
sharedManagerInited = true;
try {
const plugin = requirePlugin("WechatSI");
sharedManager = plugin.getRecordRecognitionManager();
} catch (e) {
common_vendor.index.__f__("warn", "at tongji/composables/useSpeechToText.js:44", "WechatSI record recognition not available", e);
sharedManager = null;
return null;
}
if (!sharedManager)
return null;
sharedManager.onStart = () => {
sharedRecording = true;
if (activeCtl)
activeCtl.handleStart();
};
sharedManager.onRecognize = (res) => {
if (activeCtl)
activeCtl.handleRecognize(res);
};
sharedManager.onStop = (res) => {
sharedRecording = false;
if (activeCtl)
activeCtl.handleStop(res);
};
sharedManager.onError = (res) => {
sharedRecording = false;
if (activeCtl)
activeCtl.handleError(res);
};
return sharedManager;
}
function useSpeechToText({ onResult, onSettle, onPartial, onError, showToast } = {}) {
const sttListening = common_vendor.ref(false);
const sttHolding = common_vendor.ref(false);
const sttSupported = common_vendor.ref(false);
let wxRecordManager = null;
let holdStartTs = 0;
let holdSessionId = 0;
let startRequested = false;
let recordAuthorized = null;
let pendingStartSession = 0;
function notify(msg) {
if (!msg)
return;
if (typeof showToast === "function") {
showToast(msg);
return;
}
common_vendor.index.showToast({ title: msg, icon: "none", duration: 2e3 });
}
function emitResult(text) {
const t = String(text || "").trim();
const heldMs = Date.now() - holdStartTs;
if (typeof onSettle === "function") {
const handled = onSettle(t, { heldMs });
if (handled === true)
return;
}
if (!t) {
if (heldMs < MIN_HOLD_MS)
return;
notify("没听清,请再试一次");
return;
}
if (typeof onResult === "function") {
onResult(t);
}
}
function stopListening() {
const ownsRecording = sharedRecording && activeCtl === controller;
if (wxRecordManager && (sttListening.value || ownsRecording)) {
try {
wxRecordManager.stop();
} catch (e) {
}
}
startRequested = false;
sttHolding.value = false;
sttListening.value = false;
}
function ensureRecordAuth(onGranted) {
if (recordAuthorized === true) {
onGranted();
return;
}
common_vendor.index.authorize({
scope: "scope.record",
success() {
recordAuthorized = true;
onGranted();
},
fail() {
recordAuthorized = false;
sttHolding.value = false;
common_vendor.index.showModal({
title: "需要麦克风权限",
content: "请在设置中允许使用麦克风,以便长按说话",
confirmText: "去设置",
success(res) {
if (res.confirm) {
common_vendor.index.openSetting({});
}
}
});
}
});
}
function actuallyStartWechat(session) {
if (!wxRecordManager || session !== holdSessionId || !sttHolding.value) {
return;
}
try {
startRequested = true;
wxRecordManager.start({
duration: 6e4,
lang: "zh_CN"
});
} catch (e) {
startRequested = false;
sharedRecording = false;
sttHolding.value = false;
notify("无法开始录音");
}
}
function startWechatRecord(session) {
if (!wxRecordManager || session !== holdSessionId || !sttHolding.value) {
return;
}
if (sharedRecording || startRequested) {
pendingStartSession = session;
try {
wxRecordManager.stop();
} catch (e) {
}
return;
}
actuallyStartWechat(session);
}
function beginHoldSpeech() {
if (!sttSupported.value) {
notify("当前环境不支持语音输入");
return;
}
if (sttHolding.value)
return;
const session = ++holdSessionId;
holdStartTs = Date.now();
sttHolding.value = true;
activeCtl = controller;
ensureRecordAuth(() => startWechatRecord(session));
}
function endHoldSpeech(force = false) {
let recording = false;
recording = sharedRecording && activeCtl === controller;
if (!force && !sttHolding.value && !sttListening.value && !startRequested && !recording) {
return;
}
sttHolding.value = false;
pendingStartSession = 0;
if (sttListening.value || recording) {
stopListening();
return;
}
if (startRequested) {
startRequested = false;
holdSessionId += 1;
return;
}
holdSessionId += 1;
}
const controller = {
handleStart() {
if (!sttHolding.value) {
startRequested = false;
sttListening.value = false;
return;
}
startRequested = false;
sttListening.value = true;
},
handleRecognize(res) {
if (typeof onPartial !== "function")
return;
const t = String((res == null ? void 0 : res.result) || "").trim();
if (t)
onPartial(t);
},
handleStop(res) {
sttListening.value = false;
startRequested = false;
if (pendingStartSession && pendingStartSession === holdSessionId && sttHolding.value) {
const s = pendingStartSession;
pendingStartSession = 0;
actuallyStartWechat(s);
return;
}
pendingStartSession = 0;
emitResult(res == null ? void 0 : res.result);
},
handleError(res) {
sttListening.value = false;
startRequested = false;
const msg = res && res.msg || "";
const retcode = res && (res.retcode ?? res.errCode ?? res.code);
if (/please stop after start/i.test(msg)) {
try {
wxRecordManager.stop();
} catch (e) {
}
pendingStartSession = sttHolding.value ? holdSessionId : 0;
return;
}
pendingStartSession = 0;
sttHolding.value = false;
const heldMs = Date.now() - holdStartTs;
if (isBenignSttError(msg, retcode) || heldMs < MIN_HOLD_MS) {
if (typeof onError === "function")
onError(msg || "");
return;
}
if (typeof onError === "function") {
const handled = onError(msg || "");
if (handled === true)
return;
}
const tip = friendlySttError(msg);
if (tip)
notify(tip);
}
};
wxRecordManager = getSharedRecordManager();
sttSupported.value = !!wxRecordManager;
common_vendor.onUnmounted(() => {
sttHolding.value = false;
holdSessionId += 1;
pendingStartSession = 0;
stopListening();
if (activeCtl === controller) {
activeCtl = null;
}
});
return {
sttListening,
sttHolding,
sttSupported,
beginHoldSpeech,
endHoldSpeech,
stopSpeechToText: endHoldSpeech
};
}
exports.isBenignSttError = isBenignSttError;
exports.useSpeechToText = useSpeechToText;
"use strict";const s=require("../../common/vendor.js"),C=280;function w(n,u){const d=String(n||"").toLowerCase();if(/internal voice data failed/i.test(d)||/voice data failed/i.test(d)||/recordfailed|record failed|record manager/i.test(d)||/please stop after start/i.test(d)||/no recognition|not start|未开始|无识别/i.test(d))return!0;const h=Number(u);return h===-30002||h===-30003||h===-30012}function N(n){const u=String(n||"").trim();return!u||w(u)?"":/not allowed|auth|permission|权限|麦克风/i.test(u)?"请允许使用麦克风":/network|网络|timeout/i.test(u)?"网络异常,请稍后再试":"语音识别失败,请重试"}let c=null,D=!1,g=!1,i=null;function j(){if(D)return c;D=!0;try{c=requirePlugin("WechatSI").getRecordRecognitionManager()}catch(n){return s.index.__f__("warn","at tongji/composables/useSpeechToText.js:44","WechatSI record recognition not available",n),c=null,null}return c?(c.onStart=()=>{g=!0,i&&i.handleStart()},c.onRecognize=n=>{i&&i.handleRecognize(n)},c.onStop=n=>{g=!1,i&&i.handleStop(n)},c.onError=n=>{g=!1,i&&i.handleError(n)},c):null}function A({onResult:n,onSettle:u,onPartial:d,onError:h,showToast:M}={}){const l=s.ref(!1),r=s.ref(!1),y=s.ref(!1);let f=null,R=0,p=0,o=!1,x=null,a=0;function v(e){if(e){if(typeof M=="function"){M(e);return}s.index.showToast({title:e,icon:"none",duration:2e3})}}function H(e){const t=String(e||"").trim(),m=Date.now()-R;if(!(typeof u=="function"&&u(t,{heldMs:m})===!0)){if(!t){if(m<C)return;v("没听清,请再试一次");return}typeof n=="function"&&n(t)}}function T(){const e=g&&i===S;if(f&&(l.value||e))try{f.stop()}catch{}o=!1,r.value=!1,l.value=!1}function L(e){if(x===!0){e();return}s.index.authorize({scope:"scope.record",success(){x=!0,e()},fail(){x=!1,r.value=!1,s.index.showModal({title:"需要麦克风权限",content:"请在设置中允许使用麦克风,以便长按说话",confirmText:"去设置",success(t){t.confirm&&s.index.openSetting({})}})}})}function _(e){if(!(!f||e!==p||!r.value))try{o=!0,f.start({duration:6e4,lang:"zh_CN"})}catch{o=!1,g=!1,r.value=!1,v("无法开始录音")}}function W(e){if(!(!f||e!==p||!r.value)){if(g||o){a=e;try{f.stop()}catch{}return}_(e)}}function q(){if(!y.value){v("当前环境不支持语音输入");return}if(r.value)return;const e=++p;R=Date.now(),r.value=!0,i=S,L(()=>W(e))}function z(e=!1){let t=!1;if(t=g&&i===S,!(!e&&!r.value&&!l.value&&!o&&!t)){if(r.value=!1,a=0,l.value||t){T();return}if(o){o=!1,p+=1;return}p+=1}}const S={handleStart(){if(!r.value){o=!1,l.value=!1;return}o=!1,l.value=!0},handleRecognize(e){if(typeof d!="function")return;const t=String((e==null?void 0:e.result)||"").trim();t&&d(t)},handleStop(e){if(l.value=!1,o=!1,a&&a===p&&r.value){const t=a;a=0,_(t);return}a=0,H(e==null?void 0:e.result)},handleError(e){l.value=!1,o=!1;const t=e&&e.msg||"",m=e&&(e.retcode??e.errCode??e.code);if(/please stop after start/i.test(t)){try{f.stop()}catch{}a=r.value?p:0;return}a=0,r.value=!1;const I=Date.now()-R;if(w(t,m)||I<C){typeof h=="function"&&h(t||"");return}if(typeof h=="function"&&h(t||"")===!0)return;const b=N(t);b&&v(b)}};return f=j(),y.value=!!f,s.onUnmounted(()=>{r.value=!1,p+=1,a=0,T(),i===S&&(i=null)}),{sttListening:l,sttHolding:r,sttSupported:y,beginHoldSpeech:q,endHoldSpeech:z,stopSpeechToText:z}}exports.isBenignSttError=w;exports.useSpeechToText=A;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/composables/useSpeechToText.js.map
@@ -1,64 +1,2 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
function useGameAuth(proxy) {
let loginPromise = null;
function hasToken() {
return !!String(common_vendor.index.getStorageSync("token") || "").trim();
}
function clearToken() {
common_vendor.index.removeStorageSync("token");
}
function wxLoginCode() {
return new Promise((resolve, reject) => {
common_vendor.index.login({
provider: "weixin",
success: (res) => (res == null ? void 0 : res.code) ? resolve(res.code) : reject(new Error("微信登录未返回 code")),
fail: reject
});
});
}
async function loginWithCode(code) {
var _a;
const res = await proxy.apiUrl({
url: "/api/login/mnpLogin",
method: "POST",
data: { code }
}, false);
if ((res == null ? void 0 : res.code) !== 1 || !((_a = res.data) == null ? void 0 : _a.token)) {
clearToken();
throw new Error((res == null ? void 0 : res.msg) || "登录失败");
}
common_vendor.index.setStorageSync("token", res.data.token);
common_vendor.index.setStorageSync("userData", res.data);
return true;
}
async function verifyOrLogin() {
if (hasToken()) {
try {
const res = await proxy.apiUrl({ url: "/api/user/info", method: "POST" }, false);
if ((res == null ? void 0 : res.code) === 1 && res.data) {
common_vendor.index.setStorageSync("userData", res.data);
return true;
}
if ((res == null ? void 0 : res.code) !== -1)
return true;
} catch (_) {
return true;
}
clearToken();
}
const code = await wxLoginCode();
return loginWithCode(code);
}
async function ensureLoggedIn() {
if (loginPromise)
return loginPromise;
loginPromise = verifyOrLogin().then((ok) => !!ok).catch(() => false).finally(() => {
loginPromise = null;
});
return loginPromise;
}
return { ensureLoggedIn };
}
exports.useGameAuth = useGameAuth;
"use strict";const o=require("../../../common/vendor.js");function g(r){let i=null;function u(){return!!String(o.index.getStorageSync("token")||"").trim()}function a(){o.index.removeStorageSync("token")}function c(){return new Promise((e,n)=>{o.index.login({provider:"weixin",success:t=>t!=null&&t.code?e(t.code):n(new Error("微信登录未返回 code")),fail:n})})}async function d(e){var t;const n=await r.apiUrl({url:"/api/login/mnpLogin",method:"POST",data:{code:e}},!1);if((n==null?void 0:n.code)!==1||!((t=n.data)!=null&&t.token))throw a(),new Error((n==null?void 0:n.msg)||"登录失败");return o.index.setStorageSync("token",n.data.token),o.index.setStorageSync("userData",n.data),!0}async function l(){if(u()){try{const n=await r.apiUrl({url:"/api/user/info",method:"POST"},!1);if((n==null?void 0:n.code)===1&&n.data)return o.index.setStorageSync("userData",n.data),!0;if((n==null?void 0:n.code)!==-1)return!0}catch{return!0}a()}const e=await c();return d(e)}async function f(){return i||(i=l().then(e=>!!e).catch(()=>!1).finally(()=>{i=null}),i)}return{ensureLoggedIn:f}}exports.useGameAuth=g;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/tongji/endless-game/composables/useGameAuth.js.map
@@ -1,240 +1,2 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
const EMPTY_BOARD = {
week_start: "",
week_end: "",
sex_label: "同行",
group_size: 7,
member_count: 0,
players: [],
me: { count: 0, rank: 1, best_score: 0, distance: 0, is_first: true },
invite_code: ""
};
const PENDING_SYNC_KEY = "tongji_endless_pending_sync_v1";
function createSessionKey() {
const random = Math.random().toString(36).slice(2, 12);
return `game_${Date.now().toString(36)}_${random}`;
}
function readPendingPayloads() {
try {
const stored = common_vendor.index.getStorageSync(PENDING_SYNC_KEY);
if (!Array.isArray(stored))
return [];
return stored.filter((item) => item && /^[A-Za-z0-9_-]{16,64}$/.test(String(item.session_key || "")) && Number(item.learned_count) >= 0).slice(-8);
} catch (_) {
return [];
}
}
function useGamePlatform(proxy, ensureLoggedIn) {
const connected = common_vendor.ref(false);
const loading = common_vendor.ref(false);
const syncStatus = common_vendor.ref("idle");
const leaderboard = common_vendor.ref({ ...EMPTY_BOARD });
const confirmedSessionLearned = common_vendor.ref(0);
let sessionKey = createSessionKey();
let syncTimer = null;
let syncing = false;
let queuedPayloads = readPendingPayloads();
let connectPromise = null;
function persistPendingPayloads() {
try {
common_vendor.index.setStorageSync(PENDING_SYNC_KEY, queuedPayloads.slice(-8));
} catch (_) {
}
}
async function api(request) {
if (!(proxy == null ? void 0 : proxy.apiUrl))
throw new Error("平台接口未初始化");
return proxy.apiUrl(request, false);
}
function applyLeaderboard(data, confirmedForSession = "") {
if (!data || !Array.isArray(data.players))
return;
const inactiveSessionResponse = confirmedForSession && confirmedForSession !== sessionKey;
if (!inactiveSessionResponse) {
leaderboard.value = {
...EMPTY_BOARD,
...data,
me: { ...EMPTY_BOARD.me, ...data.me || {} },
players: data.players
};
}
if (confirmedForSession === sessionKey && data.confirmed_session_learned != null) {
confirmedSessionLearned.value = Number(data.confirmed_session_learned) || 0;
}
connected.value = true;
syncStatus.value = "synced";
}
async function refreshLeaderboard() {
const res = await api({
url: "/api/tcm/gameWeeklyLeaderboard",
method: "GET"
});
if ((res == null ? void 0 : res.code) !== 1 || !res.data) {
throw new Error((res == null ? void 0 : res.msg) || "同行榜加载失败");
}
applyLeaderboard(res.data);
return res.data;
}
async function acceptShare(inviteCode) {
const code = String(inviteCode || "").trim().toUpperCase();
if (!code)
return;
try {
await api({
url: "/api/tcm/gameAcceptShare",
method: "POST",
data: { invite_code: code }
});
} catch (_) {
}
}
async function connect(inviteCode = "") {
if (connectPromise)
return connectPromise;
connectPromise = (async () => {
loading.value = true;
try {
const loggedIn = await ensureLoggedIn();
if (!loggedIn)
throw new Error("登录失败");
await acceptShare(inviteCode);
await refreshLeaderboard();
if (queuedPayloads.length)
flushProgress();
return true;
} catch (_) {
connected.value = false;
syncStatus.value = "offline";
return false;
} finally {
loading.value = false;
connectPromise = null;
}
})();
return connectPromise;
}
function beginSession() {
if (syncTimer)
clearTimeout(syncTimer);
sessionKey = createSessionKey();
confirmedSessionLearned.value = 0;
syncStatus.value = queuedPayloads.length ? "pending" : connected.value ? "synced" : "offline";
return sessionKey;
}
function queueProgress(learnedCount, score, ended = false) {
const nextPayload = {
session_key: sessionKey,
learned_count: Math.max(0, Number(learnedCount) || 0),
score: Math.max(0, Number(score) || 0),
ended: ended ? 1 : 0
};
const existingIndex = queuedPayloads.findIndex((item) => item.session_key === sessionKey);
if (existingIndex >= 0) {
const existing = queuedPayloads[existingIndex];
queuedPayloads[existingIndex] = {
...nextPayload,
learned_count: Math.max(existing.learned_count, nextPayload.learned_count),
score: Math.max(existing.score, nextPayload.score),
ended: Math.max(existing.ended, nextPayload.ended)
};
} else {
queuedPayloads.push(nextPayload);
}
persistPendingPayloads();
syncStatus.value = "pending";
if (syncTimer)
clearTimeout(syncTimer);
if (ended) {
flushProgress();
} else {
syncTimer = setTimeout(flushProgress, 1e3);
}
}
async function flushProgress() {
if (syncTimer)
clearTimeout(syncTimer);
syncTimer = null;
if (syncing || !queuedPayloads.length)
return;
const payload = queuedPayloads[0];
syncing = true;
syncStatus.value = "syncing";
try {
if (!connected.value) {
const loggedIn = await ensureLoggedIn();
if (!loggedIn)
throw new Error("未登录");
}
const res = await api({
url: "/api/tcm/gameSubmitProgress",
method: "POST",
data: payload
});
if ((res == null ? void 0 : res.code) !== 1 || !res.data) {
throw new Error((res == null ? void 0 : res.msg) || "成绩保存失败");
}
applyLeaderboard(res.data, payload.session_key);
queuedPayloads = queuedPayloads.filter((item) => item.session_key !== payload.session_key || Number(item.learned_count) > Number(payload.learned_count) || Number(item.score) > Number(payload.score) || Number(item.ended) > Number(payload.ended));
persistPendingPayloads();
} catch (_) {
connected.value = false;
syncStatus.value = "offline";
persistPendingPayloads();
} finally {
syncing = false;
if (queuedPayloads.length && connected.value) {
setTimeout(flushProgress, 80);
}
}
}
async function syncAndRefresh(learnedCount, score) {
queueProgress(learnedCount, score, false);
await flushProgress();
if (!connected.value) {
await connect();
if (queuedPayloads.length)
await flushProgress();
} else {
try {
await refreshLeaderboard();
} catch (_) {
}
}
}
async function recordShare() {
var _a;
try {
if (!connected.value && !await connect())
return;
const res = await api({ url: "/api/tcm/gameRecordShare", method: "POST" });
if ((res == null ? void 0 : res.code) === 1 && ((_a = res.data) == null ? void 0 : _a.invite_code)) {
leaderboard.value = { ...leaderboard.value, invite_code: res.data.invite_code };
}
} catch (_) {
}
}
function dispose() {
if (syncTimer)
clearTimeout(syncTimer);
syncTimer = null;
persistPendingPayloads();
}
return {
connected,
loading,
syncStatus,
leaderboard,
confirmedSessionLearned,
connect,
beginSession,
queueProgress,
flushProgress,
syncAndRefresh,
refreshLeaderboard,
recordShare,
dispose
};
}
exports.useGamePlatform = useGamePlatform;
"use strict";const l=require("../../../common/vendor.js"),N={week_start:"",week_end:"",sex_label:"同行",group_size:7,member_count:0,players:[],me:{count:0,rank:1,best_score:0,distance:0,is_first:!0},invite_code:""},x="tongji_endless_pending_sync_v1";function E(){const s=Math.random().toString(36).slice(2,12);return`game_${Date.now().toString(36)}_${s}`}function O(){try{const s=l.index.getStorageSync(x);return Array.isArray(s)?s.filter(u=>u&&/^[A-Za-z0-9_-]{16,64}$/.test(String(u.session_key||""))&&Number(u.learned_count)>=0).slice(-8):[]}catch{return[]}}function q(s,u){const i=l.ref(!1),v=l.ref(!1),o=l.ref("idle"),y=l.ref({...N}),w=l.ref(0);let d=E(),a=null,p=!1,t=O(),f=null;function g(){try{l.index.setStorageSync(x,t.slice(-8))}catch{}}async function h(e){if(!(s!=null&&s.apiUrl))throw new Error("平台接口未初始化");return s.apiUrl(e,!1)}function T(e,n=""){if(!e||!Array.isArray(e.players))return;n&&n!==d||(y.value={...N,...e,me:{...N.me,...e.me||{}},players:e.players}),n===d&&e.confirmed_session_learned!=null&&(w.value=Number(e.confirmed_session_learned)||0),i.value=!0,o.value="synced"}async function S(){const e=await h({url:"/api/tcm/gameWeeklyLeaderboard",method:"GET"});if((e==null?void 0:e.code)!==1||!e.data)throw new Error((e==null?void 0:e.msg)||"同行榜加载失败");return T(e.data),e.data}async function A(e){const n=String(e||"").trim().toUpperCase();if(n)try{await h({url:"/api/tcm/gameAcceptShare",method:"POST",data:{invite_code:n}})}catch{}}async function b(e=""){return f||(f=(async()=>{v.value=!0;try{if(!await u())throw new Error("登录失败");return await A(e),await S(),t.length&&c(),!0}catch{return i.value=!1,o.value="offline",!1}finally{v.value=!1,f=null}})(),f)}function M(){return a&&clearTimeout(a),d=E(),w.value=0,o.value=t.length?"pending":i.value?"synced":"offline",d}function k(e,n,r=!1){const m={session_key:d,learned_count:Math.max(0,Number(e)||0),score:Math.max(0,Number(n)||0),ended:r?1:0},P=t.findIndex(_=>_.session_key===d);if(P>=0){const _=t[P];t[P]={...m,learned_count:Math.max(_.learned_count,m.learned_count),score:Math.max(_.score,m.score),ended:Math.max(_.ended,m.ended)}}else t.push(m);g(),o.value="pending",a&&clearTimeout(a),r?c():a=setTimeout(c,1e3)}async function c(){if(a&&clearTimeout(a),a=null,p||!t.length)return;const e=t[0];p=!0,o.value="syncing";try{if(!i.value&&!await u())throw new Error("未登录");const n=await h({url:"/api/tcm/gameSubmitProgress",method:"POST",data:e});if((n==null?void 0:n.code)!==1||!n.data)throw new Error((n==null?void 0:n.msg)||"成绩保存失败");T(n.data,e.session_key),t=t.filter(r=>r.session_key!==e.session_key||Number(r.learned_count)>Number(e.learned_count)||Number(r.score)>Number(e.score)||Number(r.ended)>Number(e.ended)),g()}catch{i.value=!1,o.value="offline",g()}finally{p=!1,t.length&&i.value&&setTimeout(c,80)}}async function I(e,n){if(k(e,n,!1),await c(),!i.value)await b(),t.length&&await c();else try{await S()}catch{}}async function R(){var e;try{if(!i.value&&!await b())return;const n=await h({url:"/api/tcm/gameRecordShare",method:"POST"});(n==null?void 0:n.code)===1&&((e=n.data)!=null&&e.invite_code)&&(y.value={...y.value,invite_code:n.data.invite_code})}catch{}}function G(){a&&clearTimeout(a),a=null,g()}return{connected:i,loading:v,syncStatus:o,leaderboard:y,confirmedSessionLearned:w,connect:b,beginSession:M,queueProgress:k,flushProgress:c,syncAndRefresh:I,refreshLeaderboard:S,recordShare:R,dispose:G}}exports.useGamePlatform=q;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/tongji/endless-game/composables/useGamePlatform.js.map
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,141 +1,7 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
function joinApiUrl(base, path) {
const b = String(base || "").replace(/\/+$/, "");
const p = String(path || "").replace(/^\/+/, "");
return p ? `${b}/${p}` : b;
}
function appendQuery(url, data) {
if (!data || typeof data !== "object")
return url;
const keys = Object.keys(data);
if (!keys.length)
return url;
const qs = keys.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(data[k] ?? "")}`).join("&");
return url + (url.includes("?") ? "&" : "?") + qs;
}
function decodeChunkData(data) {
if (typeof data === "string")
return data;
if (!data)
return "";
if (typeof TextDecoder !== "undefined" && data instanceof ArrayBuffer) {
return new TextDecoder("utf-8").decode(new Uint8Array(data));
}
if (data instanceof ArrayBuffer) {
const bytes = new Uint8Array(data);
let str = "";
for (let i = 0; i < bytes.length; i++)
str += String.fromCharCode(bytes[i]);
try {
return decodeURIComponent(escape(str));
} catch (e) {
return str;
}
}
return "";
}
function consumeSseBuffer(buffer, onEvent) {
let rest = buffer;
let idx = rest.indexOf("\n\n");
while (idx !== -1) {
const block = rest.slice(0, idx);
rest = rest.slice(idx + 2);
let event = "message";
let dataLine = "";
block.split("\n").forEach((line) => {
if (line.startsWith("event:"))
event = line.slice(6).trim();
else if (line.startsWith("data:"))
dataLine += line.slice(5).trim();
});
if (dataLine) {
try {
onEvent(event, JSON.parse(dataLine));
} catch (e) {
onEvent(event, dataLine);
}
}
idx = rest.indexOf("\n\n");
}
return rest;
}
function parsePartialDietPlainText(text) {
const out = {};
if (!text)
return out;
const lineRe = /^(早餐|喝的|午餐|晚餐|提示|少碰)[::]\s*(.*)$/gm;
let match;
while ((match = lineRe.exec(text)) !== null) {
const key = { "早餐": "breakfast", "喝的": "drinks", "午餐": "lunch", "晚餐": "dinner", "提示": "tips", "少碰": "avoid" }[match[1]];
const val = (match[2] || "").trim();
if (key === "avoid") {
out.avoid = val.split(/[、,,;;\s]+/).map((s) => s.trim()).filter(Boolean);
} else {
out[key] = val;
}
}
const tail = text.match(/(?:^|\n)(早餐|喝的|午餐|晚餐|提示|少碰)[::]\s*([^\n]*)$/);
if (tail) {
const key = { "早餐": "breakfast", "喝的": "drinks", "午餐": "lunch", "晚餐": "dinner", "提示": "tips", "少碰": "avoid" }[tail[1]];
const val = (tail[2] || "").trim();
if (key === "avoid") {
if (val)
out.avoid = val.split(/[、,,;;\s]+/).map((s) => s.trim()).filter(Boolean);
} else {
out[key] = val;
}
}
return out;
}
function requestAiStream(opts) {
const {
baseUrl,
url,
method = "GET",
data = {},
onEvent,
fallback
} = opts;
return new Promise((resolve, reject) => {
const token = common_vendor.index.getStorageSync("token") || "";
let sseBuffer = "";
let requestUrl = joinApiUrl(baseUrl, url);
if (method === "GET") {
requestUrl = appendQuery(requestUrl, data);
}
const task = common_vendor.wx$1.request({
url: requestUrl,
method,
data: method === "POST" ? data : {},
enableChunked: true,
timeout: 6e4,
header: {
token,
"content-type": "application/x-www-form-urlencoded",
"Cache-Control": "no-cache"
},
success: (res) => {
if (res && res.data) {
sseBuffer += decodeChunkData(res.data);
sseBuffer = consumeSseBuffer(sseBuffer, onEvent);
}
resolve(res);
},
fail: (err) => reject(err)
});
if (task && typeof task.onChunkReceived === "function") {
task.onChunkReceived((res) => {
sseBuffer += decodeChunkData(res.data);
sseBuffer = consumeSseBuffer(sseBuffer, onEvent);
});
} else if (typeof fallback === "function") {
fallback().then(resolve).catch(reject);
} else {
reject(new Error("当前环境不支持流式请求"));
}
});
}
exports.parsePartialDietPlainText = parsePartialDietPlainText;
exports.requestAiStream = requestAiStream;
"use strict";const p=require("../../common/vendor.js");function k(e,n){const r=String(e||"").replace(/\/+$/,""),t=String(n||"").replace(/^\/+/,"");return t?`${r}/${t}`:r}function v(e,n){if(!n||typeof n!="object")return e;const r=Object.keys(n);if(!r.length)return e;const t=r.map(c=>`${encodeURIComponent(c)}=${encodeURIComponent(n[c]??"")}`).join("&");return e+(e.includes("?")?"&":"?")+t}function m(e){if(typeof e=="string")return e;if(!e)return"";if(typeof TextDecoder<"u"&&e instanceof ArrayBuffer)return new TextDecoder("utf-8").decode(new Uint8Array(e));if(e instanceof ArrayBuffer){const n=new Uint8Array(e);let r="";for(let t=0;t<n.length;t++)r+=String.fromCharCode(n[t]);try{return decodeURIComponent(escape(r))}catch{return r}}return""}function h(e,n){let r=e,t=r.indexOf(`
`);for(;t!==-1;){const c=r.slice(0,t);r=r.slice(t+2);let o="message",i="";if(c.split(`
`).forEach(s=>{s.startsWith("event:")?o=s.slice(6).trim():s.startsWith("data:")&&(i+=s.slice(5).trim())}),i)try{n(o,JSON.parse(i))}catch{n(o,i)}t=r.indexOf(`
`)}return r}function w(e){const n={};if(!e)return n;const r=/^(早餐|喝的|午餐|晚餐|提示|少碰)[::]\s*(.*)$/gm;let t;for(;(t=r.exec(e))!==null;){const o={早餐:"breakfast",喝的:"drinks",午餐:"lunch",晚餐:"dinner",提示:"tips",少碰:"avoid"}[t[1]],i=(t[2]||"").trim();o==="avoid"?n.avoid=i.split(/[、,,;;\s]+/).map(s=>s.trim()).filter(Boolean):n[o]=i}const c=e.match(/(?:^|\n)(早餐|喝的|午餐|晚餐|提示|少碰)[::]\s*([^\n]*)$/);if(c){const o={早餐:"breakfast",喝的:"drinks",午餐:"lunch",晚餐:"dinner",提示:"tips",少碰:"avoid"}[c[1]],i=(c[2]||"").trim();o==="avoid"?i&&(n.avoid=i.split(/[、,,;;\s]+/).map(s=>s.trim()).filter(Boolean)):n[o]=i}return n}function C(e){const{baseUrl:n,url:r,method:t="GET",data:c={},onEvent:o,fallback:i}=e;return new Promise((s,l)=>{const y=p.index.getStorageSync("token")||"";let f="",u=k(n,r);t==="GET"&&(u=v(u,c));const d=p.wx$1.request({url:u,method:t,data:t==="POST"?c:{},enableChunked:!0,timeout:6e4,header:{token:y,"content-type":"application/x-www-form-urlencoded","Cache-Control":"no-cache"},success:a=>{a&&a.data&&(f+=m(a.data),f=h(f,o)),s(a)},fail:a=>l(a)});d&&typeof d.onChunkReceived=="function"?d.onChunkReceived(a=>{f+=m(a.data),f=h(f,o)}):typeof i=="function"?i().then(s).catch(l):l(new Error("当前环境不支持流式请求"))})}exports.parsePartialDietPlainText=w;exports.requestAiStream=C;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/utils/aiStreamRequest.js.map
@@ -1,48 +1,2 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
function utf8ToBytes(str) {
const encoded = encodeURIComponent(str);
const bytes = [];
for (let i = 0; i < encoded.length; i++) {
if (encoded.charCodeAt(i) === 37) {
bytes.push(parseInt(encoded.substring(i + 1, i + 3), 16));
i += 2;
} else {
bytes.push(encoded.charCodeAt(i));
}
}
return new Uint8Array(bytes);
}
function bytesToBase64(bytes) {
if (typeof common_vendor.index !== "undefined" && typeof common_vendor.index.arrayBufferToBase64 === "function") {
return common_vendor.index.arrayBufferToBase64(bytes.buffer);
}
if (typeof btoa !== "undefined") {
let binary = "";
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
let result = "";
for (let i = 0; i < bytes.length; i += 3) {
const a = bytes[i];
const b = i + 1 < bytes.length ? bytes[i + 1] : 0;
const c = i + 2 < bytes.length ? bytes[i + 2] : 0;
result += chars[a >> 2];
result += chars[(a & 3) << 4 | b >> 4];
result += i + 1 < bytes.length ? chars[(b & 15) << 2 | c >> 6] : "=";
result += i + 2 < bytes.length ? chars[c & 63] : "=";
}
return result;
}
function svgToDataUrl(svg) {
const normalized = String(svg || "").trim();
if (!normalized)
return "";
const base64 = bytesToBase64(utf8ToBytes(normalized));
return `data:image/svg+xml;base64,${base64}`;
}
exports.svgToDataUrl = svgToDataUrl;
"use strict";const a=require("../../common/vendor.js");function u(e){const t=encodeURIComponent(e),r=[];for(let n=0;n<t.length;n++)t.charCodeAt(n)===37?(r.push(parseInt(t.substring(n+1,n+3),16)),n+=2):r.push(t.charCodeAt(n));return new Uint8Array(r)}function c(e){if(typeof a.index<"u"&&typeof a.index.arrayBufferToBase64=="function")return a.index.arrayBufferToBase64(e.buffer);if(typeof btoa<"u"){let n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return btoa(n)}const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";let r="";for(let n=0;n<e.length;n+=3){const o=e[n],i=n+1<e.length?e[n+1]:0,f=n+2<e.length?e[n+2]:0;r+=t[o>>2],r+=t[(o&3)<<4|i>>4],r+=n+1<e.length?t[(i&15)<<2|f>>6]:"=",r+=n+2<e.length?t[f&63]:"="}return r}function s(e){const t=String(e||"").trim();return t?`data:image/svg+xml;base64,${c(u(t))}`:""}exports.svgToDataUrl=s;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/utils/svgDataUrl.js.map
@@ -1,60 +1,2 @@
"use strict";
const TREE_MAX_LEVEL = 9;
const TREE_XP_PER_LEVEL = 50;
const TREE_LEVELS = [
{ level: 0, name: "种子眠", emoji: "🫘", mood: "困困", desc: "稳糖种子在土里打盹" },
{ level: 1, name: "破土芽", emoji: "🌱", mood: "探头", desc: "探出第一抹新绿" },
{ level: 2, name: "展两叶", emoji: "🌿", mood: "好奇", desc: "两片嫩叶迎风展" },
{ level: 3, name: "小树苗", emoji: "🪴", mood: "精神", desc: "身子骨硬朗起来" },
{ level: 4, name: "青枝繁", emoji: "🌳", mood: "茁壮", desc: "枝叶渐密,元气足" },
{ level: 5, name: "拔节高", emoji: "🌲", mood: "挺拔", desc: "一节一节往上蹿" },
{ level: 6, name: "稳糖冠", emoji: "💚", mood: "沉稳", desc: "树冠成形,习惯成自然" },
{ level: 7, name: "初绽香", emoji: "🌸", mood: "开心", desc: "枝头冒出第一朵花" },
{ level: 8, name: "漫开花", emoji: "🌺", mood: "灿烂", desc: "花开满枝,越记越稳" },
{ level: 9, name: "圆满树", emoji: "🏆", mood: "荣耀", desc: "满级大树,习惯大师" }
];
const WHISPERS_BY_LEVEL = {
0: ["种子在睡觉,记一笔就醒啦。", "今天浇第一滴水,芽就要冒出来。"],
1: ["破土啦!再坚持几天就长高。", "小芽最喜欢规律的记录了。"],
2: ["两片叶子为你鼓掌。", "空腹餐后都记全,我会长得更快。"],
3: ["我已经是一棵小树啦。", "家人点赞的时候,我也会发光。"],
4: ["枝叶越来越密,您真棒。", "连续记录,我会开出更多叶子。"],
5: ["拔节中!习惯比完美更重要。", "再浇一点水,我就更高啦。"],
6: ["习惯成自然,树冠成形啦。", "您今天的坚持,小树都记得。"],
7: ["开花啦!闻到春天的味道了吗?", "稳糖花只开给坚持的人。"],
8: ["满树花香,您已是控糖达人。", "明天继续来,花儿会更艳。"],
9: ["满级大树陪您一路稳糖。", "圆满不是终点,习惯才是。"]
};
function calcTreeFromPoints(points) {
const pts = Math.max(0, Number(points) || 0);
const level = Math.min(TREE_MAX_LEVEL, Math.floor(pts / TREE_XP_PER_LEVEL));
const xpInLevel = level >= TREE_MAX_LEVEL ? TREE_XP_PER_LEVEL : pts % TREE_XP_PER_LEVEL;
const progress = level >= TREE_MAX_LEVEL ? 100 : Math.round(xpInLevel / TREE_XP_PER_LEVEL * 100);
const meta = TREE_LEVELS[level] || TREE_LEVELS[0];
const nextMeta = level < TREE_MAX_LEVEL ? TREE_LEVELS[level + 1] : null;
const pointsToNext = level >= TREE_MAX_LEVEL ? 0 : TREE_XP_PER_LEVEL - xpInLevel;
return {
level,
progress,
name: meta.name,
emoji: meta.emoji,
mood: meta.mood,
desc: meta.desc,
xpInLevel,
xpNeed: TREE_XP_PER_LEVEL,
pointsToNext,
nextName: (nextMeta == null ? void 0 : nextMeta.name) || "",
isMax: level >= TREE_MAX_LEVEL
};
}
function pickTreeWhisper(level) {
const lv = Math.min(TREE_MAX_LEVEL, Math.max(0, Number(level) || 0));
const list = WHISPERS_BY_LEVEL[lv] || WHISPERS_BY_LEVEL[0];
return list[Math.floor(Math.random() * list.length)];
}
exports.TREE_LEVELS = TREE_LEVELS;
exports.TREE_MAX_LEVEL = TREE_MAX_LEVEL;
exports.TREE_XP_PER_LEVEL = TREE_XP_PER_LEVEL;
exports.calcTreeFromPoints = calcTreeFromPoints;
exports.pickTreeWhisper = pickTreeWhisper;
"use strict";const _=[{level:0,name:"种子眠",emoji:"🫘",mood:"困困",desc:"稳糖种子在土里打盹"},{level:1,name:"破土芽",emoji:"🌱",mood:"探头",desc:"探出第一抹新绿"},{level:2,name:"展两叶",emoji:"🌿",mood:"好奇",desc:"两片嫩叶迎风展"},{level:3,name:"小树苗",emoji:"🪴",mood:"精神",desc:"身子骨硬朗起来"},{level:4,name:"青枝繁",emoji:"🌳",mood:"茁壮",desc:"枝叶渐密,元气足"},{level:5,name:"拔节高",emoji:"🌲",mood:"挺拔",desc:"一节一节往上蹿"},{level:6,name:"稳糖冠",emoji:"💚",mood:"沉稳",desc:"树冠成形,习惯成自然"},{level:7,name:"初绽香",emoji:"🌸",mood:"开心",desc:"枝头冒出第一朵花"},{level:8,name:"漫开花",emoji:"🌺",mood:"灿烂",desc:"花开满枝,越记越稳"},{level:9,name:"圆满树",emoji:"🏆",mood:"荣耀",desc:"满级大树,习惯大师"}],s={0:["种子在睡觉,记一笔就醒啦。","今天浇第一滴水,芽就要冒出来。"],1:["破土啦!再坚持几天就长高。","小芽最喜欢规律的记录了。"],2:["两片叶子为你鼓掌。","空腹餐后都记全,我会长得更快。"],3:["我已经是一棵小树啦。","家人点赞的时候,我也会发光。"],4:["枝叶越来越密,您真棒。","连续记录,我会开出更多叶子。"],5:["拔节中!习惯比完美更重要。","再浇一点水,我就更高啦。"],6:["习惯成自然,树冠成形啦。","您今天的坚持,小树都记得。"],7:["开花啦!闻到春天的味道了吗?","稳糖花只开给坚持的人。"],8:["满树花香,您已是控糖达人。","明天继续来,花儿会更艳。"],9:["满级大树陪您一路稳糖。","圆满不是终点,习惯才是。"]};function l(m){const e=Math.max(0,Number(m)||0),E=Math.min(9,Math.floor(e/50)),L=E>=9?50:e%50,c=E>=9?100:Math.round(L/50*100),o=_[E]||_[0],n=E<9?_[E+1]:null,t=E>=9?0:50-L;return{level:E,progress:c,name:o.name,emoji:o.emoji,mood:o.mood,desc:o.desc,xpInLevel:L,xpNeed:50,pointsToNext:t,nextName:(n==null?void 0:n.name)||"",isMax:E>=9}}function R(m){const e=Math.min(9,Math.max(0,Number(m)||0)),E=s[e]||s[0];return E[Math.floor(Math.random()*E.length)]}exports.TREE_LEVELS=_;exports.TREE_MAX_LEVEL=9;exports.TREE_XP_PER_LEVEL=50;exports.calcTreeFromPoints=l;exports.pickTreeWhisper=R;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/utils/treeLevels.js.map
@@ -1,68 +1,2 @@
"use strict";
const tongji_utils_treeLevels = require("./treeLevels.js");
const TREE_SPECIES_LIST = [
{
id: "classic",
name: "稳糖灵树",
tagline: "经典路线,从种子到圆满",
stages: tongji_utils_treeLevels.TREE_LEVELS.map((l) => l.emoji)
},
{
id: "bonsai",
name: "雅韵盆景",
tagline: "小巧精致,书桌旁的温柔陪伴",
stages: ["🫘", "🌱", "🪴", "🎋", "🪴", "🌳", "🎍", "🌸", "🏵️", "🏆"]
},
{
id: "pine",
name: "苍劲青松",
tagline: "挺拔向上,越记越稳",
stages: ["🫘", "🌱", "🌿", "🌲", "🌲", "🌲", "⛰️", "🌲", "🏔️", "🏆"]
},
{
id: "sakura",
name: "樱花小树",
tagline: "坚持打卡,枝头渐开",
stages: ["🫘", "🌱", "🌿", "🌳", "🌸", "🌸", "🌸", "🌸", "🌺", "🏆"]
},
{
id: "ginkgo",
name: "金秋银杏",
tagline: "叶色渐变,见证每一天",
stages: ["🫘", "🌱", "🍃", "🌳", "🍂", "🍂", "🌳", "🍁", "🌟", "🏆"]
}
];
const DAILY_MAX_TASK_POINTS = 40;
function getTreeSpecies(id) {
return TREE_SPECIES_LIST.find((s) => s.id === id) || TREE_SPECIES_LIST[0];
}
function speciesEmojiAtLevel(speciesId, level) {
const sp = getTreeSpecies(speciesId);
const lv = Math.min(tongji_utils_treeLevels.TREE_MAX_LEVEL, Math.max(0, Number(level) || 0));
return sp.stages[lv] || sp.stages[0] || "🌱";
}
function speciesGrowthRoadmap(speciesId) {
const sp = getTreeSpecies(speciesId);
return tongji_utils_treeLevels.TREE_LEVELS.map((meta, i) => {
const xpTotal = i * tongji_utils_treeLevels.TREE_XP_PER_LEVEL;
const daysHint = i === 0 ? 0 : Math.max(1, Math.ceil(xpTotal / DAILY_MAX_TASK_POINTS));
return {
level: i,
name: meta.name,
emoji: sp.stages[i] || meta.emoji,
desc: meta.desc,
xpTotal,
daysHint
};
});
}
function estimateDaysToMaxLevel() {
const totalXp = tongji_utils_treeLevels.TREE_MAX_LEVEL * tongji_utils_treeLevels.TREE_XP_PER_LEVEL;
return Math.max(1, Math.ceil(totalXp / DAILY_MAX_TASK_POINTS));
}
exports.TREE_SPECIES_LIST = TREE_SPECIES_LIST;
exports.estimateDaysToMaxLevel = estimateDaysToMaxLevel;
exports.getTreeSpecies = getTreeSpecies;
exports.speciesEmojiAtLevel = speciesEmojiAtLevel;
exports.speciesGrowthRoadmap = speciesGrowthRoadmap;
"use strict";const a=require("./treeLevels.js"),i=[{id:"classic",name:"稳糖灵树",tagline:"经典路线,从种子到圆满",stages:a.TREE_LEVELS.map(e=>e.emoji)},{id:"bonsai",name:"雅韵盆景",tagline:"小巧精致,书桌旁的温柔陪伴",stages:["🫘","🌱","🪴","🎋","🪴","🌳","🎍","🌸","🏵️","🏆"]},{id:"pine",name:"苍劲青松",tagline:"挺拔向上,越记越稳",stages:["🫘","🌱","🌿","🌲","🌲","🌲","⛰️","🌲","🏔️","🏆"]},{id:"sakura",name:"樱花小树",tagline:"坚持打卡,枝头渐开",stages:["🫘","🌱","🌿","🌳","🌸","🌸","🌸","🌸","🌺","🏆"]},{id:"ginkgo",name:"金秋银杏",tagline:"叶色渐变,见证每一天",stages:["🫘","🌱","🍃","🌳","🍂","🍂","🌳","🍁","🌟","🏆"]}],c=40;function E(e){return i.find(n=>n.id===e)||i[0]}function _(e,n){const t=E(e),s=Math.min(a.TREE_MAX_LEVEL,Math.max(0,Number(n)||0));return t.stages[s]||t.stages[0]||"🌱"}function r(e){const n=E(e);return a.TREE_LEVELS.map((t,s)=>{const o=s*a.TREE_XP_PER_LEVEL,m=s===0?0:Math.max(1,Math.ceil(o/c));return{level:s,name:t.name,emoji:n.stages[s]||t.emoji,desc:t.desc,xpTotal:o,daysHint:m}})}function L(){const e=a.TREE_MAX_LEVEL*a.TREE_XP_PER_LEVEL;return Math.max(1,Math.ceil(e/c))}exports.TREE_SPECIES_LIST=i;exports.estimateDaysToMaxLevel=L;exports.getTreeSpecies=E;exports.speciesEmojiAtLevel=_;exports.speciesGrowthRoadmap=r;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/utils/treeSpecies.js.map
@@ -1,310 +1,2 @@
"use strict";
const CN_DIGIT = {
零: 0,
"〇": 0,
一: 1,
壹: 1,
幺: 1,
二: 2,
贰: 2,
两: 2,
三: 3,
叁: 3,
四: 4,
肆: 4,
五: 5,
伍: 5,
六: 6,
陆: 6,
七: 7,
柒: 7,
八: 8,
捌: 8,
九: 9,
玖: 9
};
const CN_UNIT = { 十: 10, 拾: 10, 百: 100, 佰: 100, 千: 1e3, 仟: 1e3, 万: 1e4, 亿: 1e8 };
function cnIntToNumber(s) {
let total = 0;
let section = 0;
let number = 0;
let hadUnit = false;
let lastUnit = 0;
let sawZeroAfterUnit = false;
for (const ch of s) {
if (CN_DIGIT[ch] !== void 0) {
number = CN_DIGIT[ch];
if (number === 0)
sawZeroAfterUnit = true;
} else if (CN_UNIT[ch] !== void 0) {
hadUnit = true;
const unit = CN_UNIT[ch];
lastUnit = unit;
sawZeroAfterUnit = false;
if (unit >= 1e4) {
section = (section + number) * unit;
total += section;
section = 0;
} else {
if (number === 0)
number = 1;
section += number * unit;
}
number = 0;
}
}
if (!hadUnit && s.length > 1) {
let joined = "";
for (const ch of s) {
if (CN_DIGIT[ch] !== void 0)
joined += CN_DIGIT[ch];
}
if (joined)
return Number(joined);
}
if (number > 0 && lastUnit >= 100 && !sawZeroAfterUnit) {
number = number * (lastUnit / 10);
}
return total + section + number;
}
function cnSeqToNumber(seq) {
if (seq.includes("点")) {
const parts = seq.split("点");
const intPart = parts[0];
const decPart = parts.slice(1).join("");
const intVal = intPart ? cnIntToNumber(intPart) : 0;
let decStr = "";
for (const ch of decPart) {
if (CN_DIGIT[ch] !== void 0)
decStr += CN_DIGIT[ch];
}
if (!decStr)
return intVal;
return Number(`${intVal}.${decStr}`);
}
return cnIntToNumber(seq);
}
function hasCnDigit(seq) {
for (const ch of seq) {
if (CN_DIGIT[ch] !== void 0 || CN_UNIT[ch] !== void 0)
return true;
}
return false;
}
function normalizeNumbers(text) {
const raw = String(text || "");
return raw.replace(/[零〇一壹幺二贰两三叁四肆五伍六陆七柒八捌九玖十拾百佰千仟万亿点]+/g, (m) => {
if (!hasCnDigit(m))
return m;
const n = cnSeqToNumber(m);
return Number.isFinite(n) ? String(n) : m;
});
}
function numAfter(text, keys) {
for (const k of keys) {
const i = text.indexOf(k);
if (i >= 0) {
const rest = text.slice(i + k.length);
const m = rest.match(/-?\d+(?:\.\d+)?/);
if (m)
return m[0];
}
}
return "";
}
function textAfter(text, keys, stopKeys = []) {
for (const k of keys) {
const i = text.indexOf(k);
if (i >= 0) {
let rest = text.slice(i + k.length);
rest = rest.replace(/^[是为吃了喝了吃的喝的有打了用了::,,、。\s]+/, "");
let end = rest.length;
const mStop = rest.match(/[,,。.;;!!??\n]/);
if (mStop && mStop.index < end)
end = mStop.index;
for (const sk of stopKeys) {
const si = rest.indexOf(sk);
if (si >= 0 && si < end)
end = si;
}
const seg = rest.slice(0, end).trim();
if (seg)
return seg;
}
}
return "";
}
function parseGlucose(raw) {
const t = normalizeNumbers(raw);
const result = {};
const fasting = numAfter(t, ["空腹"]);
const post = numAfter(t, ["餐后", "饭后"]);
const other = numAfter(t, ["其他", "随机", "睡前", "凌晨", "夜间", "晚上"]);
if (fasting)
result.fasting_blood_sugar = fasting;
if (post)
result.postprandial_blood_sugar = post;
if (other)
result.other_blood_sugar = other;
if (!fasting && !post && !other) {
const nums = t.match(/\d+(?:\.\d+)?/g);
if (nums && nums.length === 1)
result.other_blood_sugar = nums[0];
}
return result;
}
function parseBloodPressure(raw) {
const t = normalizeNumbers(raw);
const result = {};
let sys = numAfter(t, ["高压", "收缩压", "收缩"]);
let dia = numAfter(t, ["低压", "舒张压", "舒张"]);
if (!sys || !dia) {
const nums = (t.match(/\d{2,3}/g) || []).map(Number).filter((n) => n >= 30 && n <= 300);
if (!sys && !dia && nums.length >= 2) {
sys = String(nums[0]);
dia = String(nums[1]);
} else if (!sys && nums.length === 1 && nums[0] >= 90) {
sys = String(nums[0]);
}
}
if (sys && dia && Number(sys) < Number(dia)) {
const tmp = sys;
sys = dia;
dia = tmp;
}
if (sys)
result.systolic_pressure = sys;
if (dia)
result.diastolic_pressure = dia;
const insulin = textAfter(raw, ["胰岛素"], ["高压", "低压", "血压", "西药", "备注"]);
if (insulin)
result.insulin = insulin;
const western = textAfter(raw, ["西药", "降糖药", "口服药"], ["胰岛素", "高压", "低压", "血压", "备注"]);
if (western)
result.western_medicine = western;
return result;
}
const DIET_MARKERS = [
{ keys: ["早餐", "早饭", "早上", "早点", "早晨"], field: "breakfast_foods" },
{ keys: ["午餐", "午饭", "中午"], field: "lunch_foods" },
{ keys: ["晚餐", "晚饭", "晚上", "夜宵", "夜里"], field: "dinner_foods" }
];
function cleanFoodSeg(seg) {
return String(seg || "").replace(/^[是为吃了吃的喝了喝的有::,,、。\s]+/, "").replace(/[。.\s]+$/, "").trim();
}
function parseDiet(raw) {
const t = String(raw || "").trim();
const result = {};
const hits = [];
DIET_MARKERS.forEach((m) => {
for (const k of m.keys) {
const idx = t.indexOf(k);
if (idx >= 0) {
hits.push({ idx, field: m.field, klen: k.length });
break;
}
}
});
if (!hits.length) {
if (t)
result.note = t;
return result;
}
hits.sort((a, b) => a.idx - b.idx);
hits.forEach((h, i) => {
const start = h.idx + h.klen;
const end = i + 1 < hits.length ? hits[i + 1].idx : t.length;
const seg = cleanFoodSeg(t.slice(start, end));
if (seg && !result[h.field])
result[h.field] = seg;
});
const head = cleanFoodSeg(t.slice(0, hits[0].idx));
if (head)
result.note = head;
return result;
}
const EXERCISE_FILLERS = [
"今天",
"我",
"做了",
"做",
"进行了",
"进行",
"运动了",
"运动",
"锻炼了",
"锻炼",
"了",
"大概",
"左右",
"持续",
"差不多",
"一共",
"总共",
"的",
"走了",
"打了",
"跑了"
];
function parseExercise(raw) {
const t = normalizeNumbers(raw);
const result = {};
const durMatch = t.match(/(\d+(?:\.\d+)?)\s*(个小时|小时|钟头|时|分钟|分)/);
if (durMatch) {
const val = parseFloat(durMatch[1]);
const isHour = /个小时|小时|钟头|时/.test(durMatch[2]);
result.duration = String(Math.round(isHour ? val * 60 : val));
}
if (/高强度|剧烈|很累|大汗|气喘/.test(t))
result.intensity = 3;
else if (/中强度|中等强度|中等|有点累|微微出汗|微汗/.test(t))
result.intensity = 2;
else if (/低强度|轻松|轻微|溜达|缓慢/.test(t))
result.intensity = 1;
let type = t;
if (durMatch)
type = type.replace(durMatch[0], "");
type = type.replace(/高强度|中强度|中等强度|低强度|剧烈|很累|大汗|气喘|有点累|微微出汗|微汗|轻松|轻微|缓慢/g, "").replace(/\d+(?:\.\d+)?/g, "").replace(/[,,。.;;、\s]+/g, "");
EXERCISE_FILLERS.forEach((f) => {
type = type.split(f).join("");
});
type = type.trim();
if (type && type.length <= 20)
result.exercise_type = type;
return result;
}
const FIELD_LABELS = {
fasting_blood_sugar: "空腹",
postprandial_blood_sugar: "餐后",
other_blood_sugar: "其他血糖",
systolic_pressure: "高压",
diastolic_pressure: "低压",
western_medicine: "西药",
insulin: "胰岛素",
breakfast_foods: "早餐",
lunch_foods: "午餐",
dinner_foods: "晚餐",
note: "备注",
exercise_type: "运动",
duration: "时长",
intensity: "强度"
};
const INTENSITY_LABELS = { 1: "低强度", 2: "中强度", 3: "高强度" };
function summarizeParsed(parsed) {
const parts = [];
Object.keys(parsed).forEach((k) => {
const label = FIELD_LABELS[k] || k;
let val = parsed[k];
if (k === "intensity")
val = INTENSITY_LABELS[val] || val;
parts.push(`${label}${val}`);
});
return parts.join(" · ");
}
exports.normalizeNumbers = normalizeNumbers;
exports.parseBloodPressure = parseBloodPressure;
exports.parseDiet = parseDiet;
exports.parseExercise = parseExercise;
exports.parseGlucose = parseGlucose;
exports.summarizeParsed = summarizeParsed;
"use strict";const l={零:0,"〇":0,一:1,壹:1,幺:1,二:2,贰:2,两:2,三:3,叁:3,四:4,肆:4,五:5,伍:5,六:6,陆:6,七:7,柒:7,八:8,捌:8,九:9,玖:9},p={十:10,拾:10,百:100,佰:100,千:1e3,仟:1e3,万:1e4,亿:1e8};function h(r){let i=0,t=0,e=0,n=!1,s=0,o=!1;for(const c of r)if(l[c]!==void 0)e=l[c],e===0&&(o=!0);else if(p[c]!==void 0){n=!0;const f=p[c];s=f,o=!1,f>=1e4?(t=(t+e)*f,i+=t,t=0):(e===0&&(e=1),t+=e*f),e=0}if(!n&&r.length>1){let c="";for(const f of r)l[f]!==void 0&&(c+=l[f]);if(c)return Number(c)}return e>0&&s>=100&&!o&&(e=e*(s/10)),i+t+e}function b(r){if(r.includes("点")){const i=r.split("点"),t=i[0],e=i.slice(1).join(""),n=t?h(t):0;let s="";for(const o of e)l[o]!==void 0&&(s+=l[o]);return s?+`${n}.${s}`:n}return h(r)}function S(r){for(const i of r)if(l[i]!==void 0||p[i]!==void 0)return!0;return!1}function d(r){return String(r||"").replace(/[零〇一壹幺二贰两三叁四肆五伍六陆七柒八捌九玖十拾百佰千仟万亿点]+/g,t=>{if(!S(t))return t;const e=b(t);return Number.isFinite(e)?String(e):t})}function u(r,i){for(const t of i){const e=r.indexOf(t);if(e>=0){const s=r.slice(e+t.length).match(/-?\d+(?:\.\d+)?/);if(s)return s[0]}}return""}function _(r,i,t=[]){for(const e of i){const n=r.indexOf(e);if(n>=0){let s=r.slice(n+e.length);s=s.replace(/^[是为吃了喝了吃的喝的有打了用了::,,、。\s]+/,"");let o=s.length;const c=s.match(/[,,。.;;!!??\n]/);c&&c.index<o&&(o=c.index);for(const a of t){const g=s.indexOf(a);g>=0&&g<o&&(o=g)}const f=s.slice(0,o).trim();if(f)return f}}return""}function y(r){const i=d(r),t={},e=u(i,["空腹"]),n=u(i,["餐后","饭后"]),s=u(i,["其他","随机","睡前","凌晨","夜间","晚上"]);if(e&&(t.fasting_blood_sugar=e),n&&(t.postprandial_blood_sugar=n),s&&(t.other_blood_sugar=s),!e&&!n&&!s){const o=i.match(/\d+(?:\.\d+)?/g);o&&o.length===1&&(t.other_blood_sugar=o[0])}return t}function E(r){const i=d(r),t={};let e=u(i,["高压","收缩压","收缩"]),n=u(i,["低压","舒张压","舒张"]);if(!e||!n){const c=(i.match(/\d{2,3}/g)||[]).map(Number).filter(f=>f>=30&&f<=300);!e&&!n&&c.length>=2?(e=String(c[0]),n=String(c[1])):!e&&c.length===1&&c[0]>=90&&(e=String(c[0]))}if(e&&n&&Number(e)<Number(n)){const c=e;e=n,n=c}e&&(t.systolic_pressure=e),n&&(t.diastolic_pressure=n);const s=_(r,["胰岛素"],["高压","低压","血压","西药","备注"]);s&&(t.insulin=s);const o=_(r,["西药","降糖药","口服药"],["胰岛素","高压","低压","血压","备注"]);return o&&(t.western_medicine=o),t}const x=[{keys:["早餐","早饭","早上","早点","早晨"],field:"breakfast_foods"},{keys:["午餐","午饭","中午"],field:"lunch_foods"},{keys:["晚餐","晚饭","晚上","夜宵","夜里"],field:"dinner_foods"}];function m(r){return String(r||"").replace(/^[是为吃了吃的喝了喝的有::,,、。\s]+/,"").replace(/[。.\s]+$/,"").trim()}function N(r){const i=String(r||"").trim(),t={},e=[];if(x.forEach(s=>{for(const o of s.keys){const c=i.indexOf(o);if(c>=0){e.push({idx:c,field:s.field,klen:o.length});break}}}),!e.length)return i&&(t.note=i),t;e.sort((s,o)=>s.idx-o.idx),e.forEach((s,o)=>{const c=s.idx+s.klen,f=o+1<e.length?e[o+1].idx:i.length,a=m(i.slice(c,f));a&&!t[s.field]&&(t[s.field]=a)});const n=m(i.slice(0,e[0].idx));return n&&(t.note=n),t}const k=["今天","我","做了","做","进行了","进行","运动了","运动","锻炼了","锻炼","了","大概","左右","持续","差不多","一共","总共","的","走了","打了","跑了"];function I(r){const i=d(r),t={},e=i.match(/(\d+(?:\.\d+)?)\s*(个小时|小时|钟头|时|分钟|分)/);if(e){const s=parseFloat(e[1]),o=/个小时|小时|钟头|时/.test(e[2]);t.duration=String(Math.round(o?s*60:s))}/高强度|剧烈|很累|大汗|气喘/.test(i)?t.intensity=3:/中强度|中等强度|中等|有点累|微微出汗|微汗/.test(i)?t.intensity=2:/低强度|轻松|轻微|溜达|缓慢/.test(i)&&(t.intensity=1);let n=i;return e&&(n=n.replace(e[0],"")),n=n.replace(/高强度|中强度|中等强度|低强度|剧烈|很累|大汗|气喘|有点累|微微出汗|微汗|轻松|轻微|缓慢/g,"").replace(/\d+(?:\.\d+)?/g,"").replace(/[,,。.;;、\s]+/g,""),k.forEach(s=>{n=n.split(s).join("")}),n=n.trim(),n&&n.length<=20&&(t.exercise_type=n),t}const L={fasting_blood_sugar:"空腹",postprandial_blood_sugar:"餐后",other_blood_sugar:"其他血糖",systolic_pressure:"高压",diastolic_pressure:"低压",western_medicine:"西药",insulin:"胰岛素",breakfast_foods:"早餐",lunch_foods:"午餐",dinner_foods:"晚餐",note:"备注",exercise_type:"运动",duration:"时长",intensity:"强度"},T={1:"低强度",2:"中强度",3:"高强度"};function A(r){const i=[];return Object.keys(r).forEach(t=>{const e=L[t]||t;let n=r[t];t==="intensity"&&(n=T[n]||n),i.push(`${e}${n}`)}),i.join(" · ")}exports.normalizeNumbers=d;exports.parseBloodPressure=E;exports.parseDiet=N;exports.parseExercise=I;exports.parseGlucose=y;exports.summarizeParsed=A;
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/utils/voiceParse.js.map