diff --git a/appcast.json b/appcast.json index 408edbc..41d99e3 100644 --- a/appcast.json +++ b/appcast.json @@ -2,10 +2,10 @@ "identifier": "me.vacuity.chat.gptranslate", "versions": [ { - "version": "1.3.9", - "desc": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/tag/1.3.9", - "sha256": "011f4224ec2a4845c2a1539b51e60009291f37c3b4124a4308f1e276e2124c7e", - "url": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/download/1.3.9/bob-plugin-vac-gptranslate.bobplugin", + "version": "1.4.0", + "desc": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/tag/1.4.0", + "sha256": "abb8a9bddd7b800a767ae72560dac072354c51b3d77305aaec9f3f01d52aecc2", + "url": "https://github.com/vacuityv/bob-plugin-vac-gptranslate/releases/download/1.4.0/bob-plugin-vac-gptranslate.bobplugin", "minBobVersion": "0.5.0" } ] diff --git a/info.json b/info.json index dc9dd2e..0015d05 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "identifier": "me.vacuity.chat.gptranslate", - "version": "1.3.9", + "version": "1.4.0", "category": "translate", "name": "GPTranslate", "summary": "调用chatgpt/gemini/claude实现翻译功能", @@ -24,15 +24,15 @@ "identifier": "modelType", "type": "menu", "title": "模型选择", - "defaultValue": "gpt3.5", + "defaultValue": "gpt-4o-mini", "menuValues": [ { - "title": "gpt3.5", - "value": "gpt3.5" + "title": "gpt-4o-mini", + "value": "gpt-4o-mini" }, { - "title": "gpt4.0", - "value": "gpt4.0" + "title": "gpt3.5", + "value": "gpt3.5" }, { "title": "gpt4o", diff --git a/main.js b/main.js index 73e4fb6..4ef5b90 100644 --- a/main.js +++ b/main.js @@ -34,6 +34,8 @@ var langMap = { }; var usaHttp = "https://chat.vacuity.me/vac-chat-api/chat/ext/loginTranslate"; var usaWss = "wss://chat.vacuity.me/vac-chat-api/stream/chat/chat"; +// var usaHttp = "http://127.0.0.1:8081/vac-chat-api/chat/ext/loginTranslate"; +// var usaWss = "ws://127.0.0.1:8081/vac-chat-api/stream/chat/chat"; var socket = ''; var readyState = false; @@ -51,9 +53,11 @@ function translate(query, completion) { var env = $env; if (typeof env !== "undefined") { appVersion = $env.appVersion; - if (appVersion >= '1.8.0') { - streamSupFlag = true; + if (compareVersions(appVersion, '1.8.0') >= 0) { + streamSupFlag = true } + } else { + $log.info('get env error, process as old version'); } } catch (error) { $log.info('get env error, process as old version'); @@ -63,10 +67,9 @@ function translate(query, completion) { $log.info('useStreamFlag'); $log.info(useStreamFlag); - if (streamSupFlag && useStreamFlag === 'y') { // newTrans(query, completion); - $log.info("vac-body" + initReqBody(query)); + $log.info("vac-body-stream" + initReqBody(query)); websocketTrans(query, completion); } else { oldTranslate(query, completion); @@ -222,3 +225,18 @@ function initReqBody(query) { }; } +function compareVersions(version1, version2) { + const v1Parts = version1.split('.').map(Number); + const v2Parts = version2.split('.').map(Number); + + for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { + const v1Part = v1Parts[i] || 0; + const v2Part = v2Parts[i] || 0; + + if (v1Part > v2Part) return 1; + if (v1Part < v2Part) return -1; + } + + return 0; +} +