mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
## Summary Extracts desktop UI into apps/desktop-ui package with minimal changes. ## Changes - **What**: - Separates desktop-specific code into standalone package with independent Vite config, router, and i18n - Drastically simplifies the main app router by removing all desktop routes - Adds a some code duplication, most due to the existing design - Some duplication can be refactored to be *simpler* on either side - no need to split things by `isElectron()` - Rudimentary storybook support has been added - **Breaking**: Stacked PR for publishing must be merged before this PR makes it to stable core (but publishing _could_ be done manually) - #5915 - **Dependencies**: Takes full advantage of pnpm catalog. No additional dependencies added. ## Review Focus - Should be no changes to normal frontend operation - Scripts added to root package.json are acceptable - The duplication in this PR is copied as is, wherever possible. Any corrections or fix-ups beyond the scope of simply migrating the functionality as-is, can be addressed in later PRs. That said, if any changes are made, it instantly becomes more difficult to separate the duplicated code out into a shared utility. - Tracking issue to address concerns: #5925 ### i18n Fixing i18n is out of scope for this PR. It is a larger task that we should consider carefully and implement properly. Attempting to isolate the desktop i18n and duplicate the _current_ localisation scripts would be wasted energy.
89 lines
2.2 KiB
TypeScript
89 lines
2.2 KiB
TypeScript
import { definePreset } from '@primevue/themes'
|
|
import Aura from '@primevue/themes/aura'
|
|
import { setup } from '@storybook/vue3'
|
|
import type { Preview, StoryContext, StoryFn } from '@storybook/vue3-vite'
|
|
import { createPinia } from 'pinia'
|
|
import 'primeicons/primeicons.css'
|
|
import PrimeVue from 'primevue/config'
|
|
import ConfirmationService from 'primevue/confirmationservice'
|
|
import ToastService from 'primevue/toastservice'
|
|
import Tooltip from 'primevue/tooltip'
|
|
|
|
import '@/assets/css/style.css'
|
|
import { i18n } from '@/i18n'
|
|
|
|
const ComfyUIPreset = definePreset(Aura, {
|
|
semantic: {
|
|
// @ts-expect-error prime type quirk
|
|
primary: Aura['primitive'].blue
|
|
}
|
|
})
|
|
|
|
setup((app) => {
|
|
app.directive('tooltip', Tooltip)
|
|
|
|
const pinia = createPinia()
|
|
|
|
app.use(pinia)
|
|
app.use(i18n)
|
|
app.use(PrimeVue, {
|
|
theme: {
|
|
preset: ComfyUIPreset,
|
|
options: {
|
|
prefix: 'p',
|
|
cssLayer: { name: 'primevue', order: 'primevue, tailwind-utilities' },
|
|
darkModeSelector: '.dark-theme, :root:has(.dark-theme)'
|
|
}
|
|
}
|
|
})
|
|
app.use(ConfirmationService)
|
|
app.use(ToastService)
|
|
})
|
|
|
|
export const withTheme = (Story: StoryFn, context: StoryContext) => {
|
|
const theme = context.globals.theme || 'light'
|
|
if (theme === 'dark') {
|
|
document.documentElement.classList.add('dark-theme')
|
|
document.body.classList.add('dark-theme')
|
|
} else {
|
|
document.documentElement.classList.remove('dark-theme')
|
|
document.body.classList.remove('dark-theme')
|
|
}
|
|
|
|
return Story(context.args, context)
|
|
}
|
|
|
|
const preview: Preview = {
|
|
parameters: {
|
|
controls: {
|
|
matchers: { color: /(background|color)$/i, date: /Date$/i }
|
|
},
|
|
backgrounds: {
|
|
default: 'light',
|
|
values: [
|
|
{ name: 'light', value: '#ffffff' },
|
|
{ name: 'dark', value: '#0a0a0a' }
|
|
]
|
|
}
|
|
},
|
|
globalTypes: {
|
|
theme: {
|
|
name: 'Theme',
|
|
description: 'Global theme for components',
|
|
defaultValue: 'light',
|
|
toolbar: {
|
|
icon: 'circlehollow',
|
|
items: [
|
|
{ value: 'light', icon: 'sun', title: 'Light' },
|
|
{ value: 'dark', icon: 'moon', title: 'Dark' }
|
|
],
|
|
showName: true,
|
|
dynamicTitle: true
|
|
}
|
|
}
|
|
},
|
|
decorators: [withTheme]
|
|
}
|
|
|
|
export default preview
|