diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx
index 0015089..a9a6d2f 100644
--- a/src/pages/index/index.tsx
+++ b/src/pages/index/index.tsx
@@ -24,8 +24,6 @@ function mainPageCard(c: CardContent): JSX.Element {
);
}
-type DutyState = 'off' | '1' | '2' | '3';
-
class DutyData {
constructor() {
this.isInDuty = false;
@@ -37,9 +35,9 @@ class DutyData {
isInDuty: boolean;
inDutyCnt: number;
- currentDuty: DutyState;
- offDutyReason: string;
- dutyRecoverTime: string;
+ currentDuty: 'off' | '1' | '2' | '3';
+ offDutyReason: string; // from backend
+ dutyRecoverTime: string; // from backend
}
class ExpandItem extends Component {
@@ -77,22 +75,24 @@ class DutyInfo extends Component {
offDutyContent(): ReactNode {
const data = this.props.data;
+ const od = pt.get().mainPage.dutyCard.offDuty;
return (
- 当前未值班
- {data.offDutyReason}
- 恢复值班时间:{data.dutyRecoverTime}
+ {od.title}
+ {od.reason(data.offDutyReason)}
+ {od.recoverTime(data.dutyRecoverTime)}
);
}
inDutyContent(): ReactNode {
const data = this.props.data;
+ const id = pt.get().mainPage.dutyCard.inDuty;
return (
- 值班中
- 当前班次 {data.currentDuty}
- 当前{data.inDutyCnt}人在岗
+ {id.title}
+ {id.currentDutyText(data.currentDuty)}
+ {id.inDutyCnt(data.inDutyCnt)}
);
}
diff --git a/src/plain-text/MainPage.ts b/src/plain-text/MainPage.ts
index c907ec3..584b483 100644
--- a/src/plain-text/MainPage.ts
+++ b/src/plain-text/MainPage.ts
@@ -12,6 +12,19 @@ export interface MainPageText {
};
stepList: Array<{ title: string }>;
tipsList: Array<{ title: string }>;
+
+ dutyCard: {
+ offDuty: {
+ title: string;
+ reason: (s: string) => string;
+ recoverTime: (t: string) => string;
+ };
+ inDuty: {
+ title: string;
+ currentDutyText: (c: 'off' | '1' | '2' | '3') => string;
+ inDutyCnt: (n: number) => string;
+ };
+ };
}
export const mainPageZhCn: MainPageText = {
@@ -38,4 +51,27 @@ export const mainPageZhCn: MainPageText = {
{ title: '204也是实验室,请遵守实验室纪律,请勿饮食~' },
{ title: '我们是志愿服务,不收任何礼物哦~' },
],
+ dutyCard: {
+ offDuty: {
+ title: '未值班',
+ reason: s => '值班停止原因:' + s,
+ recoverTime: t => '恢复值班时间:' + t,
+ },
+ inDuty: {
+ title: '值班中',
+ currentDutyText: c => {
+ switch (c) {
+ case 'off':
+ return '当前未值班';
+ case '1':
+ return '第一班 13:30-16:00';
+ case '2':
+ return '第二班 16:00-18:00';
+ case '3':
+ return '第三班 18:00-20:30';
+ }
+ },
+ inDutyCnt: n => '当前值班人数:' + n,
+ },
+ },
};