新增人生轨迹模块代码

This commit is contained in:
2025-12-21 17:44:59 +08:00
parent f3c06ce6af
commit cfd12f01db
14 changed files with 1156 additions and 72 deletions
+32 -2
View File
@@ -68,16 +68,46 @@ export function PathView({ onSwitchToScript }) {
}
};
const handleDelete = () => {
const handleDelete = async () => {
if (window.confirm('确定要删除这个路径规划吗?')) {
Store.deletePath(currentPath.id);
// Sync to backend
try {
const allPaths = Store.get().paths;
const profileRes = await userApi.getCurrentUser();
if (profileRes.data) {
await userApi.updateUserProfile({
id: profileRes.data.id,
paths: JSON.stringify(allPaths)
});
}
} catch (err) {
console.error("Failed to sync path deletion to backend", err);
}
setIsEditing(false);
}
};
const handleSaveEdit = () => {
const handleSaveEdit = async () => {
if (editedPath) {
Store.updatePath(editedPath.id, { steps: editedPath.steps });
// Sync to backend
try {
const allPaths = Store.get().paths;
const profileRes = await userApi.getCurrentUser();
if (profileRes.data) {
await userApi.updateUserProfile({
id: profileRes.data.id,
paths: JSON.stringify(allPaths)
});
}
} catch (err) {
console.error("Failed to sync path update to backend", err);
}
setIsEditing(false);
}
};