get image
This commit is contained in:
parent
95b5de3f39
commit
da4b878859
57199
example.json
57199
example.json
File diff suppressed because it is too large
Load Diff
151
pal.ini
151
pal.ini
@ -1,151 +0,0 @@
|
||||
[/Script/Pal.PalGameWorldSettings]
|
||||
|
||||
OptionSettings=(
|
||||
Difficulty=None,
|
||||
DayTimeSpeedRate=1.000000,
|
||||
NightTimeSpeedRate=1.000000,
|
||||
ExpRate=1.000000,
|
||||
PalCaptureRate=1.000000,
|
||||
PalSpawnNumRate=1.000000,
|
||||
PalDamageRateAttack=1.000000,
|
||||
PalDamageRateDefense=1.000000,
|
||||
PlayerDamageRateAttack=1.000000,
|
||||
PlayerDamageRateDefense=1.000000,
|
||||
PlayerStomachDecreaceRate=1.000000,
|
||||
PlayerStaminaDecreaceRate=1.000000,
|
||||
PlayerAutoHPRegeneRate=1.000000,
|
||||
PlayerAutoHpRegeneRateInSleep=1.000000,
|
||||
PalStomachDecreaceRate=0.500000,
|
||||
PalStaminaDecreaceRate=1.000000,
|
||||
PalAutoHPRegeneRate=1.000000,
|
||||
PalAutoHpRegeneRateInSleep=1.000000,
|
||||
BuildObjectDamageRate=1.000000,
|
||||
BuildObjectDeteriorationDamageRate=1.000000,
|
||||
CollectionDropRate=1.000000,
|
||||
CollectionObjectHpRate=1.000000,
|
||||
CollectionObjectRespawnSpeedRate=1.000000,
|
||||
EnemyDropItemRate=1.000000,
|
||||
DeathPenalty=None,
|
||||
bEnablePlayerToPlayerDamage=True,
|
||||
bEnableFriendlyFire=True,
|
||||
bEnableInvaderEnemy=True,
|
||||
|
||||
; 否会发生袭击事件
|
||||
|
||||
bActiveUNKO=False,
|
||||
|
||||
; ??
|
||||
|
||||
bEnableAimAssistPad=True,
|
||||
|
||||
; 启用瞄准辅助手柄
|
||||
|
||||
bEnableAimAssistKeyboard=False,
|
||||
|
||||
; 准星开启
|
||||
|
||||
DropItemMaxNum=3000,
|
||||
|
||||
; 掉落物品最大数量
|
||||
|
||||
DropItemMaxNum_UNKO=100,
|
||||
|
||||
; 掉落物品最大数量_UNKO
|
||||
|
||||
BaseCampMaxNum=128,
|
||||
|
||||
; 大本营最大数
|
||||
|
||||
BaseCampWorkerMaxNum=15,
|
||||
|
||||
; 大本营工人最多人数
|
||||
|
||||
DropItemAliveMaxHours=1.000000,
|
||||
|
||||
; 掉落物品存在最大时长
|
||||
|
||||
bAutoResetGuildNoOnlinePlayers=False,
|
||||
|
||||
; 自动重置没有在线玩家的公会
|
||||
|
||||
AutoResetGuildTimeNoOnlinePlayers=72.000000,
|
||||
|
||||
; 无在线玩家时自动重置生成时间
|
||||
|
||||
GuildPlayerMaxNum=20,
|
||||
|
||||
; 公会玩家最大数量
|
||||
|
||||
PalEggDefaultHatchingTime=0.000000,
|
||||
|
||||
; 帕鲁蛋默认孵化时间
|
||||
|
||||
WorkSpeedRate=1.000000,
|
||||
|
||||
; 工作速率
|
||||
|
||||
bIsMultiplay=False,
|
||||
|
||||
; 多人游戏
|
||||
|
||||
bIsPvP=True,
|
||||
|
||||
; PvP
|
||||
|
||||
bCanPickupOtherGuildDeathPenaltyDrop=False,
|
||||
|
||||
; 可拾取其他公会的死亡掉落物
|
||||
|
||||
bEnableNonLoginPenalty=True,
|
||||
|
||||
; 启用不登录惩罚
|
||||
|
||||
bEnableFastTravel=True,
|
||||
|
||||
; 启用快速旅行
|
||||
|
||||
bIsStartLocationSelectByMap=True,
|
||||
|
||||
; 通过地图选择起始位置
|
||||
|
||||
bExistPlayerAfterLogout=False,
|
||||
|
||||
; 注销后玩家仍然存在
|
||||
|
||||
bEnableDefenseOtherGuildPlayer=False,
|
||||
|
||||
; 启用防御其他公会玩家功能
|
||||
|
||||
CoopPlayerMaxNum=4,
|
||||
|
||||
; 合作玩家最大人数
|
||||
|
||||
ServerPlayerMaxNum=32,
|
||||
|
||||
; 服务器玩家最大人数
|
||||
|
||||
ServerName="Gangsters",
|
||||
|
||||
; 服务器名称
|
||||
|
||||
ServerDescription="Gangsters",
|
||||
|
||||
; 服务器描述
|
||||
|
||||
PublicPort=8888,
|
||||
|
||||
; 服务器ip
|
||||
|
||||
RCONEnabled=False,
|
||||
|
||||
; 启用 RCON
|
||||
|
||||
RCONPort=25575,
|
||||
|
||||
; RCON端口
|
||||
|
||||
bUseAuth=True,
|
||||
|
||||
; 使用授权
|
||||
|
||||
BanListURL="https://api.palworldgame.com/api/banlist.txt")
|
26
src/biz/getimg.ts
Normal file
26
src/biz/getimg.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { RequestHandler, Txt2ImgRequest } from "../type/request";
|
||||
import { txt2imgAPIformatJSON, txt2imgAPIformatExtraData } from "../comfyJson/txt2img";
|
||||
import axios from "axios";
|
||||
import { selectNodeFromApiJSONbyID } from "../utils/editComfyJson";
|
||||
import WebSocket from "ws";
|
||||
import { readJSONFile, saveJSONFile } from "../utils/jsonReader";
|
||||
const baseUrl = "http://47.108.92.176:20000";
|
||||
const baseWsUrl = "ws://47.108.92.176:20000";
|
||||
// const baseUrl = "http://localhost:8188";
|
||||
// const baseWsUrl = "ws://localhost:8188";
|
||||
axios.defaults.baseURL = baseUrl;
|
||||
const GetImageHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) => {
|
||||
console.log(ctx.method);
|
||||
ctx.set('Access-Control-Allow-Origin', '*')
|
||||
ctx.set('Access-Control-Allow-Headers', 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With')
|
||||
ctx.set('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
|
||||
if (ctx.method == 'OPTIONS') {
|
||||
ctx.body = 200;
|
||||
return;
|
||||
}
|
||||
const data = await readJSONFile("../../data.json");
|
||||
ctx.body = {
|
||||
data: data
|
||||
}
|
||||
}
|
||||
export default GetImageHandler;
|
@ -8,7 +8,7 @@ const baseWsUrl = "ws://47.108.92.176:20000";
|
||||
// const baseUrl = "http://localhost:8188";
|
||||
// const baseWsUrl = "ws://localhost:8188";
|
||||
axios.defaults.baseURL = baseUrl;
|
||||
const Txt23DHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx) => {
|
||||
const Txt23DHandler: RequestHandler<any, any> = async (ctx) => {
|
||||
ctx.set('Access-Control-Allow-Origin', '*')
|
||||
ctx.set('Access-Control-Allow-Headers', 'Content-Type,Content-Length,Authorization,Accept,X-Requested-With')
|
||||
ctx.set('Access-Control-Allow-Methods', 'PUT,POST,GET,DELETE,OPTIONS')
|
||||
@ -17,7 +17,7 @@ const Txt23DHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx) => {
|
||||
return;
|
||||
}
|
||||
const requestBody = ctx.request.body;
|
||||
const { prompt, loraDetail, loraModel } = requestBody;
|
||||
const { prompt, url } = requestBody;
|
||||
const inputNode = selectNodeFromApiJSONbyID(txt23dApiFormatJSON, "33");
|
||||
inputNode.inputs.string = prompt;
|
||||
ctx.body = {
|
||||
|
@ -3,6 +3,7 @@ import { txt2imgAPIformatJSON, txt2imgAPIformatExtraData } from "../comfyJson/tx
|
||||
import axios from "axios";
|
||||
import { selectNodeFromApiJSONbyID } from "../utils/editComfyJson";
|
||||
import WebSocket from "ws";
|
||||
import { readJSONFile, saveJSONFile } from "../utils/jsonReader";
|
||||
const baseUrl = "http://47.108.92.176:20000";
|
||||
const baseWsUrl = "ws://47.108.92.176:20000";
|
||||
// const baseUrl = "http://localhost:8188";
|
||||
@ -53,6 +54,8 @@ const Txt2ImgHandler: RequestHandler<Txt2ImgRequest, any> = async (ctx, next) =>
|
||||
}
|
||||
if (data.node === '94') {
|
||||
console.log(data.output);
|
||||
// 综合使用示例
|
||||
|
||||
resolve({ prompt: temp, url: baseUrl + '/view?filename=' + data.output.images[0].filename });
|
||||
}
|
||||
}else if (type === "executing") {
|
||||
|
@ -3,6 +3,7 @@ import { upScaleAPIFormatJSON } from "../comfyJson/upscale";
|
||||
import axios from "axios";
|
||||
import { selectNodeFromApiJSONbyID } from "../utils/editComfyJson";
|
||||
import WebSocket from "ws";
|
||||
import { readJSONFile, saveJSONFile } from "../utils/jsonReader";
|
||||
const baseUrl = "http://47.108.92.176:20000";
|
||||
const baseWsUrl = "ws://47.108.92.176:20000";
|
||||
// const baseUrl = "http://localhost:8188";
|
||||
@ -41,14 +42,21 @@ const UpscaleHandler: RequestHandler<any ,any> = async (ctx) => {
|
||||
if (type === "executed") {
|
||||
console.log(data.output);
|
||||
if (data.node === '47') {
|
||||
const filePath = './data.json';
|
||||
|
||||
readJSONFile(filePath)
|
||||
.then((data: any) => {
|
||||
console.log('读取的JSON数据:', data);
|
||||
// 修改对象
|
||||
data.push({ prompt: prompt, url: baseUrl + '/view?filename=' + data.output.images[0].filename, like: 0,index: data.length })
|
||||
// 保存回JSON文件
|
||||
return saveJSONFile(filePath, data);
|
||||
})
|
||||
|
||||
resolve(data.output.images[0].filename)
|
||||
}
|
||||
}
|
||||
} else if(event.data instanceof ArrayBuffer) {
|
||||
const blob = new Blob([event.data])// arraybuffer to blob
|
||||
let a = new FileReader();
|
||||
a.onload = function (e) { console.log('image/png;base64,'+ e.target!.result) }
|
||||
a.readAsDataURL(blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ const txt2imgAPIformatJSON = {
|
||||
},
|
||||
"86": {
|
||||
"inputs": {
|
||||
"system_prompt": "你是一个懂宋词分析的古诗词专家,我会给你一句宋词。请你分析古诗中的意象,按照重要性排序,并参照文件列出只英文的意象prompt。注意只需要英文,请控制输出长度在256token以内。",
|
||||
"system_prompt": "你是一个懂宋词分析的古诗词专家,我会给你一句宋词。请你分析古诗中的意象,按照重要性排序,只列出重要的即可,并参照文件列出只英文的意象。注意只需要英文,请控制输出长度在256token以内只需要输出纯文本格式的回复:意象1,意象2,意象3....。不要回复额外内容,不要回复额外内容,不需要回复诗歌解析。",
|
||||
"user_prompt": [
|
||||
"33",
|
||||
0
|
||||
@ -200,7 +200,7 @@ const txt2imgAPIformatJSON = {
|
||||
"is_tools_in_sys_prompt": "disable",
|
||||
"is_locked": "disable",
|
||||
"main_brain": "enable",
|
||||
"max_length": 2048,
|
||||
"max_length": 30,
|
||||
"file_content": [
|
||||
"89",
|
||||
0
|
||||
@ -221,7 +221,7 @@ const txt2imgAPIformatJSON = {
|
||||
},
|
||||
"89": {
|
||||
"inputs": {
|
||||
"is_enable": true,
|
||||
"is_enable": false,
|
||||
"file1": [
|
||||
"87",
|
||||
0
|
||||
|
@ -1,3 +1,4 @@
|
||||
import GetImageHandler from "../biz/getimg";
|
||||
import Txt23DHandler from "../biz/txt23d";
|
||||
import Txt2ImgHandler from "../biz/txt2img";
|
||||
import UpscaleHandler from "../biz/upScale";
|
||||
@ -13,6 +14,8 @@ const InitHandler = () => {
|
||||
RegistHandler("options", "/txt23d", Txt23DHandler);
|
||||
RegistHandler("options", "/upscale", UpscaleHandler);
|
||||
RegistHandler("post", "/upscale", UpscaleHandler);
|
||||
RegistHandler("options", "/get", GetImageHandler);
|
||||
RegistHandler("post", "/get", GetImageHandler);
|
||||
}
|
||||
|
||||
|
||||
|
34
src/utils/jsonReader.ts
Normal file
34
src/utils/jsonReader.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import fs from 'fs';
|
||||
// 读取JSON文件并解析成对象
|
||||
function readJSONFile(filePath:string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(filePath, 'utf8', (err:any, data:any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
try {
|
||||
const jsonObject = JSON.parse(data);
|
||||
resolve(jsonObject);
|
||||
} catch (jsonErr) {
|
||||
reject(jsonErr);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 将对象保存回JSON文件
|
||||
function saveJSONFile(filePath: string, data: any) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const jsonData = JSON.stringify(data, null, 4); // 格式化输出JSON字符串
|
||||
fs.writeFile(filePath, jsonData, 'utf8', (err:any) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(void 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export { readJSONFile, saveJSONFile };
|
86
test.html
86
test.html
@ -1,86 +0,0 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>测试页面</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>测试页面</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<script>
|
||||
import {
|
||||
app
|
||||
} from "../../scripts/app.js";
|
||||
import {
|
||||
api
|
||||
} from "../../scripts/api.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "efficiency.previewfix",
|
||||
lastExecutedNodeId: null,
|
||||
blobsToRevoke: [], // Array to accumulate blob URLs for revocation
|
||||
debug: false,
|
||||
|
||||
log(...args) {
|
||||
if (this.debug) console.log(...args);
|
||||
},
|
||||
|
||||
error(...args) {
|
||||
if (this.debug) console.error(...args);
|
||||
},
|
||||
|
||||
shouldRevokeBlobForNode(nodeId) {
|
||||
const node = app.graph.getNodeById(nodeId);
|
||||
|
||||
const validTitles = [
|
||||
"KSampler (Efficient)",
|
||||
"KSampler Adv. (Efficient)",
|
||||
"KSampler SDXL (Eff.)"
|
||||
];
|
||||
|
||||
if (!node || !validTitles.includes(node.title)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const getValue = name => ((node.widgets || []).find(w => w.name === name) || {}).value;
|
||||
return getValue("preview_method") !== "none" && getValue("vae_decode").includes("true");
|
||||
},
|
||||
|
||||
setup() {
|
||||
// Intercepting blob creation to store and immediately revoke the last blob URL
|
||||
const originalCreateObjectURL = URL.createObjectURL;
|
||||
URL.createObjectURL = (object) => {
|
||||
const blobURL = originalCreateObjectURL(object);
|
||||
if (blobURL.startsWith('blob:')) {
|
||||
this.log("[BlobURLLogger] Blob URL created:", blobURL);
|
||||
|
||||
// If the current node meets the criteria, add the blob URL to the revocation list
|
||||
if (this.shouldRevokeBlobForNode(this.lastExecutedNodeId)) {
|
||||
this.blobsToRevoke.push(blobURL);
|
||||
}
|
||||
}
|
||||
return blobURL;
|
||||
};
|
||||
|
||||
// Listen to the start of the node execution to revoke all accumulated blob URLs
|
||||
api.addEventListener("executing", ({
|
||||
detail
|
||||
}) => {
|
||||
if (this.lastExecutedNodeId !== detail || detail === null) {
|
||||
this.blobsToRevoke.forEach(blob => {
|
||||
this.log("[BlobURLLogger] Revoking Blob URL:", blob);
|
||||
URL.revokeObjectURL(blob);
|
||||
});
|
||||
this.blobsToRevoke = []; // Clear the list after revoking all blobs
|
||||
}
|
||||
|
||||
// Update the last executed node ID
|
||||
this.lastExecutedNodeId = detail;
|
||||
});
|
||||
|
||||
this.log("[BlobURLLogger] Hook attached.");
|
||||
},
|
||||
});
|
||||
</script>
|
2
test.js
2
test.js
@ -1,2 +0,0 @@
|
||||
[/Script/Pal.PalGameWorldSettings]
|
||||
OptionSettings = (Difficulty = None, DayTimeSpeedRate = 1.000000, NightTimeSpeedRate = 1.000000, ExpRate = 1.000000, PalCaptureRate = 1.000000, PalSpawnNumRate = 1.000000, PalDamageRateAttack = 1.000000, PalDamageRateDefense = 1.000000, PlayerDamageRateAttack = 1.000000, PlayerDamageRateDefense = 1.000000, PlayerStomachDecreaceRate = 1.000000, PlayerStaminaDecreaceRate = 1.000000, PlayerAutoHPRegeneRate = 1.000000, PlayerAutoHpRegeneRateInSleep = 1.000000, PalStomachDecreaceRate = 0.500000, PalStaminaDecreaceRate = 1.000000, PalAutoHPRegeneRate = 1.000000, PalAutoHpRegeneRateInSleep = 1.000000, BuildObjectDamageRate = 1.000000, BuildObjectDeteriorationDamageRate = 1.000000, CollectionDropRate = 1.000000, CollectionObjectHpRate = 1.000000, CollectionObjectRespawnSpeedRate = 1.000000, EnemyDropItemRate = 1.000000, DeathPenalty = None, bEnablePlayerToPlayerDamage = True, bEnableFriendlyFire = True, bEnableInvaderEnemy = True, bActiveUNKO = False, bEnableAimAssistPad = True, bEnableAimAssistKeyboard = False, DropItemMaxNum = 3000, DropItemMaxNum_UNKO = 100, BaseCampMaxNum = 128, BaseCampWorkerMaxNum = 15, DropItemAliveMaxHours = 1.000000, bAutoResetGuildNoOnlinePlayers = False, AutoResetGuildTimeNoOnlinePlayers = 72.000000, GuildPlayerMaxNum = 20, PalEggDefaultHatchingTime = 0.000000, WorkSpeedRate = 1.000000, bIsMultiplay = False, bIsPvP = True, bCanPickupOtherGuildDeathPenaltyDrop = False, bEnableNonLoginPenalty = True, bEnableFastTravel = True, bIsStartLocationSelectByMap = True, bExistPlayerAfterLogout = False, bEnableDefenseOtherGuildPlayer = False, CoopPlayerMaxNum = 4, ServerPlayerMaxNum = 32, ServerName = "Gangsters", ServerDescription = "Gangsters", PublicPort = 8888, RCONEnabled = False, RCONPort = 25575, bUseAuth = True, BanListURL = "https://api.palworldgame.com/api/banlist.txt")
|
Loading…
x
Reference in New Issue
Block a user