新增人生轨迹模块代码
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user