diff --git a/backend/main.py b/backend/main.py index d05dbe8..4fa4148 100644 --- a/backend/main.py +++ b/backend/main.py @@ -324,7 +324,7 @@ def symptom_search(body: dict, user=Depends(get_current_user)): # If user reports no match, notify editors if body.get("report_missing"): who = user.get("display_name") or user.get("username") or "用户" - for role in ("admin", "senior_editor", "editor"): + for role in ("admin", "senior_editor"): conn.execute( "INSERT INTO notifications (target_role, title, body) VALUES (?, ?, ?)", (role, "🔍 用户需求:" + query, diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 0d23ac5..8a396ce 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -32,7 +32,7 @@ @@ -72,29 +72,24 @@ const route = useRoute() const showUserMenu = ref(false) const navTabsRef = ref(null) -// Tab 定义,顺序固定:配方查询 → 管理配方 → 个人库存 → 精油价目 → 商业核算 → 操作日志 → Bug → 用户管理 -// require: 'login' = 需要登录, 'business' = 需要商业认证, 'admin' = 需要管理员 +// Tab 定义,顺序固定 +// require: 点击时需要的条件,不满足则提示 +// hide: 完全隐藏(只有满足条件才显示) const allTabs = [ { key: 'search', icon: '🔍', label: '配方查询' }, { key: 'manage', icon: '📋', label: '管理配方', require: 'login' }, { key: 'inventory', icon: '📦', label: '个人库存', require: 'login' }, { key: 'oils', icon: '💧', label: '精油价目' }, - { key: 'projects', icon: '💼', label: '商业核算', require: 'business' }, - { key: 'audit', icon: '📜', label: '操作日志', require: 'admin' }, - { key: 'bugs', icon: '🐛', label: 'Bug', require: 'admin' }, - { key: 'users', icon: '👥', label: '用户管理', require: 'admin' }, + { key: 'projects', icon: '💼', label: '商业核算', require: 'login' }, + { key: 'audit', icon: '📜', label: '操作日志', hide: 'admin' }, + { key: 'bugs', icon: '🐛', label: 'Bug', hide: 'admin' }, + { key: 'users', icon: '👥', label: '用户管理', hide: 'admin' }, ] -// 根据当前用户角色,过滤出可见的 tab -// 未登录: 配方查询, 精油价目 -// 普通登录: 配方查询, 管理配方, 个人库存, 精油价目 -// 商业用户: + 商业核算 -// 管理员: + 操作日志, Bug, 用户管理 +// 所有人都能看到大部分 tab,bug 和用户管理只有 admin 可见 const visibleTabs = computed(() => allTabs.filter(t => { - if (!t.require) return true - if (t.require === 'login') return auth.isLoggedIn - if (t.require === 'business') return auth.isBusiness - if (t.require === 'admin') return auth.isAdmin + if (!t.hide) return true + if (t.hide === 'admin') return auth.isAdmin return true })) const unreadNotifCount = ref(0) @@ -124,6 +119,22 @@ const prMatch = hostname.match(/^pr-(\d+)\./) const isPreview = !!prMatch const prId = prMatch ? prMatch[1] : '' +function handleTabClick(tab) { + if (tab.require === 'login' && !auth.isLoggedIn) { + ui.openLogin(() => goSection(tab.key)) + return + } + if (tab.require === 'business' && !auth.isBusiness) { + if (!auth.isLoggedIn) { + ui.openLogin(() => goSection(tab.key)) + } else { + ui.showToast('需要商业认证才能使用此功能') + } + return + } + goSection(tab.key) +} + function goSection(name) { ui.showSection(name) router.push('/' + (name === 'search' ? '' : name)) @@ -178,12 +189,12 @@ function onSwipeEnd(e) { const currentIdx = tabs.indexOf(ui.currentSection) if (currentIdx < 0) return - if (dx < 0 && currentIdx < tabs.length - 1) { - // 左滑 → 下一个 tab - goSection(tabs[currentIdx + 1]) - } else if (dx > 0 && currentIdx > 0) { - // 右滑 → 上一个 tab - goSection(tabs[currentIdx - 1]) + let nextIdx = -1 + if (dx < 0 && currentIdx < tabs.length - 1) nextIdx = currentIdx + 1 + else if (dx > 0 && currentIdx > 0) nextIdx = currentIdx - 1 + if (nextIdx >= 0) { + const tab = visibleTabs.value[nextIdx] + handleTabClick(tab) } } diff --git a/frontend/src/views/MyDiary.vue b/frontend/src/views/MyDiary.vue index fda3760..bd00166 100644 --- a/frontend/src/views/MyDiary.vue +++ b/frontend/src/views/MyDiary.vue @@ -241,7 +241,7 @@ -
+

💼 商业认证

申请商业认证后可使用商业核算功能。

@@ -259,8 +259,8 @@