diff --git a/html/config.html b/html/config.html
index dbe6757..5c91d9f 100644
--- a/html/config.html
+++ b/html/config.html
@@ -112,7 +112,7 @@
-
+
diff --git a/lib/engine/ollama.js b/lib/engine/ollama.js
index b605189..6bfa31c 100644
--- a/lib/engine/ollama.js
+++ b/lib/engine/ollama.js
@@ -7,7 +7,8 @@ const apiurl = 'http://127.0.0.1:11434/';
async function translate(query,engine,win,controller) {
- const appid = engine.url;
+ //console.log(engine);
+ let appid = engine.url;
const key = engine.model;
const name = engine.name;
let result = {};
@@ -25,6 +26,8 @@ async function translate(query,engine,win,controller) {
if (!utils.isUrl(appid)) {
appid = apiurl
}
+
+ //console.log(appid,key);
//大模型反应较慢,先加一个提醒让用户等待
win.webContents.send('update-text', {"origintext":origin,"resulttext":"等待大模型["+key+"]翻译中......","done":false});
const reqdata = {
@@ -63,14 +66,14 @@ async function translate(query,engine,win,controller) {
result.done = true;
}
win.webContents.send('update-text', result);
- console.log(result);
+ //console.log(result);
});
parser.on('error', error => {
console.error('Error parsing JSON', error);
});
})
.catch(error => {
- //console.error('Error during request:', error);
+ //console.error('Error during request:', JSON.stringify(error));
result = {"origintext":origin,"resulttext":error.address+':'+error.port+' '+ error.syscall + ' ' + error.code,"done":true};
win.webContents.send('update-text', result);
console.log(result);
diff --git a/main.js b/main.js
index a1d287e..20fdb79 100644
--- a/main.js
+++ b/main.js
@@ -231,7 +231,7 @@ app.whenReady().then(() => {
}
}
}else{
- console.log("无需隐入,当前状态:",cfgobj.wininto);
+ //console.log("无需隐入,当前状态:",cfgobj.wininto);
}
});
diff --git a/package.json b/package.json
index 12162f8..610b4be 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "wodict",
- "version": "0.1.5",
+ "version": "0.1.7",
"description": "A translator based on Electron",
"main": "main.js",
"scripts": {
diff --git a/renderer.js b/renderer.js
index 632b367..41e9144 100644
--- a/renderer.js
+++ b/renderer.js
@@ -8,7 +8,10 @@ const audiosource = document.getElementById('audiosource')
const btnaudio = document.getElementById('btnaudio')
window.electronAPI.onUpdateText((value) => {
console.log("renderer.js onUpdateText:",value,value.done);
- origintext.value = value.origintext.toString();
+ if (value.origintext && value.origintext.toString() != ''){
+ origintext.value = value.origintext.toString();
+ }
+
resulttext.value = value.resulttext.toString();
if (value.voice && value.voice.toString() != '') {
audiosource.setAttribute('src', value.voice.toString());
diff --git a/test/httpurl.js b/test/httpurl.js
index e5029a5..721dd2e 100644
--- a/test/httpurl.js
+++ b/test/httpurl.js
@@ -9,9 +9,7 @@ function isUrl(s) {
}
console.log(isUrl("http://www.example.com")); // true
- console.log(isUrl("https://example.com/test")); // true
- console.log(isUrl("example.com")); // true
- console.log(isUrl("not a url")); // false
console.log(isUrl("http://127.0.0.1:11434/")); //true
console.log(isUrl("http://localhost:11434/")); //true
+ console.log(isUrl("")); //false
\ No newline at end of file