diff --git a/package.json b/package.json index bc2aa5fff..a69274015 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "./gen_js_from_hbb.py > src/gen_js_from_hbb.ts && ./ts_proto.py && tsc && vite build", "preview": "vite preview" }, "devDependencies": { diff --git a/src/common.ts b/src/common.ts index 80125848b..2f1516042 100644 --- a/src/common.ts +++ b/src/common.ts @@ -33,7 +33,7 @@ export async function decompress(compressedArray: Uint8Array) { } export function translate(locale: string, text: string): string { - const lang = locale.substr(locale.length - 2).toLowerCase(); + const lang = locale.substring(locale.length - 2).toLowerCase(); let en = LANGS.en as any; let dict = (LANGS as any)[lang]; if (!dict) dict = en; diff --git a/src/gen_js_from_hbb.ts b/src/gen_js_from_hbb.ts index 2ad8407a9..1a53133bc 100644 --- a/src/gen_js_from_hbb.ts +++ b/src/gen_js_from_hbb.ts @@ -199,6 +199,12 @@ export const LANGS = { "Hostname": "主机名", "Discovered": "已发现", "install_daemon_tip": "为了开机启动,请安装系统服务。", + "Remote ID": "远程ID", + "Paste": "粘贴", + "Are you sure to close the connection?": "是否确认关闭连接?", + "Download new version": "下载新版本", + "Touch mode": "触屏模式", + "Reset canvas": "重置画布", }, it: { "Status": "Stato", @@ -393,6 +399,12 @@ export const LANGS = { "Invalid folder name": "Nome della cartella non valido", "Hostname": "Nome host", "Discovered": "Scoperto", + "Remote ID": "ID remoto", + "Paste": "Impasto", + "Are you sure to close the connection?": "Sei sicuro di chiudere la connessione?", + "Download new version": "Scarica nuova versione", + "Touch mode": "Modalità tocco", + "Reset canvas": "Ripristina tela", }, en: { "desk_tip": "Your desktop can be accessed with this ID and password.", @@ -605,6 +617,12 @@ export const LANGS = { "Invalid folder name": "Nom de dossier invalide", "Hostname": "nom d'hôte", "Discovered": "Découvert", + "Remote ID": "ID à distance", + "Paste": "Pâte", + "Are you sure to close the connection?": "Êtes-vous sûr de fermer la connexion?", + "Download new version": "Télécharger la nouvelle version", + "Touch mode": "Mode tactile", + "Reset canvas": "Réinitialiser le canevas", }, } diff --git a/src/globals.js b/src/globals.js index ca3001d19..9b06848b5 100644 --- a/src/globals.js +++ b/src/globals.js @@ -235,10 +235,22 @@ window.getByName = (name, arg) => { return JSON.stringify(v); } +function getPeersForDart() { + const peers = []; + for (const [key, value] of Object.entries(getPeers())) { + if (!key) continue; + const tm = value['tm']; + const info = values['info']; + if (!tm || !info) continue; + peers.push([tm, id, info]); + } + return peers.sort().reverse().map(x => x.slice(1)); +} + function _getByName(name, arg) { switch (name) { case 'peers': - return localStorage.getItem('peers') || '[]'; + return getPeersForDart(); case 'remote_id': return localStorage.getItem('remote-id'); case 'remember': @@ -257,6 +269,7 @@ function _getByName(name, arg) { case 'image_quality': return curConn.getImageQuality(); case 'translate': + const arg = JSON.parse(arg); return translate(arg.locale, arg.text); case 'peer_option': return curConn.getOption(arg);