-
Notifications
You must be signed in to change notification settings - Fork 244
feat(web): 统一界面图标层与菜单体系,重做 Computer 入口与权限弹窗 #1177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
282caa4
feat(icons): 建立统一界面图标层与使用规范
qqqqqf-q 8d33a2d
feat(web): 保存菜单、电脑入口与组件库联调检查点
qqqqqf-q fcd930f
chore(web): 保存图标试调与选择器修复检查点
qqqqqf-q 4ea32b0
fix(web): 收敛图标与卡片样式并复用远程图标缓存
qqqqqf-q a291c19
chore(icons): 补 CloudIcon 语义注释并修订 UI 交接文档
qqqqqf-q 74de77c
chore(ui): 更新 UI 子模块至菜单清理 checkpoint
qqqqqf-q e6296f4
fix(web): 补齐 reka 补丁的 Select 站点并消除远程图标回退闪烁
qqqqqf-q 77b3f52
feat(web): Computer 入口收尾——命名分层、原地连接向导与幽灵行
qqqqqf-q 89f061a
chore(docs): 移除分支上的过程交接文档
qqqqqf-q 0baf0d5
chore(web): 移除 connectors DEV mock fixture
qqqqqf-q 7aebd4d
fix(web): 适配 main #1195——connectors 入口深链改指 apps 页签
qqqqqf-q 82b38cc
fix(web): 独立 review 三处修复——connectors 门控、幽灵行向导上移、死 key
qqqqqf-q 77a3a42
fix(web): 输入框 placeholder 不随流式状态切换(revert #1105 的 followUpPlaceholder)
qqqqqf-q 2179c74
fix(web): runtimesReady 改用 isPending——error 初值为 null 门从未生效
qqqqqf-q 2bb9662
chore(web): gitlink 指向 ui main——ui#19 已合并(0db558f)
qqqqqf-q File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { ref } from 'vue' | ||
| import { useI18n } from 'vue-i18n' | ||
| import { useMutation } from '@pinia/colada' | ||
| import { postUsersMeRuntimes, type UserruntimeRuntime } from '@memohai/sdk' | ||
| import { toast } from '@felinic/ui' | ||
| import { resolveApiErrorMessage } from '@/utils/api-error' | ||
| import { useAccountRuntimes } from './use-computer-access' | ||
|
|
||
| // Shared one-click connect flow for every "add a computer" entry point: | ||
| // create the credential, hand it to the stepper dialog (command → connected | ||
| // → permissions), and let that dialog own cancellation cleanup. Used by the | ||
| // composer menu and the access dialog's zero-state ghost row; the Computers | ||
| // page keeps its own copy because it also drives the this-machine form. | ||
| export function useConnectComputer() { | ||
| const { t } = useI18n() | ||
| const { refetch: refetchRuntimes } = useAccountRuntimes() | ||
|
|
||
| const open = ref(false) | ||
| const credential = ref<UserruntimeRuntime | null>(null) | ||
| const { mutateAsync: createRuntime, isLoading: creating } = useMutation({ | ||
| mutation: async () => (await postUsersMeRuntimes({ body: { name: '' }, throwOnError: true })).data, | ||
| }) | ||
|
|
||
| async function startConnect(): Promise<void> { | ||
| if (creating.value) return | ||
| try { | ||
| credential.value = await createRuntime() | ||
| open.value = true | ||
| void refetchRuntimes() | ||
| } catch (error) { | ||
| toast.error(resolveApiErrorMessage(error, t('runtimes.connectDialog.createFailed'))) | ||
| } | ||
| } | ||
|
|
||
| return { connectOpen: open, connectCredential: credential, creating, startConnect } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { afterEach, expect, it, vi } from 'vitest' | ||
|
|
||
| const decode = vi.fn<() => Promise<void>>() | ||
| const request = vi.fn<typeof fetch>() | ||
| class MockImage { | ||
| src = '' | ||
| decode = decode | ||
| } | ||
|
|
||
| function setup() { | ||
| vi.stubGlobal('Image', MockImage) | ||
| vi.stubGlobal('fetch', request) | ||
| decode.mockResolvedValue(undefined) | ||
| request.mockImplementation(async () => new Response('<svg xmlns="http://www.w3.org/2000/svg"/>', { | ||
| headers: { 'Content-Type': 'image/svg+xml' }, | ||
| })) | ||
| } | ||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllGlobals() | ||
| vi.resetModules() | ||
| decode.mockReset() | ||
| request.mockReset() | ||
| }) | ||
|
|
||
| it('shares pending work and decoded bytes between preload and repeated mounts for any URL', async () => { | ||
| setup() | ||
| const { providerIconSource, preloadProviderIcons } = await import('./preload') | ||
| const url = 'https://custom.example/artwork.svg' | ||
| preloadProviderIcons([url, 'slack', undefined]) | ||
| const first = providerIconSource(url) | ||
| expect(providerIconSource(url)).toBe(first) | ||
| await vi.waitFor(() => expect(first.value).toMatch(/^data:image\/svg\+xml;base64,/)) | ||
| for (let i = 0; i < 20; i++) expect(providerIconSource(url).value).toBe(first.value) | ||
| expect(request).toHaveBeenCalledTimes(1) | ||
| expect(decode).toHaveBeenCalledTimes(1) | ||
| }) | ||
|
|
||
| it('falls back to normal embedding on CORS failure and retries on a later mount', async () => { | ||
| setup() | ||
| request.mockRejectedValueOnce(new TypeError('Failed to fetch')) | ||
| const { providerIconSource } = await import('./preload') | ||
| const url = 'https://custom.example/no-cors.png' | ||
| const first = providerIconSource(url) | ||
| await vi.waitFor(() => expect(first.value).toBe(url)) | ||
| const second = providerIconSource(url) | ||
| await vi.waitFor(() => expect(second.value).toMatch(/^data:/)) | ||
| expect(request).toHaveBeenCalledTimes(2) | ||
| }) | ||
|
|
||
| it('does not publish an undecodable data source', async () => { | ||
| setup() | ||
| decode.mockRejectedValueOnce(new Error('Invalid artwork')) | ||
| const { providerIconSource } = await import('./preload') | ||
| const url = 'https://custom.example/broken.svg' | ||
| const source = providerIconSource(url) | ||
| await vi.waitFor(() => expect(source.value).toBe(url)) | ||
| }) | ||
|
|
||
| it('evicts old cache entries without invalidating sources held by mounted consumers', async () => { | ||
| setup() | ||
| const { providerIconSource } = await import('./preload') | ||
| const first = providerIconSource('https://custom.example/first.svg') | ||
| await vi.waitFor(() => expect(first.value).toMatch(/^data:/)) | ||
| const loaded = first.value | ||
| for (let i = 0; i < 128; i++) providerIconSource(`https://custom.example/${i}.svg`) | ||
| expect(first.value).toBe(loaded) | ||
| expect(providerIconSource('https://custom.example/first.svg')).not.toBe(first) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当 URL 图标调用方仅通过组件的
size属性指定尺寸(例如 provider/voice 页面使用的size="1.5em")时,这个空span没有应用width或height,加载期间实际为 0×0;fetch/decode 完成并换成带尺寸的img后仍会发生布局跳动,正好违背这里消除尺寸跳变的目的。占位符需要根据size设置宽高,而不能仅依赖可能不存在的$attrs.class。Useful? React with 👍 / 👎.