Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions public/functions/api/user/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function onRequest(event) {

if (event.request.method === "POST") {
const body = await event.request.json();
const { trips, pins, latest_5 } = body;
const { trips, pins, latest_5, version } = body;

// Fetch existing to preserve other fields (like password, bindings)
const existingRaw = await DB.get(userKey);
Expand All @@ -50,7 +50,8 @@ export async function onRequest(event) {
...existing,
trips: trips || existing.trips || [],
pins: pins || existing.pins || [],
latest_5: latest_5 || existing.latest_5 || null // Store the pre-calculated card data
latest_5: latest_5 || existing.latest_5 || null, // Store the pre-calculated card data
version: version || existing.version || null
};

await DB.put(userKey, JSON.stringify(newData));
Expand Down
22 changes: 22 additions & 0 deletions public/readme/cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 用户指南与协议

欢迎使用 RailRound!这是一款为铁路爱好者设计的行程记录与可视化工具。

## 1. 服务条款
使用本服务即表示您同意以下条款:
- 请勿上传违法或侵权内容。
- 您的数据将安全存储,但建议定期导出备份。
- 我们尊重您的隐私,不会向第三方出售您的个人数据。

## 2. 隐私政策
我们收集的信息仅用于提供服务:
- 用户名与加密后的密码。
- 您主动记录的行程数据与图钉信息。
- 通过 GitHub 登录时的公开资料(头像、昵称)。

## 3. 使用指南
- **记录行程**: 在首页点击“记录新行程”,支持手动输入或自动规划。
- **地图模式**: 可视化查看您的足迹,支持上传 GeoJSON 地图文件。
- **GitHub 挂件**: 绑定 GitHub 账号后,可生成动态 SVG 卡片展示在您的个人主页。

[了解更多](https://github.com/s3xyseia/railround)
15 changes: 9 additions & 6 deletions src/RailRound.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { LoginModal } from './components/LoginModal';
import { api } from './services/api';
import { db } from './utils/db';

const CURRENT_VERSION = 0.30;
const MIN_SUPPORTED_VERSION = 0.0;

const GithubRegisterModal = ({ isOpen, onClose, regToken, onLoginSuccess }) => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
Expand Down Expand Up @@ -1458,7 +1461,7 @@ export default function RailRoundApp() {

// Sync back the merged result to cloud immediately
if (token) {
api.saveData(token, newTrips, newPins).catch(e => console.error("Merge sync failed", e));
api.saveData(token, newTrips, newPins, null, CURRENT_VERSION).catch(e => console.error("Merge sync failed", e));
}
}
}
Expand Down Expand Up @@ -2020,7 +2023,7 @@ export default function RailRoundApp() {
const linesUsed = new Set();
const companiesUsed = new Set();
trips.forEach(t => { (t.segments || []).forEach(s => { if(s.lineKey) { linesUsed.add(s.lineKey); const meta = railwayData[s.lineKey]?.meta; if(meta && meta.company) companiesUsed.add(meta.company); } }); });
const backupData = { meta: { version: 1, exportedAt: new Date().toISOString(), appName: "RailRound" }, dependencies: { lines: Array.from(linesUsed), companies: Array.from(companiesUsed) }, data: { trips: trips, pins: pins } };
const backupData = { meta: { version: CURRENT_VERSION, exportedAt: new Date().toISOString(), appName: "RailRound" }, dependencies: { lines: Array.from(linesUsed), companies: Array.from(companiesUsed) }, data: { trips: trips, pins: pins } };
const blob = new Blob([JSON.stringify(backupData, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a'); link.href = url; link.download = `railround_backup_${new Date().toISOString().slice(0,10)}.json`; document.body.appendChild(link); link.click(); document.body.removeChild(link);
Expand Down Expand Up @@ -2157,7 +2160,7 @@ export default function RailRoundApp() {
// Sync to Cloud
if (user) {
const latest5 = calculateLatestStats(finalTrips, segmentGeometries, railwayData, geoData);
api.saveData(user.token, finalTrips, pins, latest5).catch(e => alert('云端保存失败: ' + e.message));
api.saveData(user.token, finalTrips, pins, latest5, CURRENT_VERSION).catch(e => alert('云端保存失败: ' + e.message));
}

setIsTripEditing(false); setEditingTripId(null);
Expand All @@ -2175,7 +2178,7 @@ export default function RailRoundApp() {
setTrips(newTrips);
if (user) {
const latest5 = calculateLatestStats(newTrips, segmentGeometries, railwayData, geoData);
api.saveData(user.token, newTrips, pins, latest5).catch(e => alert('云端同步失败'));
api.saveData(user.token, newTrips, pins, latest5, CURRENT_VERSION).catch(e => alert('云端同步失败'));
}
}
};
Expand Down Expand Up @@ -2210,7 +2213,7 @@ export default function RailRoundApp() {
setPins(newPins);

if (user) {
api.saveData(user.token, trips, newPins).catch(e => console.error('Pin sync failed', e));
api.saveData(user.token, trips, newPins, null, CURRENT_VERSION).catch(e => console.error('Pin sync failed', e));
}

setEditingPin(null);
Expand All @@ -2223,7 +2226,7 @@ export default function RailRoundApp() {
if (editingPin?.id === id) setEditingPin(null);

if (user) {
api.saveData(user.token, trips, newPins).catch(e => console.error('Pin sync failed', e));
api.saveData(user.token, trips, newPins, null, CURRENT_VERSION).catch(e => console.error('Pin sync failed', e));
}
}
};
Expand Down
Loading