日程行程条目端上同步:字段、列表卡「出发地→目的地」可导航 (#67)
同步服务端 #67 的新字段与三处改动: 数据层 - RawCalEvent / FbCalEvent 加 fromPlace/toPlace/fromLng/fromLat/toLng/toLat - FbParse 解析赋值;新增 numStr() 把 DECIMAL 可能给的 number 转成字符串 (`s()` 签名只收 string|null|undefined,坐标字段会报类型错) - FbCalStore.toModels、DemoData 的 8 条演示数据同步补字段 渲染 - FbDayEventPanel 列表卡片:在时间行**上面**加一行「出发地 → 目的地」, 只对两端都有值的条目画(普通日程 fromPlace/toPlace 都是空串,不画)。 目的地用日历本色 + 下划线,点击 fbOpenNavigation: 有坐标走 `lat,lng?地名`(同名地点不会搜错城市),没有就让 FbNav 地理编码。 不塞进时间行是因为那里已有「时刻 + 重复徽标 + 地点」,窄屏会挤爆。 - FbDayTimeline 全天块:一行文字「出发地 → 目的地」,替代原来的 place。 不给点击 —— 26vp 高的块切两个热区点不准,导航入口在详情卡。 图标与 ✓ 的改动在服务端(Trip::leadIcon / 删 ✓ ),端上只消费 title, 所以不需要额外处理。
This commit is contained in:
@@ -277,7 +277,14 @@ export class FbCalStore {
|
||||
allDay: r.num('all_day', 0) === 1,
|
||||
place: r.strOr('place', ''),
|
||||
note: r.strOr('note', ''),
|
||||
kind: r.strOr('kind', '')
|
||||
kind: r.strOr('kind', ''),
|
||||
/* #67:行程条目的「从哪到哪」(普通日程一律空串,界面按空串不画) */
|
||||
fromPlace: r.strOr('from_place', ''),
|
||||
toPlace: r.strOr('to_place', ''),
|
||||
fromLng: r.strOr('from_lng', ''),
|
||||
fromLat: r.strOr('from_lat', ''),
|
||||
toLng: r.strOr('to_lng', ''),
|
||||
toLat: r.strOr('to_lat', '')
|
||||
};
|
||||
out.push(e);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,14 @@ export function s(v: string | null | undefined): string {
|
||||
return v !== null && v !== undefined ? v : '';
|
||||
}
|
||||
|
||||
/** 把 `string | number | null | undefined` 统一成字符串(#67:坐标字段可能是 number) */
|
||||
function numStr(v: string | number | null | undefined): string {
|
||||
if (v === null || v === undefined) {
|
||||
return '';
|
||||
}
|
||||
return String(v);
|
||||
}
|
||||
|
||||
/** 安全转数字 */
|
||||
export function n(v: number | null | undefined): number {
|
||||
return v !== null && v !== undefined ? v : 0;
|
||||
@@ -111,6 +119,13 @@ interface RawCalEvent {
|
||||
date?: string; time?: string; end_time?: string; all_day?: boolean | number;
|
||||
kind?: string; ref_id?: number; location?: string; note?: string;
|
||||
repeat?: string; occ?: string;
|
||||
/* 🔴 #67(用户 2026-11-05):「如果行程里面有地址,也就是有出发地和目的地,
|
||||
应该像行程里显示的那样,把它显示在下面,这样一点就可以导航。」
|
||||
⇒ 服务端 `Calendar::window()` 的 trip 派生段现在会带出这六个字段。
|
||||
坐标单独带是因为导航要用:只给地名的话,同名地点会搜错城市。 */
|
||||
from_place?: string; to_place?: string;
|
||||
from_lng?: string | number; from_lat?: string | number;
|
||||
to_lng?: string | number; to_lat?: string | number;
|
||||
}
|
||||
|
||||
interface RawTrip {
|
||||
@@ -311,7 +326,16 @@ function parseCalRows(rows: RawCalEvent[]): FbCalEvent[] {
|
||||
allDay: b(r.all_day),
|
||||
place: s(r.location),
|
||||
note: s(r.note),
|
||||
kind: s(r.kind)
|
||||
kind: s(r.kind),
|
||||
/* #67:行程条目才有值,普通日程是空串 */
|
||||
/* ⚠️ 坐标字段服务端可能给 number(DECIMAL),`s()` 只收 string
|
||||
⇒ 统一走 numStr() 转成字符串,避免类型报错 */
|
||||
fromPlace: s(r.from_place),
|
||||
toPlace: s(r.to_place),
|
||||
fromLng: numStr(r.from_lng),
|
||||
fromLat: numStr(r.from_lat),
|
||||
toLng: numStr(r.to_lng),
|
||||
toLat: numStr(r.to_lat)
|
||||
};
|
||||
out.push(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user