5 Commits

Author SHA1 Message Date
abc54f2d6a test: PR#29测试 — 拼音匹配扩展、viewer标签可见性
All checks were successful
PR Preview / test (pull_request) Has been skipped
Deploy Production / test (push) Successful in 5s
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Successful in 13s
PR Preview / deploy-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Deploy Production / deploy (push) Successful in 6s
Test / e2e-test (push) Successful in 51s
新增14个单元测试:
- 拼音匹配: mlk→麦卢卡、tx→檀香等11个用例
- viewer标签可见性: 只看自己diary标签、不看公共标签

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:43:15 +00:00
6d1ae6e682 fix: 补全88个精油名拼音映射,修复mlk无法匹配麦卢卡等问题
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:40:56 +00:00
1790ab3b44 fix: viewer只能看到和管理自己个人配方的标签,不显示公共库标签
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:36:09 +00:00
36862a4dbe fix: 用户管理筛选去掉管理员加企业用户,管理员不可换角色和删除
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 49s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:19:58 +00:00
eae9d507f2 fix: 商业认证图标逻辑反转 — 认证用户点亮,未认证灰色
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 8s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Successful in 53s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 13:17:25 +00:00
4 changed files with 130 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import { describe, it, expect } from 'vitest' import { describe, it, expect } from 'vitest'
import { recipeNameEn, oilEn } from '../composables/useOilTranslation' import { recipeNameEn, oilEn } from '../composables/useOilTranslation'
import { matchesPinyinInitials, getPinyinInitials } from '../composables/usePinyinMatch'
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// EDITOR_ONLY_TAGS includes '已下架' // EDITOR_ONLY_TAGS includes '已下架'
@@ -283,3 +284,95 @@ describe('one-time username change guard', () => {
expect(!!user.username_changed).toBe(false) expect(!!user.username_changed).toBe(false)
}) })
}) })
// ---------------------------------------------------------------------------
// Pinyin matching — PR29 extended coverage
// ---------------------------------------------------------------------------
describe('pinyin matching — extended oil names', () => {
it('matches mlk → 麦卢卡', () => {
expect(matchesPinyinInitials('麦卢卡', 'mlk')).toBe(true)
})
it('matches tx → 檀香', () => {
expect(matchesPinyinInitials('檀香', 'tx')).toBe(true)
})
it('matches xm → 香茅', () => {
expect(matchesPinyinInitials('香茅', 'xm')).toBe(true)
})
it('matches gbxz → 古巴香脂', () => {
expect(matchesPinyinInitials('古巴香脂', 'gbxz')).toBe(true)
})
it('matches my → 没药', () => {
expect(matchesPinyinInitials('没药', 'my')).toBe(true)
})
it('matches xhx → 小茴香', () => {
expect(matchesPinyinInitials('小茴香', 'xhx')).toBe(true)
})
it('matches jybh → 椒样薄荷', () => {
expect(matchesPinyinInitials('椒样薄荷', 'jybh')).toBe(true)
})
it('matches xbynz → 西班牙牛至', () => {
expect(matchesPinyinInitials('西班牙牛至', 'xbynz')).toBe(true)
})
it('matches sc → 顺畅呼吸 prefix', () => {
expect(matchesPinyinInitials('顺畅呼吸', 'sc')).toBe(true)
})
it('does not match wrong initials', () => {
expect(matchesPinyinInitials('麦卢卡', 'abc')).toBe(false)
})
it('getPinyinInitials returns correct string', () => {
expect(getPinyinInitials('麦卢卡')).toBe('mlk')
expect(getPinyinInitials('檀香')).toBe('tx')
expect(getPinyinInitials('没药')).toBe('my')
})
})
// ---------------------------------------------------------------------------
// Viewer tag visibility — PR29
// ---------------------------------------------------------------------------
describe('viewer tag visibility logic', () => {
const EDITOR_ONLY_TAGS_VAL = ['已审核', '已下架']
it('editor sees all tags', () => {
const allTags = ['美容', '儿童', '已审核', '已下架']
const canEdit = true
const visible = canEdit ? allTags : []
expect(visible).toEqual(allTags)
})
it('viewer sees no public tags', () => {
const canEdit = false
const myDiary = [
{ tags: ['我的标签'] },
{ tags: ['我的标签', '另一个'] },
]
// Viewer: collect tags from own diary only
const myTags = new Set()
for (const d of myDiary) {
for (const t of (d.tags || [])) myTags.add(t)
}
const visible = canEdit ? ['美容', '已审核'] : [...myTags]
expect(visible).toContain('我的标签')
expect(visible).toContain('另一个')
expect(visible).not.toContain('美容')
expect(visible).not.toContain('已审核')
})
it('viewer with no diary tags sees empty', () => {
const myDiary = []
const myTags = new Set()
for (const d of myDiary) {
for (const t of (d.tags || [])) myTags.add(t)
}
expect([...myTags]).toHaveLength(0)
})
})

View File

