chore: 首次纳入版本控制(审查前基线,v1.2.0)

This commit is contained in:
errortopic
2026-11-18 20:13:37 +08:00
commit f7b28e1740
441 changed files with 31220 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
const api = require("../../utils/api");
const CHANNELS = [
{ k: "three_lines", name: "三句话", tip: "这题错在… 关键是… 下次遇到先…" },
{ k: "ai_voice", name: "讲给 AI 听", tip: "假装我是你同桌,我没听懂" },
{ k: "steps", name: "写步骤", tip: "一步一步写下来" },
{ k: "find_error", name: "找错", tip: "别人这么做错了,你挑出来" },
{ k: "make_question", name: "出题", tip: "自己出一道同类型的" },
];
// 换行用字符码拼:WXML 的属性值里写不了 \n(会被编译器当成非法转义)。
const NL = String.fromCharCode(10);
const PLACEHOLDER = {
three_lines: "这题错在…" + NL + "关键是…" + NL + "下次遇到先…",
ai_voice: "假装我是你同桌:你为什么要先算这一步?",
steps: "第一步…" + NL + "第二步…" + NL + "所以我最后得出的答案是…",
find_error: "先说他在哪一步错了,再说你会怎么改",
make_question: "出一道同类型的题,写上答案和最关键的那一步",
};
Page({
data: {
mid: "",
item: null,
channels: CHANNELS,
channel: "three_lines",
ph: PLACEHOLDER.three_lines,
text: "",
submitting: false,
result: null,
loading: true,
},
onLoad(query) {
if (!api.requireChild()) return;
this.setData({ mid: query.mid || "" });
this.load();
},
load() {
const child = getApp().globalData.child;
api
.get("/api/mistakes?child_id=" + child.id)
.then((d) => {
const item = (d.items || []).find((m) => m.id === this.data.mid) || null;
this.setData({ item, loading: false });
})
.catch((e) => {
api.toastError(e);
this.setData({ loading: false });
});
},
pickChannel(e) {
const k = e.currentTarget.dataset.k;
this.setData({ channel: k, ph: PLACEHOLDER[k] || "", result: null });
},
onInput(e) {
this.setData({ text: e.detail.value });
},
onSubmit() {
const text = (this.data.text || "").trim();
if (text.length < 8) {
wx.showToast({ title: "太短了,多说两句", icon: "none" });
return;
}
if (this.data.submitting) return;
this.setData({ submitting: true });
api
.post("/api/mistakes/" + this.data.mid + "/explain", {
child_id: getApp().globalData.child.id,
channel: this.data.channel,
text,
})
.then((r) => this.setData({ result: r, submitting: false }))
.catch((e) => {
api.toastError(e);
this.setData({ submitting: false });
});
},
onBack() {
wx.reLaunch({ url: "/pages/home/home" });
},
onRetry() {
this.setData({ result: null, text: "" });
},
});
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "讲一遍"
}
+47
View File
@@ -0,0 +1,47 @@
<view class="wrap">
<view class="card" wx:if="{{item}}">
<view class="card-title">这道题</view>
<view class="stem">{{item.stem}}</view>
<view class="muted">连对两次了。讲清楚这一遍,它就从队列里毕业。</view>
</view>
<view class="pick">
<view
class="chip {{channel === item.k ? 'on' : ''}}"
wx:for="{{channels}}"
wx:key="k"
data-k="{{item.k}}"
bindtap="pickChannel"
>{{item.name}}</view>
</view>
<view class="tip" wx:for="{{channels}}" wx:key="k" wx:if="{{item.k === channel}}">{{item.tip}}</view>
<view class="box">
<textarea
class="ta"
placeholder="{{ph}}"
value="{{text}}"
bindinput="onInput"
maxlength="300"
auto-height
/>
<view class="count">{{text.length}} / 300</view>
</view>
<button class="btn" bindtap="onSubmit" disabled="{{submitting}}">
{{submitting ? "判中…" : "说完了"}}
</button>
<view class="result" wx:if="{{result}}">
<view class="rh {{result.passed ? 'ok' : 'no'}}">{{result.passed ? "通过,毕业" : "还差一点"}}</view>
<view class="rd" wx:if="{{result.missing}}">缺的是:{{result.missing}}</view>
<view class="rd" wx:if="{{result.detail}}">{{result.detail}}</view>
<view class="rs">现在状态:<text class="tag {{result.status}}">{{result.status_zh}}</text></view>
<button class="btn" style="margin-top:16px" bindtap="{{result.passed ? 'onBack' : 'onRetry'}}">
{{result.passed ? "回今天" : "再说一遍"}}
</button>
</view>
<view class="foot">7 天内可以讲 3 次,讲不过会回到队列,明天再做一次。</view>
</view>
+23
View File
@@ -0,0 +1,23 @@
.stem { font-size: 17px; font-weight: 700; line-height: 1.6; margin-bottom: 6px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.chip {
padding: 7px 13px; border-radius: 999px; background: #fff;
border: 1px solid var(--line); font-size: 13px; color: #5f5852;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tip { font-size: 12px; color: var(--ochre); margin-bottom: 10px; }
.box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 6px; margin-bottom: 16px; }
.ta { width: 100%; min-height: 110px; font-size: 15px; line-height: 1.7; }
.count { text-align: right; font-size: 11px; color: #b9b1a9; padding-bottom: 6px; }
.result { margin-top: 20px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.rh { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.rh.ok { color: var(--bamboo); }
.rh.no { color: var(--brand); }
.rd { font-size: 13px; color: #4a4440; line-height: 1.7; }
.rs { margin-top: 8px; font-size: 13px; color: var(--muted); }
.foot { margin-top: 20px; text-align: center; font-size: 11px; color: #b9b1a9; line-height: 1.6; }
+7
View File
@@ -0,0 +1,7 @@
Page({
data: { url: "" },
onLoad(query) {
this.setData({ url: decodeURIComponent(query.url || "") });
},
});
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "周日那张纸"
}
+5
View File
@@ -0,0 +1,5 @@
<web-view src="{{url}}" wx:if="{{url}}" />
<view class="wrap" wx:else>
<view class="empty">这一页需要先用小程序打开一次周报</view>
<view class="note">web-view 只能加载在小程序后台配置过的业务域名;开发阶段请用「设置 → 项目设置 → 不校验合法域名」。</view>
</view>
+1
View File
@@ -0,0 +1 @@
.note { margin-top: 14px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 11px; color: #9a938c; line-height: 1.7; }
+112
View File
@@ -0,0 +1,112 @@
const api = require("../../utils/api");
Page({
data: {
loading: true,
items: [],
index: 0,
item: null,
total: 0,
answer: "",
submitting: false,
result: null,
},
onLoad(query) {
if (!api.requireChild()) return;
this.setData({ index: Number(query.i || 0) });
this.load();
},
load() {
const child = getApp().globalData.child;
api
.get("/api/today?child_id=" + child.id)
.then((d) => {
const items = d.items || [];
const index = Math.min(this.data.index, Math.max(items.length - 1, 0));
this.setData({
items,
index,
total: items.length,
item: items[index] || null,
loading: false,
answer: "",
result: null,
});
})
.catch((e) => {
api.toastError(e);
this.setData({ loading: false });
});
},
onInput(e) {
this.setData({ answer: e.detail.value });
},
onSubmit() {
const { item, answer, submitting } = this.data;
if (!item || submitting) return;
if (!(answer || "").trim()) {
wx.showToast({ title: "先写个答案", icon: "none" });
return;
}
this.setData({ submitting: true });
api
.post("/api/mistakes/" + item.id + "/attempt", {
child_id: getApp().globalData.child.id,
answer: answer.trim(),
})
.then((r) => {
this.setData({ result: r, submitting: false });
})
.catch((e) => {
api.toastError(e);
this.setData({ submitting: false });
});
},
onNext() {
const next = this.data.index + 1;
if (next >= this.data.total) {
wx.showModal({
title: "今天的 5 道做完了",
content: "不再追加。明天见。",
showCancel: false,
success: () => wx.reLaunch({ url: "/pages/home/home" }),
});
return;
}
const items = this.data.items;
this.setData({
index: next,
item: items[next],
answer: "",
result: null,
});
},
/** 没标准答案的题(拍照切出来的应用题/语文题):孩子自己判。 */
onSelfJudge(e) {
const { item, submitting } = this.data;
if (!item || submitting) return;
const correct = e.currentTarget.dataset.ok === "1";
this.setData({ submitting: true });
api
.post("/api/mistakes/" + item.id + "/self-judge", {
child_id: getApp().globalData.child.id,
correct,
})
.then((r) => this.setData({ result: r, submitting: false }))
.catch((err) => {
api.toastError(err);
this.setData({ submitting: false });
});
},
onExplainNow() {
const mid = this.data.result && this.data.result.mistake_id;
wx.redirectTo({ url: "/pages/explain/explain?mid=" + (mid || this.data.item.id) });
},
});
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "做题"
}
+53
View File
@@ -0,0 +1,53 @@
<view class="wrap" wx:if="{{item}}">
<view class="bar">
<text class="prog">第 {{index + 1}} / {{total}} 道</text>
<text class="tag {{item.status}}">{{item.status_zh}}</text>
</view>
<view class="stem {{item.subject === 'chinese' ? 'chn' : 'math'}}">
<view class="sub">{{item.subject === 'chinese' ? '语文' : '数学'}}</view>
<view class="text">{{item.stem}}</view>
</view>
<block wx:if="{{item.judge_type !== 'manual'}}">
<view class="answer">
<input class="ipt" type="text" placeholder="把答案写这儿" value="{{answer}}" bindinput="onInput" confirm-type="done" />
</view>
<button class="btn" bindtap="onSubmit" disabled="{{submitting}}">
{{submitting ? "判分中…" : "交卷"}}
</button>
</block>
<view class="selfjudge" wx:else>
<view class="sj-t">这题机器没有标准答案,你说了算</view>
<view class="sj-row">
<button class="btn plain" data-ok="1" bindtap="onSelfJudge" disabled="{{submitting}}">我做对了</button>
<button class="btn plain" data-ok="0" bindtap="onSelfJudge" disabled="{{submitting}}">我做错了</button>
</view>
<view class="sj-n">自己判不算放水:复习时间照样按规则排。</view>
</view>
<view class="result" wx:if="{{result}}">
<view class="rh {{result.correct === true ? 'ok' : (result.correct === false ? 'no' : 'skip')}}">
{{result.correct === true ? "对了" : (result.correct === false ? "再想想" : "这次不判")}}
</view>
<view class="rd" wx:if="{{result.detail}}">{{result.detail}}</view>
<view class="rs">这道题现在是:<text class="tag {{result.status}}">{{result.status_zh}}</text></view>
<view class="hint" wx:if="{{result.status === 'careless'}}">
24 小时内做对 → 记成「粗心」,不进复习队列,只进「粗心小记」。
</view>
<view class="hint" wx:if="{{result.status === 'to_explain'}}">
连对两次了,但要讲一遍才算毕业。
</view>
<button class="btn" style="margin-top:16px" bindtap="onNext">
{{index + 1 >= total ? "今天到此为止" : "下一道"}}
</button>
<button class="btn plain" style="margin-top:10px" wx:if="{{result.status === 'to_explain'}}" bindtap="onExplainNow">
现在就讲一遍
</button>
</view>
<view class="foot">第 {{total}} 道做完就结束,不追加。</view>
</view>
<view class="empty" wx:else>今天没有要做的题了</view>
+32
View File
@@ -0,0 +1,32 @@
.bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.prog { font-size: 12px; color: var(--muted); }
.stem { border-radius: 16px; padding: 22px 18px; margin-bottom: 18px; border: 1px solid var(--line); }
.stem.math {
background: var(--paper-math) repeating-linear-gradient(0deg, rgba(169, 118, 26, 0.07) 0 1px, transparent 1px 13px);
}
.stem.chn {
background: var(--paper-chn) repeating-linear-gradient(0deg, rgba(47, 107, 87, 0.07) 0 1px, transparent 1px 14px);
}
.stem .sub { font-size: 11px; color: #9a938c; margin-bottom: 8px; letter-spacing: 1px; }
.stem .text { font-size: 24px; font-weight: 700; line-height: 1.5; word-break: break-all; }
.answer { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px; margin-bottom: 16px; }
.ipt { height: 48px; font-size: 18px; }
.result { margin-top: 22px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.rh { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.rh.ok { color: var(--bamboo); }
.rh.no { color: var(--brand); }
.rh.skip { color: var(--ochre); }
.rd { font-size: 13px; color: #4a4440; line-height: 1.7; }
.rs { margin-top: 8px; font-size: 13px; color: var(--muted); }
.hint { margin-top: 10px; padding: 9px 11px; background: var(--paper); border-radius: 10px; font-size: 11px; color: #7a6440; line-height: 1.6; }
.foot { margin-top: 22px; text-align: center; font-size: 11px; color: #b9b1a9; }
.selfjudge { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.sj-t { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.sj-row { display: flex; gap: 10px; }
.sj-row .btn { flex: 1; margin: 0; }
.sj-n { margin-top: 10px; font-size: 11px; color: var(--muted); }
+44
View File
@@ -0,0 +1,44 @@
const api = require("../../utils/api");
Page({
data: {
numbers: null,
weakest: [],
oneLine: "",
printUrl: "",
loading: true,
},
onShow() {
if (!api.requireChild()) return;
this.load();
},
load() {
const child = getApp().globalData.child;
api
.get("/api/report/weekly?child_id=" + child.id)
.then((d) => {
this.setData({
numbers: d.numbers,
weakest: d.weakest || [],
oneLine: d.one_line || "",
printUrl:
getApp().globalData.apiBase +
"/api/print/weekly?child_id=" +
child.id +
"&token=" +
encodeURIComponent(api.token()),
loading: false,
});
})
.catch((e) => {
api.toastError(e);
this.setData({ loading: false });
});
},
onPrint() {
wx.navigateTo({ url: "/pages/print/print?url=" + encodeURIComponent(this.data.printUrl) });
},
});
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "这周"
}
+41
View File
@@ -0,0 +1,41 @@
<view class="wrap">
<block wx:if="{{numbers}}">
<view class="card">
<view class="card-title">这周</view>
<view class="grid">
<view class="g">
<view class="gv">{{numbers.graduated_this_week}}</view>
<view class="gl">毕业</view>
</view>
<view class="g">
<view class="gv">{{numbers.new_this_week}}</view>
<view class="gl">新进</view>
</view>
<view class="g">
<view class="gv">{{numbers.review_days}}</view>
<view class="gl">复习天数</view>
</view>
<view class="g">
<view class="gv">{{numbers.kill_rate}}%</view>
<view class="gl">消灭率</view>
</view>
</view>
<view class="one">{{oneLine}}</view>
</view>
<view class="card" wx:if="{{weakest.length}}">
<view class="card-title">最弱的三个知识点</view>
<view class="li" wx:for="{{weakest}}" wx:key="code">
<text class="l">{{item.zh}}</text>
<text class="r">{{item.count}} 道</text>
</view>
</view>
<button class="btn" bindtap="onPrint">打开周日那张纸</button>
<view class="muted" style="margin-top:10px;text-align:center">
纸上留了答题区,答案折叠在下面,底下是家长签字。
</view>
</block>
<view class="empty" wx:elif="{{!loading}}">这周还没有记录</view>
</view>
+8
View File
@@ -0,0 +1,8 @@
.grid { display: flex; margin: 6px 0 12px; }
.g { flex: 1; text-align: center; }
.gv { font-size: 24px; font-weight: 700; color: var(--brand); }
.gl { margin-top: 2px; font-size: 11px; color: var(--muted); }
.one {
padding: 11px 13px; background: var(--paper); border-radius: 10px;
font-size: 12px; color: #7a6440; line-height: 1.7;
}