fix on getByname

This commit is contained in:
rustdesk 2022-01-31 00:48:04 +08:00
parent a75bef9791
commit 1e13484c26
2 changed files with 13 additions and 9 deletions

View File

@ -424,8 +424,8 @@ export default class Connection {
} }
} }
getRemember(): any { getRemember(): Boolean {
return this._options["remember"]; return this._options["remember"] || false;
} }
setRemember(v: Boolean) { setRemember(v: Boolean) {
@ -568,7 +568,7 @@ export default class Connection {
} }
getImageQuality() { getImageQuality() {
return this.getOption("image-quality"); return this.getOption('image-quality');
} }
getImageQualityEnum( getImageQualityEnum(

View File

@ -229,14 +229,18 @@ window.setByName = (name, value) => {
} }
window.getByName = (name, arg) => { window.getByName = (name, arg) => {
try { let v = _getByName(name, arg);
arg = JSON.parse(arg); if (typeof v == 'string' || v instanceof String) return v;
} catch (e) { } if (v == undefined || v == null) return '';
return JSON.stringify(v);
}
function _getByName(name, arg) {
switch (name) { switch (name) {
case 'peers': case 'peers':
return localStorage.getItem('peers') || '[]'; return localStorage.getItem('peers') || '[]';
case 'remote_id': case 'remote_id':
return localStorage.getItem('remote-id') || ''; return localStorage.getItem('remote-id');
case 'remember': case 'remember':
return curConn.getRemember(); return curConn.getRemember();
case 'event': case 'event':
@ -247,7 +251,7 @@ window.getByName = (name, arg) => {
} }
break; break;
case 'toggle_option': case 'toggle_option':
return curConn.getOption(arg); return curConn.getOption(arg) || false;
case 'option': case 'option':
return localStorage.getItem(arg); return localStorage.getItem(arg);
case 'image_quality': case 'image_quality':