🐛 fix: Fix ImageInfo reload (#474)
parent
4be9f3634f
commit
8b17a70e1a
File diff suppressed because one or more lines are too long
|
|
@ -8,31 +8,49 @@ const formatPrompt = (prompt: string) => {
|
||||||
export const formatInfo = (info: string) => {
|
export const formatInfo = (info: string) => {
|
||||||
if (!info || info === 'undefined') return;
|
if (!info || info === 'undefined') return;
|
||||||
if (!info.includes('<br>')) return;
|
if (!info.includes('<br>')) return;
|
||||||
const data = info.split('<br>').filter(Boolean);
|
const data = info?.split('<br>').filter(Boolean);
|
||||||
const config = data[2] || data[1];
|
|
||||||
|
let position: any;
|
||||||
|
let negative: any;
|
||||||
|
let config: any;
|
||||||
|
|
||||||
|
switch (data.length) {
|
||||||
|
case 1: {
|
||||||
|
config = data[0] || info;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
if (data[0].includes('Negative prompt:')) {
|
||||||
|
negative = data[0];
|
||||||
|
config = data[1];
|
||||||
|
} else {
|
||||||
|
position = data[0];
|
||||||
|
config = data[1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
position = data[0];
|
||||||
|
negative = data[1];
|
||||||
|
config = data[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.includes(',')) return;
|
if (!config.includes(',')) return;
|
||||||
const clearConfigs = config
|
const clearConfigs = config
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((item) => item.trim())
|
.map((item: any) => item?.trim())
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
|
|
||||||
const configs: any = {};
|
const configs: any = {};
|
||||||
|
|
||||||
for (const item of clearConfigs) {
|
for (const item of clearConfigs) {
|
||||||
const items = item.split(':');
|
const items = item.split(':');
|
||||||
configs[items[0].trim()] = items[1].trim();
|
configs[items[0]?.trim()] = items[1]?.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
let position = data[0];
|
position = position ? formatPrompt(position) : '';
|
||||||
let negative = data[2] ? data[1] : '';
|
negative = negative ? formatPrompt(negative.split('Negative prompt: ')[1]) : '';
|
||||||
|
|
||||||
if (position.includes('Negative prompt:')) {
|
|
||||||
negative = position;
|
|
||||||
position = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
position = formatPrompt(position);
|
|
||||||
negative = formatPrompt(negative.split('Negative prompt: ')[1]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
config: configs,
|
config: configs,
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,7 @@ const ImageInfo = (parentId: string, containerId: string) => {
|
||||||
const settingsDiv = document.createElement('div') as HTMLDivElement;
|
const settingsDiv = document.createElement('div') as HTMLDivElement;
|
||||||
settingsDiv.id = containerId.replace('#', '');
|
settingsDiv.id = containerId.replace('#', '');
|
||||||
|
|
||||||
(gradioApp().querySelector(parentId) as HTMLDivElement).insertBefore(
|
(gradioApp().querySelector(parentId) as HTMLDivElement).append(settingsDiv);
|
||||||
settingsDiv,
|
|
||||||
(gradioApp().querySelector(parentId) as HTMLDivElement).firstChild,
|
|
||||||
);
|
|
||||||
|
|
||||||
createRoot(settingsDiv).render(
|
createRoot(settingsDiv).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import react from '@vitejs/plugin-react-swc';
|
import react from '@vitejs/plugin-react-swc';
|
||||||
|
import { consola } from 'consola';
|
||||||
import dotenv from 'dotenv';
|
import dotenv from 'dotenv';
|
||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import * as process from 'node:process';
|
import * as process from 'node:process';
|
||||||
|
|
@ -11,7 +12,7 @@ const isProduction = process.env.NODE_ENV === 'production';
|
||||||
const SD_HOST = process.env.SD_HOST || '127.0.0.1';
|
const SD_HOST = process.env.SD_HOST || '127.0.0.1';
|
||||||
const SD_PORT = process.env.SD_PORT || 7860;
|
const SD_PORT = process.env.SD_PORT || 7860;
|
||||||
|
|
||||||
console.log(SD_HOST, SD_PORT);
|
consola.info('Proxy:', `http://${SD_HOST}:${SD_PORT}`);
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: '/dev',
|
base: '/dev',
|
||||||
build: {
|
build: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue