Auto-Photoshop-StableDiffusion-Plugin icon indicating copy to clipboard operation
Auto-Photoshop-StableDiffusion-Plugin copied to clipboard

prompts library not work

Open XiaoXiaoJiangYun opened this issue 1 year ago • 3 comments

always temple, can not save or load

XiaoXiaoJiangYun avatar Nov 10 '23 03:11 XiaoXiaoJiangYun

I have create the json file.

XiaoXiaoJiangYun avatar Nov 10 '23 03:11 XiaoXiaoJiangYun

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

XiaoXiaoJiangYun avatar Nov 10 '23 06:11 XiaoXiaoJiangYun

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 {}
    }
}
  1. index.js,use the dialog_box.js instead of bundle:
const dialog_box = require('./dialog_box')
const {
...
    // dialog_box,
...
} = require('./typescripts/dist/bundle')

XiaoXiaoJiangYun avatar Nov 10 '23 08:11 XiaoXiaoJiangYun