feat: 大量管理配方和搜索改进
- 存为我的:修复调用错误API,改用 diaryStore.createDiary - 存为我的:同名检测(我的配方 + 公共配方库) - 我的配方:使用 RecipeCard 统一卡片格式 - 管理配方:按钮缩小、编辑时隐藏智能粘贴、精油搜索框支持拼音跳转 - 管理配方:批量操作改为按钮组(打标签/删除/导出卡片/分享到公共库) - 管理配方:我的配方加勾选框、全选按钮、编辑功能 - 搜索:模糊匹配 + 同义词扩展(37组),精确/相似分层显示 - 搜索:无匹配时通知编辑添加,搜索时隐藏无匹配的收藏/我的配方区 - 搜索:配方按首字母排序 - 共享审核:通知高级编辑+管理员,我的配方显示共享状态 - 通知:搜索未收录→已添加按钮,审核类→去审核按钮跳转 - 贡献统计:非管理员显示已贡献公共配方数 - 登录弹窗:加反馈问题按钮(无需登录) - 精油编辑:右上角加保存按钮,支持回车保存 - 后端:新增 /api/me/contribution 接口 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,15 @@
|
||||
<button class="login-submit" :disabled="loading" @click="submit">
|
||||
{{ loading ? '请稍候...' : (mode === 'login' ? '登录' : '注册') }}
|
||||
</button>
|
||||
|
||||
<div class="login-divider"></div>
|
||||
<button v-if="!showFeedback" class="login-feedback-btn" @click="showFeedback = true">🐛 反馈问题(无需登录)</button>
|
||||
<div v-if="showFeedback" class="feedback-section">
|
||||
<textarea v-model="feedbackText" class="login-input" rows="3" placeholder="描述你遇到的问题..." style="resize:vertical;"></textarea>
|
||||
<button class="login-submit" :disabled="!feedbackText.trim() || feedbackLoading" @click="submitFeedback">
|
||||
{{ feedbackLoading ? '提交中...' : '提交反馈' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -60,6 +69,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import { useUiStore } from '../stores/ui'
|
||||
import { api } from '../composables/useApi'
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
@@ -73,6 +83,9 @@ const confirmPassword = ref('')
|
||||
const displayName = ref('')
|
||||
const errorMsg = ref('')
|
||||
const loading = ref(false)
|
||||
const showFeedback = ref(false)
|
||||
const feedbackText = ref('')
|
||||
const feedbackLoading = ref(false)
|
||||
|
||||
async function submit() {
|
||||
errorMsg.value = ''
|
||||
@@ -115,6 +128,26 @@ async function submit() {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitFeedback() {
|
||||
if (!feedbackText.value.trim()) return
|
||||
feedbackLoading.value = true
|
||||
try {
|
||||
const res = await api('/api/bug-report', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ content: feedbackText.value.trim(), priority: 0 }),
|
||||
})
|
||||
if (res.ok) {
|
||||
feedbackText.value = ''
|
||||
showFeedback.value = false
|
||||
ui.showToast('反馈已提交,感谢!')
|
||||
}
|
||||
} catch {
|
||||
ui.showToast('提交失败')
|
||||
} finally {
|
||||
feedbackLoading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -209,4 +242,31 @@ async function submit() {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.login-divider {
|
||||
height: 1px;
|
||||
background: #eee;
|
||||
margin: 4px 0;
|
||||
}
|
||||
|
||||
.login-feedback-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #999;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
text-align: center;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
.login-feedback-btn:hover {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.feedback-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<button class="action-btn action-btn-fav action-btn-sm" @click="handleToggleFavorite">
|
||||
{{ isFav ? '★ 已收藏' : '☆ 收藏' }}
|
||||
</button>
|
||||
<button v-if="!recipe._diary_id" class="action-btn action-btn-diary action-btn-sm" @click="saveToDiary">
|
||||
<button v-if="!props.isDiary" class="action-btn action-btn-diary action-btn-sm" @click="saveToDiary">
|
||||
📔 存为我的
|
||||
</button>
|
||||
</div>
|
||||
@@ -359,7 +359,9 @@ import { matchesPinyinInitials } from '../composables/usePinyinMatch'
|
||||
// TagPicker replaced with inline tag editing
|
||||
|
||||
const props = defineProps({
|
||||
recipeIndex: { type: Number, required: true },
|
||||
recipeIndex: { type: Number, default: null },
|
||||
recipeData: { type: Object, default: null },
|
||||
isDiary: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
@@ -386,9 +388,10 @@ const generatingImage = ref(false)
|
||||
const previewOverride = ref(null)
|
||||
|
||||
// ---- Source recipe ----
|
||||
const recipe = computed(() =>
|
||||
recipesStore.recipes[props.recipeIndex] || { name: '', ingredients: [], tags: [], note: '' }
|
||||
)
|
||||
const recipe = computed(() => {
|
||||
if (props.recipeData) return props.recipeData
|
||||
return recipesStore.recipes[props.recipeIndex] || { name: '', ingredients: [], tags: [], note: '' }
|
||||
})
|
||||
|
||||
// ---- Display recipe: previewOverride when in preview mode, otherwise saved recipe ----
|
||||
const displayRecipe = computed(() => {
|
||||
@@ -710,22 +713,31 @@ async function saveToDiary() {
|
||||
return
|
||||
}
|
||||
const name = await showPrompt('保存为我的配方,名称:', recipe.value.name)
|
||||
// null = user cancelled (clicked 取消)
|
||||
if (name === null) return
|
||||
// empty string = user cleared the name field
|
||||
if (!name.trim()) {
|
||||
ui.showToast('请输入配方名称')
|
||||
return
|
||||
}
|
||||
const trimmed = name.trim()
|
||||
const dupDiary = diaryStore.userDiary.some(d => d.name === trimmed)
|
||||
const dupPublic = recipesStore.recipes.some(r => r.name === trimmed)
|
||||
if (dupDiary) {
|
||||
ui.showToast('我的配方中已有同名配方「' + trimmed + '」')
|
||||
return
|
||||
}
|
||||
if (dupPublic) {
|
||||
ui.showToast('公共配方库中已有同名配方「' + trimmed + '」')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const payload = {
|
||||
name: name.trim(),
|
||||
note: recipe.value.note || '',
|
||||
ingredients: recipe.value.ingredients.map(i => ({ oil_name: i.oil, drops: i.drops })),
|
||||
ingredients: recipe.value.ingredients.map(i => ({ oil: i.oil, drops: i.drops })),
|
||||
tags: recipe.value.tags || [],
|
||||
source_recipe_id: recipe.value._id || null,
|
||||
}
|
||||
console.log('[saveToDiary] saving recipe:', payload)
|
||||
await recipesStore.saveRecipe(payload)
|
||||
await diaryStore.createDiary(payload)
|
||||
ui.showToast('已保存!可在「配方查询 → 我的配方」查看')
|
||||
} catch (e) {
|
||||
console.error('[saveToDiary] failed:', e)
|
||||
|
||||
@@ -30,7 +30,14 @@
|
||||
class="notif-item" :class="{ unread: !n.is_read }">
|
||||
<div class="notif-item-header">
|
||||
<div class="notif-title">{{ n.title }}</div>
|
||||
<button v-if="!n.is_read" class="notif-mark-one" @click="markOneRead(n)">已读</button>
|
||||
<div v-if="!n.is_read" class="notif-actions">
|
||||
<!-- 搜索未收录通知:已添加按钮 -->
|
||||
<button v-if="isSearchMissing(n)" class="notif-action-btn notif-btn-added" @click="markAdded(n)">已添加</button>
|
||||
<!-- 审核类通知:去审核按钮 -->
|
||||
<button v-else-if="isReviewable(n)" class="notif-action-btn notif-btn-review" @click="goReview(n)">去审核</button>
|
||||
<!-- 默认:已读按钮 -->
|
||||
<button v-else class="notif-mark-one" @click="markOneRead(n)">已读</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="n.body" class="notif-body">{{ n.body }}</div>
|
||||
<div class="notif-time">{{ formatTime(n.created_at) }}</div>
|
||||
@@ -108,6 +115,29 @@ async function submitBug() {
|
||||
}
|
||||
}
|
||||
|
||||
function isSearchMissing(n) {
|
||||
return n.title && n.title.includes('用户需求')
|
||||
}
|
||||
|
||||
function isReviewable(n) {
|
||||
if (!n.title) return false
|
||||
return n.title.includes('待审核') || n.title.includes('商业认证') || n.title.includes('申请')
|
||||
}
|
||||
|
||||
async function markAdded(n) {
|
||||
await markOneRead(n)
|
||||
}
|
||||
|
||||
function goReview(n) {
|
||||
markOneRead(n)
|
||||
emit('close')
|
||||
if (n.title.includes('配方')) {
|
||||
router.push('/manage')
|
||||
} else if (n.title.includes('商业认证') || n.title.includes('申请')) {
|
||||
router.push('/users')
|
||||
}
|
||||
}
|
||||
|
||||
async function markOneRead(n) {
|
||||
try {
|
||||
await api(`/api/notifications/${n.id}/read`, { method: 'POST', body: '{}' })
|
||||
@@ -209,6 +239,16 @@ onMounted(loadNotifications)
|
||||
font-family: inherit; white-space: nowrap; flex-shrink: 0;
|
||||
}
|
||||
.notif-mark-one:hover { background: #f0faf5; border-color: #7a9e7e; }
|
||||
.notif-actions { display: flex; gap: 4px; flex-shrink: 0; }
|
||||
.notif-action-btn {
|
||||
background: none; border: 1px solid #ccc; border-radius: 6px;
|
||||
font-size: 11px; cursor: pointer; padding: 2px 8px;
|
||||
font-family: inherit; white-space: nowrap;
|
||||
}
|
||||
.notif-btn-added { color: #4a9d7e; border-color: #7ec6a4; }
|
||||
.notif-btn-added:hover { background: #e8f5e9; }
|
||||
.notif-btn-review { color: #e65100; border-color: #ffb74d; }
|
||||
.notif-btn-review:hover { background: #fff3e0; }
|
||||
.notif-body { color: #888; font-size: 12px; margin-top: 2px; white-space: pre-line; }
|
||||
.notif-time { color: #bbb; font-size: 11px; margin-top: 2px; }
|
||||
.notif-empty { text-align: center; color: #ccc; padding: 16px; font-size: 13px; }
|
||||
|
||||
Reference in New Issue
Block a user