@@ -57,6 +57,25 @@ const PINYIN_MAP = {
'触': 'c', '修': 'x', '养': 'y', '滋': 'z', '润': 'r', '触': 'c', '修': 'x', '养': 'y', '滋': 'z', '润': 'r',
'呼': 'h', '吸': 'x', '消': 'x', '化': 'h', '排': 'p', '呼': 'h', '吸': 'x', '消': 'x', '化': 'h', '排': 'p',
'毒': 'd', '净': 'j', '纤': 'x', '体': 't', '塑': 's', '毒': 'd', '净': 'j', '纤': 'x', '体': 't', '塑': 's',
// Extended: all oil name chars
'麦': 'm', '卢': 'l', '卡': 'k', '檀': 't', '橘': 'j',
'茅': 'm', '茴': 'h', '芹': 'q', '菜': 'c', '蕾': 'l',
'蜂': 'f', '蓍': 's', '莱': 'l', '姆': 'm', '莎': 's',
'穗': 's', '醇': 'c', '郁': 'y', '没': 'm', '脂': 'z',
'巴': 'b', '样': 'y', '班': 'b', '牙': 'y', '鸡': 'j',
'苍': 'c', '卫': 'w', '畅': 'c', '顺': 's', '释': 's',
'悦': 'y', '柔': 'r', '压': 'y', '定': 'd', '情': 'q',
'绪': 'x', '神': 's', '气': 'q', '宽': 'k', '容': 'r',
'恬': 't', '家': 'j', '欢': 'h', '欣': 'x', '舞': 'w',
'鼓': 'g', '赋': 'f', '谧': 'm', '睡': 's', '烂': 'l',
'绚': 'x', '焕': 'h', '肤': 'f', '年': 'n', '华': 'h',
'完': 'w', '理': 'l', '注': 'z', '贯': 'g', '全': 'q',
'仕': 's', '女': 'nv', '伯': 'b', '斯': 's', '道': 'd',
'格': 'g', '拉': 'l', '元': 'y', '肌': 'j', '栀': 'z',
'鹅': 'e', '掌': 'z', '柴': 'c', '胶': 'j', '囊': 'n',
'空': 'k', '风': 'f', '文': 'w', '月': 'y', '云': 'y',
'五': 'w', '味': 'w', '愈': 'y', '创': 'c', '慰': 'w',
'扁': 'b', '广': 'g', '州': 'z', '热': 'r',
} }
/** /**

View File

@@ -83,7 +83,7 @@
</div> </div>
<div class="candidate-tags"> <div class="candidate-tags">
<span <span
v-for="tag in recipeStore.allTags.filter(t => !batchTagsSelected.includes(t))" v-for="tag in visibleAllTags.filter(t => !batchTagsSelected.includes(t))"
:key="tag" :key="tag"
class="candidate-tag" class="candidate-tag"
@click="batchTagsSelected.push(tag)" @click="batchTagsSelected.push(tag)"
@@ -1308,9 +1308,13 @@ const previewRecipeIndex = ref(null)
const previewRecipeData = ref(null) const previewRecipeData = ref(null)
const showBatchMenu = ref(false) const showBatchMenu = ref(false)
const visibleAllTags = computed(() => { const visibleAllTags = computed(() => {
const tags = recipeStore.allTags if (auth.canEdit) return recipeStore.allTags
if (auth.canEdit) return tags // Viewer: only show tags from their own diary recipes
return tags.filter(t => !EDITOR_ONLY_TAGS.includes(t)) const myTags = new Set()
for (const d of diaryStore.userDiary) {
for (const t of (d.tags || [])) myTags.add(t)
}
return [...myTags].sort((a, b) => a.localeCompare(b, 'zh'))
}) })
const showBatchTagPicker = ref(false) const showBatchTagPicker = ref(false)
const batchTagsSelected = ref([]) const batchTagsSelected = ref([])

View File

@@ -91,18 +91,18 @@
</div> </div>
<div class="user-actions"> <div class="user-actions">
<select <select
v-if="u.role !== 'admin'"
:value="u.role" :value="u.role"
class="role-select" class="role-select"
@change="changeRole(u, $event.target.value)" @change="changeRole(u, $event.target.value)"
:disabled="u.role === 'admin'"
> >
<option value="viewer">查看者</option> <option value="viewer">查看者</option>
<option value="editor">编辑</option> <option value="editor">编辑</option>
<option value="senior_editor">高级编辑</option> <option value="senior_editor">高级编辑</option>
</select> </select>
<button v-if="!u.business_verified" class="btn-sm btn-outline" @click="grantBusiness(u)" title="开通商业认证">💼</button> <button v-if="u.business_verified" class="btn-sm btn-outline" @click="revokeBusiness(u)" title="撤销商业认证">💼</button>
<button v-else class="btn-sm btn-outline" @click="revokeBusiness(u)" title="撤销商业认证" style="opacity:0.5">💼</button> <button v-else class="btn-sm btn-outline" @click="grantBusiness(u)" title="开通商业认证" style="opacity:0.3">💼</button>
<button class="btn-sm btn-delete" @click="removeUser(u)" title="删除用户">🗑</button> <button class="btn-sm btn-delete" @click="removeUser(u)" :disabled="u.role === 'admin'" title="删除用户">🗑</button>
</div> </div>
</div> </div>
<div v-if="filteredUsers.length === 0" class="empty-hint">未找到用户</div> <div v-if="filteredUsers.length === 0" class="empty-hint">未找到用户</div>
@@ -162,10 +162,10 @@ function formatDate(d) {
} }
const roles = [ const roles = [
{ value: 'admin', label: '管理员' },
{ value: 'senior_editor', label: '高级编辑' }, { value: 'senior_editor', label: '高级编辑' },
{ value: 'editor', label: '编辑' }, { value: 'editor', label: '编辑' },
{ value: 'viewer', label: '查看者' }, { value: 'viewer', label: '查看者' },
{ value: 'business', label: '企业用户' },
] ]
const filteredUsers = computed(() => { const filteredUsers = computed(() => {
@@ -178,7 +178,11 @@ const filteredUsers = computed(() => {
) )
} }
if (filterRole.value) { if (filterRole.value) {
list = list.filter(u => u.role === filterRole.value) if (filterRole.value === 'business') {
list = list.filter(u => u.business_verified)
} else {
list = list.filter(u => u.role === filterRole.value)
}
} }
return list return list
}) })