👍️[Update] Model : tauri -> python のデータ部分をbase64でencodeするように修正
This commit is contained in:
@@ -73,13 +73,5 @@ def splitList(lst:list, split_count:int, to_shuffle:bool=False):
|
||||
split_lists.append(sub_list)
|
||||
return split_lists
|
||||
|
||||
def encodeUtf8(data:str) -> dict:
|
||||
data = {i: byte for i, byte in enumerate(data.encode('UTF-8'))}
|
||||
return data
|
||||
|
||||
def decodeUtf8(data:dict) -> str:
|
||||
data = bytes(data.values()).decode("UTF-8")
|
||||
return data
|
||||
|
||||
def printLog(log:str, data:Any=None) -> None:
|
||||
print(json.dumps({"status":348, "log":log, "data":str(data)}), flush=True)
|
||||
@@ -5,7 +5,7 @@ from subprocess import Popen
|
||||
from threading import Thread
|
||||
from config import config
|
||||
from model import model
|
||||
from utils import getKeyByValue, isUniqueStrings, decodeUtf8, encodeUtf8, printLog
|
||||
from utils import getKeyByValue, isUniqueStrings, printLog
|
||||
|
||||
# Common
|
||||
class DownloadSoftwareProgressBar:
|
||||
@@ -289,7 +289,7 @@ class ChatMessage:
|
||||
|
||||
def send(self, data):
|
||||
id = data["id"]
|
||||
message = decodeUtf8(data["message"])
|
||||
message = data["message"]
|
||||
if len(message) > 0:
|
||||
# addSentMessageLog(message)
|
||||
translation = ""
|
||||
@@ -329,8 +329,6 @@ class ChatMessage:
|
||||
translation = f" ({translation})"
|
||||
model.logger.info(f"[SENT] {message}{translation}")
|
||||
|
||||
message = encodeUtf8(message)
|
||||
translation = encodeUtf8(translation)
|
||||
return {"status":200,
|
||||
"result":{
|
||||
"id":id,
|
||||
|
||||
@@ -3,7 +3,8 @@ import json
|
||||
import time
|
||||
from config import config
|
||||
import webui_controller as controller
|
||||
from utils import printLog, encodeUtf8
|
||||
from utils import printLog
|
||||
import base64
|
||||
|
||||
config_mapping = {
|
||||
"/config/version": "VERSION",
|
||||
@@ -288,6 +289,8 @@ def main():
|
||||
if received_data:
|
||||
endpoint = received_data.get("endpoint", None)
|
||||
data = received_data.get("data", None)
|
||||
if data is not None:
|
||||
data = json.loads(base64.b64decode(data).decode('utf-8'))
|
||||
|
||||
with open('process.log', 'a') as f:
|
||||
f.write(f"received_data : endpoint: {endpoint}, data:{data}\n")
|
||||
@@ -367,7 +370,7 @@ if __name__ == "__main__":
|
||||
|
||||
match endpoint:
|
||||
case "/controller/callback_messagebox_send":
|
||||
data = {"id":"123456", "message":encodeUtf8("テスト")}
|
||||
data = {"id":"123456", "message":"テスト"}
|
||||
case "/controller/set_your_language_and_country":
|
||||
data = {"language": "English", "country": "Hong Kong"}
|
||||
case "/controller/set_target_language_and_country":
|
||||
|
||||
Reference in New Issue
Block a user