mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-28 02:34:10 +00:00
## Summary Address several small CodeRabbit-filed issues: clipboard simplification, queue getter cleanup, pointer handling, and test parameterization. ## Changes - **What**: - Simplify `useCopyToClipboard` by using VueUse's built-in `legacy` mode instead of a manual `document.execCommand` fallback - Remove `queueIndex` getter alias from `TaskItemImpl`, replace all usages with `job.priority` - Add `pointercancel` event handling and try-catch around `releasePointerCapture` in `useNodeResize` to prevent stuck resize state - Parameterize repetitive `getNodeProvider` tests in `modelToNodeStore.test.ts` using `it.each()` - Fixes #9024 - Fixes #7955 - Fixes #7323 - Fixes #8703 ## Review Focus - `useCopyToClipboard`: VueUse's `legacy: true` enables the `execCommand` fallback internally — verify browser compat is acceptable - `useNodeResize`: cleanup logic extracted into shared function used by both `pointerup` and `pointercancel`
40 lines
871 B
TypeScript
40 lines
871 B
TypeScript
import { useClipboard } from '@vueuse/core'
|
|
import { useToast } from 'primevue/usetoast'
|
|
|
|
import { t } from '@/i18n'
|
|
|
|
export function useCopyToClipboard() {
|
|
const { copy, copied } = useClipboard({ legacy: true })
|
|
const toast = useToast()
|
|
|
|
async function copyToClipboard(text: string) {
|
|
try {
|
|
await copy(text)
|
|
if (copied.value) {
|
|
toast.add({
|
|
severity: 'success',
|
|
summary: t('g.success'),
|
|
detail: t('clipboard.successMessage'),
|
|
life: 3000
|
|
})
|
|
} else {
|
|
toast.add({
|
|
severity: 'error',
|
|
summary: t('g.error'),
|
|
detail: t('clipboard.errorMessage')
|
|
})
|
|
}
|
|
} catch {
|
|
toast.add({
|
|
severity: 'error',
|
|
summary: t('g.error'),
|
|
detail: t('clipboard.errorMessage')
|
|
})
|
|
}
|
|
}
|
|
|
|
return {
|
|
copyToClipboard
|
|
}
|
|
}
|