mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-21 14:59:39 +00:00
Add server config modified message to prompt restart (#1668)
* Server config changed message * Write to settings on unmount * nit * Highlight modified config * Move modified logic to store * Add jest test * nit
This commit is contained in:
@@ -3,7 +3,14 @@ import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export type ServerConfigWithValue<T> = ServerConfig<T> & {
|
||||
/**
|
||||
* Current value.
|
||||
*/
|
||||
value: T
|
||||
/**
|
||||
* Initial value loaded from settings.
|
||||
*/
|
||||
initialValue: T
|
||||
}
|
||||
|
||||
export const useServerConfigStore = defineStore('serverConfig', () => {
|
||||
@@ -11,6 +18,12 @@ export const useServerConfigStore = defineStore('serverConfig', () => {
|
||||
const serverConfigs = computed(() => {
|
||||
return Object.values(serverConfigById.value)
|
||||
})
|
||||
const modifiedConfigs = computed<ServerConfigWithValue<any>[]>(() => {
|
||||
return serverConfigs.value.filter((config) => {
|
||||
return config.initialValue !== config.value
|
||||
})
|
||||
})
|
||||
|
||||
const serverConfigsByCategory = computed<
|
||||
Record<string, ServerConfigWithValue<any>[]>
|
||||
>(() => {
|
||||
@@ -55,9 +68,11 @@ export const useServerConfigStore = defineStore('serverConfig', () => {
|
||||
values: Record<string, any>
|
||||
) {
|
||||
for (const config of configs) {
|
||||
const value = values[config.id] ?? config.defaultValue
|
||||
serverConfigById.value[config.id] = {
|
||||
...config,
|
||||
value: values[config.id] ?? config.defaultValue
|
||||
value,
|
||||
initialValue: value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +80,7 @@ export const useServerConfigStore = defineStore('serverConfig', () => {
|
||||
return {
|
||||
serverConfigById,
|
||||
serverConfigs,
|
||||
modifiedConfigs,
|
||||
serverConfigsByCategory,
|
||||
serverConfigValues,
|
||||
launchArgs,
|
||||
|
||||
Reference in New Issue
Block a user