Compare commits
2 Commits
603e81853d
...
fix/save-t
| Author | SHA1 | Date | |
|---|---|---|---|
| b07b97bf1e | |||
| 2ab192c3ba |
@@ -350,6 +350,7 @@ import { useUiStore } from '../stores/ui'
|
|||||||
import { useDiaryStore } from '../stores/diary'
|
import { useDiaryStore } from '../stores/diary'
|
||||||
import { api } from '../composables/useApi'
|
import { api } from '../composables/useApi'
|
||||||
import { oilEn, recipeNameEn } from '../composables/useOilTranslation'
|
import { oilEn, recipeNameEn } from '../composables/useOilTranslation'
|
||||||
|
import { showPrompt } from '../composables/useDialog'
|
||||||
// TagPicker replaced with inline tag editing
|
// TagPicker replaced with inline tag editing
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -576,16 +577,16 @@ async function saveToDiary() {
|
|||||||
ui.openLogin()
|
ui.openLogin()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const name = prompt('保存为我的配方,名称:', recipe.value.name)
|
const name = await showPrompt('保存为我的配方,名称:', recipe.value.name)
|
||||||
if (!name) return
|
if (!name) return
|
||||||
try {
|
try {
|
||||||
await api.post('/api/diary', {
|
await recipesStore.saveRecipe({
|
||||||
name,
|
name,
|
||||||
source_recipe_id: recipe.value._id || null,
|
|
||||||
ingredients: recipe.value.ingredients.map(i => ({ oil: i.oil, drops: i.drops })),
|
|
||||||
note: recipe.value.note || '',
|
note: recipe.value.note || '',
|
||||||
|
ingredients: recipe.value.ingredients.map(i => ({ oil_name: i.oil, drops: i.drops })),
|
||||||
|
tags: recipe.value.tags || [],
|
||||||
})
|
})
|
||||||
ui.showToast('已保存到「我的配方日记」')
|
ui.showToast('已保存到「我的配方」')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ui.showToast('保存失败: ' + (e?.message || '未知错误'))
|
ui.showToast('保存失败: ' + (e?.message || '未知错误'))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,11 +136,7 @@ function handleLogout() {
|
|||||||
auth.logout()
|
auth.logout()
|
||||||
ui.showToast('已退出登录')
|
ui.showToast('已退出登录')
|
||||||
emit('close')
|
emit('close')
|
||||||
if (router.currentRoute.value.meta.requiresAuth) {
|
window.location.reload()
|
||||||
router.push('/')
|
|
||||||
} else {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(loadNotifications)
|
onMounted(loadNotifications)
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ const routes = [
|
|||||||
path: '/manage',
|
path: '/manage',
|
||||||
name: 'RecipeManager',
|
name: 'RecipeManager',
|
||||||
component: () => import('../views/RecipeManager.vue'),
|
component: () => import('../views/RecipeManager.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/inventory',
|
path: '/inventory',
|
||||||
name: 'Inventory',
|
name: 'Inventory',
|
||||||
component: () => import('../views/Inventory.vue'),
|
component: () => import('../views/Inventory.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/oils',
|
path: '/oils',
|
||||||
@@ -27,31 +25,26 @@ const routes = [
|
|||||||
path: '/projects',
|
path: '/projects',
|
||||||
name: 'Projects',
|
name: 'Projects',
|
||||||
component: () => import('../views/Projects.vue'),
|
component: () => import('../views/Projects.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/mydiary',
|
path: '/mydiary',
|
||||||
name: 'MyDiary',
|
name: 'MyDiary',
|
||||||
component: () => import('../views/MyDiary.vue'),
|
component: () => import('../views/MyDiary.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/audit',
|
path: '/audit',
|
||||||
name: 'AuditLog',
|
name: 'AuditLog',
|
||||||
component: () => import('../views/AuditLog.vue'),
|
component: () => import('../views/AuditLog.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/bugs',
|
path: '/bugs',
|
||||||
name: 'BugTracker',
|
name: 'BugTracker',
|
||||||
component: () => import('../views/BugTracker.vue'),
|
component: () => import('../views/BugTracker.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/users',
|
path: '/users',
|
||||||
name: 'UserManagement',
|
name: 'UserManagement',
|
||||||
component: () => import('../views/UserManagement.vue'),
|
component: () => import('../views/UserManagement.vue'),
|
||||||
meta: { requiresAuth: true },
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user