AbdullahAlfaraj / Auto-Photoshop-StableDiffusion-Plugin

A user-friendly plug-in that makes it easy to generate stable diffusion images inside Photoshop using either Automatic or ComfyUI as a backend.
MIT License
6.81k stars 508 forks source link

prompts library not work #403

Open XiaoXiaoJiangYun opened 1 year ago

XiaoXiaoJiangYun commented 1 year ago

always temple, can not save or load

XiaoXiaoJiangYun commented 1 year ago

I have create the json file.

XiaoXiaoJiangYun commented 1 year ago

Error: Could not find an entry of 'plugin-data:/prompt_shortcut.json'

XiaoXiaoJiangYun commented 1 year ago

I have fix this problem:

  1. \utility\sdapi\python_replacement.js,function loadPromptShortcut,add create a new json file:

    async function loadPromptShortcut(file_name) {
    const json_file_name = file_name
    
    const folder = await fs.getDataFolder()
    
    try {
        const json_entry = await folder.getEntry(json_file_name)
        if (json_entry) {
            // await json_entry.read()
    
            const json = JSON.parse(
                await json_entry.read({
                    format: storage.formats.utf8,
                })
            )
            return json
        }
    } catch (e) {
        const file = await folder.createFile('prompt_shortcut.json', {type: storage.types.file, overwrite: true});
        if (file.isFile) {
            await file.write('{}', {append: false});
            data = {};
            return file;
        }
        console.warn(e)
        return {}
    }
    }
  2. index.js,use the dialog_box.js instead of bundle:
    const dialog_box = require('./dialog_box')
    const {
    ...
    // dialog_box,
    ...
    } = require('./typescripts/dist/bundle')