Browse Source

WIP: 区分置顶实心与取消置顶图标

[gstack-context]
Decisions: 未置顶动作空心针、列表已置顶实心针、取消置顶斜线针
Remaining: 全量测试、重载 8800、真实页面检查
Skill: /frontend-skill
[/gstack-context]
samien 2 tháng trước cách đây
mục cha
commit
89f53ea71e

+ 1 - 1
src/client/components/app/ResourceSidebar.vue

@@ -139,7 +139,7 @@ defineExpose({ focusSearch })
             </span>
             <span class="sidebar-item__copy">
               <span class="sidebar-item__row">
-                <strong><AppIcon v-if="row.item.pinned" name="pin" :size="12" />{{ row.item.title }}</strong>
+                <strong><AppIcon v-if="row.item.pinned" name="pin-filled" :size="12" />{{ row.item.title }}</strong>
                 <small v-if="row.item.meta">{{ row.item.meta }}</small>
               </span>
               <span v-if="!singleLine && row.item.subtitle" class="sidebar-item__row sidebar-item__row--secondary">

+ 4 - 0
src/client/components/common/AppIcon.vue

@@ -40,6 +40,8 @@ type IconName =
   | 'edit'
   | 'panel'
   | 'pin'
+  | 'pin-filled'
+  | 'pin-off'
 
 withDefaults(defineProps<{ name: IconName; size?: number }>(), { size: 18 })
 </script>
@@ -108,6 +110,8 @@ withDefaults(defineProps<{ name: IconName; size?: number }>(), { size: 18 })
     <template v-else-if="name === 'edit'"><path d="M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L8 18l-4 1 1-4z" /></template>
     <template v-else-if="name === 'panel'"><rect x="3" y="3" width="18" height="18" rx="2" /><path d="M15 3v18" /></template>
     <template v-else-if="name === 'pin'"><path d="M9 4v6l-2 4v2h10v-2l-2-4V4M12 16v5M8 4h8" /></template>
+    <template v-else-if="name === 'pin-filled'"><path d="M8 3a1 1 0 0 0 0 2h1v4.72l-2.8 4.7A1 1 0 0 0 7.06 16H11v5a1 1 0 1 0 2 0v-5h3.94a1 1 0 0 0 .86-1.58L15 9.72V5h1a1 1 0 1 0 0-2z" fill="currentColor" stroke="none" /></template>
+    <template v-else-if="name === 'pin-off'"><path d="M9 4v6l-2 4v2h10v-2l-2-4V4M12 16v5M8 4h8" /><path d="M4 4l16 16" /></template>
   </svg>
 </template>
 

+ 1 - 1
src/client/views/ChatView.vue

@@ -411,7 +411,7 @@ watch(() => chat.activeSessionId, async id => {
           <div><button class="quiet-button" type="button" @click="renaming = false">取消</button><button class="solid-button" type="button" @click="saveRename">保存</button></div>
         </template>
         <template v-else>
-          <button class="action-row" role="menuitem" type="button" @click="toggleSessionPinned"><AppIcon name="pin" :size="14" />{{ actionSession?.pinned ? '取消置顶' : '置顶会话' }}</button>
+          <button class="action-row" role="menuitem" type="button" @click="toggleSessionPinned"><AppIcon :name="actionSession?.pinned ? 'pin-off' : 'pin'" :size="14" />{{ actionSession?.pinned ? '取消置顶' : '置顶会话' }}</button>
           <button class="action-row" role="menuitem" type="button" @click="renaming = true"><AppIcon name="edit" :size="14" />重命名</button>
           <button class="action-row danger" role="menuitem" type="button" @click="deleteSession"><AppIcon name="trash" :size="14" />删除会话</button>
         </template>

+ 4 - 1
tests/e2e/workspace.spec.ts

@@ -195,7 +195,10 @@ test('keeps the canonical logo and yaoyao-webui composer geometry', async ({ pag
   await page.getByRole('button', { name: '会话操作' }).click()
   const sessionMenu = page.getByRole('menu', { name: '会话操作' })
   await expect(sessionMenu.getByText('取消置顶', { exact: true })).toBeVisible()
-  await expect(sessionMenu.getByRole('menuitem', { name: '取消置顶' }).locator('path')).toHaveAttribute('d', /M9 4v6l-2 4v2h10/)
+  const unpinIcon = sessionMenu.getByRole('menuitem', { name: '取消置顶' }).locator('.app-icon')
+  await expect(unpinIcon.locator('path')).toHaveCount(2)
+  await expect(unpinIcon.locator('path').last()).toHaveAttribute('d', 'M4 4l16 16')
+  await expect(page.locator('.desktop-sidebar .sidebar-item--single-line').first().locator('.app-icon path')).toHaveAttribute('fill', 'currentColor')
   await expect(sessionMenu.getByText('重命名', { exact: true })).toBeVisible()
   await expect(sessionMenu.getByText('删除会话', { exact: true })).toBeVisible()
   await expect(page.getByText('置顶会话', { exact: true })).toHaveCount(0)