From 51ad81e48f8239ed394df74ec8679ef9f2a353e4 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sun, 17 Apr 2022 20:36:54 +0800 Subject: [PATCH] only show login for customized self host --- lib/main.dart | 2 +- lib/pages/connection_page.dart | 55 ++++++++++++++++++++++---------- lib/pages/scan_page.dart | 1 + web/assets/firebase-analytics.js | 2 ++ web/assets/firebase-app.js | 2 ++ web/index.html | 4 +-- 6 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 web/assets/firebase-analytics.js create mode 100644 web/assets/firebase-app.js diff --git a/lib/main.dart b/lib/main.dart index 6f9f6b8a6..7a6205d13 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -40,7 +40,7 @@ class App extends StatelessWidget { primarySwatch: Colors.blue, visualDensity: VisualDensity.adaptivePlatformDensity, ), - home: isWeb ? WebHomePage() : HomePage(), + home: !isAndroid ? WebHomePage() : HomePage(), navigatorObservers: [ FirebaseAnalyticsObserver(analytics: analytics), ], diff --git a/lib/pages/connection_page.dart b/lib/pages/connection_page.dart index 96341ed02..d40fb019f 100644 --- a/lib/pages/connection_page.dart +++ b/lib/pages/connection_page.dart @@ -8,6 +8,7 @@ import '../models/model.dart'; import 'home_page.dart'; import 'remote_page.dart'; import 'settings_page.dart'; +import 'scan_page.dart'; class ConnectionPage extends StatefulWidget implements PageShape { ConnectionPage({Key? key}) : super(key: key); @@ -287,22 +288,36 @@ class _WebMenuState extends State { return PopupMenuButton( icon: Icon(Icons.more_vert), itemBuilder: (context) { - return [ - PopupMenuItem( - child: Text(translate('ID/Relay Server')), - value: "server", - ), - PopupMenuItem( - child: Text(username == null - ? translate("Login") - : translate("Logout") + ' ($username)'), - value: "login", - ), - PopupMenuItem( - child: Text(translate('About') + ' RustDesk'), - value: "about", - ) - ]; + return (isIOS + ? [ + PopupMenuItem( + child: Icon(Icons.qr_code_scanner, color: Colors.black), + value: "scan", + ) + ] + : >[]) + + [ + PopupMenuItem( + child: Text(translate('ID/Relay Server')), + value: "server", + ) + ] + + (getUrl().contains('admin.rustdesk.com') + ? >[] + : [ + PopupMenuItem( + child: Text(username == null + ? translate("Login") + : translate("Logout") + ' ($username)'), + value: "login", + ) + ]) + + [ + PopupMenuItem( + child: Text(translate('About') + ' RustDesk'), + value: "about", + ) + ]; }, onSelected: (value) { if (value == 'server') { @@ -318,6 +333,14 @@ class _WebMenuState extends State { logout(); } } + if (value == 'scan') { + Navigator.push( + context, + MaterialPageRoute( + builder: (BuildContext context) => ScanPage(), + ), + ); + } }); } } diff --git a/lib/pages/scan_page.dart b/lib/pages/scan_page.dart index 52e1f1bf4..ab17c67b8 100644 --- a/lib/pages/scan_page.dart +++ b/lib/pages/scan_page.dart @@ -234,6 +234,7 @@ void showServerSettingsWithValue( if (api != api0) FFI.setByName( 'option', '{"name": "api-server", "value": "$api"}'); + FFI.ffiModel.updateUser(); close(); } }, diff --git a/web/assets/firebase-analytics.js b/web/assets/firebase-analytics.js new file mode 100644 index 000000000..9b9a02b09 --- /dev/null +++ b/web/assets/firebase-analytics.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("@firebase/app")):"function"==typeof define&&define.amd?define(["@firebase/app"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).firebase)}(this,function(mt){"use strict";try{!function(){function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(mt),r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;na[0]&&t[1]=e.length?void 0:e)&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){for(var n=0,r=t.length,i=e.length;n"})):"Error",e=this.serviceName+": "+e+" ("+o+").";return new f(o,e,i)},n);function n(e,t,n){this.service=e,this.serviceName=t,this.errors=n}var y=/\{\$([^}]+)}/g,b=1e3,w=2,I=144e5,_=.5;function E(e,t,n){void 0===n&&(n=w);n=(t=void 0===t?b:t)*Math.pow(n,e),e=Math.round(_*n*(Math.random()-.5)*2);return Math.min(I,n+e)}var T=(S.prototype.setInstantiationMode=function(e){return this.instantiationMode=e,this},S.prototype.setMultipleInstances=function(e){return this.multipleInstances=e,this},S.prototype.setServiceProps=function(e){return this.serviceProps=e,this},S.prototype.setInstanceCreatedCallback=function(e){return this.onInstanceCreated=e,this},S);function S(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}function C(n){return new Promise(function(e,t){n.onsuccess=function(){e(n.result)},n.onerror=function(){t(n.error)}})}function O(n,r,i){var o,e=new Promise(function(e,t){C(o=n[r].apply(n,i)).then(e,t)});return e.request=o,e}function N(e,n,t){t.forEach(function(t){Object.defineProperty(e.prototype,t,{get:function(){return this[n][t]},set:function(e){this[n][t]=e}})})}function D(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return O(this[n],e,arguments)})})}function P(t,n,r,e){e.forEach(function(e){e in r.prototype&&(t.prototype[e]=function(){return this[n][e].apply(this[n],arguments)})})}function A(e,r,t,n){n.forEach(function(n){n in t.prototype&&(e.prototype[n]=function(){return e=this[r],(t=O(e,n,arguments)).then(function(e){if(e)return new k(e,t.request)});var e,t})})}function x(e){this._index=e}function k(e,t){this._cursor=e,this._request=t}function j(e){this._store=e}function L(n){this._tx=n,this.complete=new Promise(function(e,t){n.oncomplete=function(){e()},n.onerror=function(){t(n.error)},n.onabort=function(){t(n.error)}})}function R(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new L(n)}function F(e){this._db=e}N(x,"_index",["name","keyPath","multiEntry","unique"]),D(x,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),A(x,"_index",IDBIndex,["openCursor","openKeyCursor"]),N(k,"_cursor",["direction","key","primaryKey","value"]),D(k,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach(function(n){n in IDBCursor.prototype&&(k.prototype[n]=function(){var t=this,e=arguments;return Promise.resolve().then(function(){return t._cursor[n].apply(t._cursor,e),C(t._request).then(function(e){if(e)return new k(e,t._request)})})})}),j.prototype.createIndex=function(){return new x(this._store.createIndex.apply(this._store,arguments))},j.prototype.index=function(){return new x(this._store.index.apply(this._store,arguments))},N(j,"_store",["name","keyPath","indexNames","autoIncrement"]),D(j,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),A(j,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),P(j,"_store",IDBObjectStore,["deleteIndex"]),L.prototype.objectStore=function(){return new j(this._tx.objectStore.apply(this._tx,arguments))},N(L,"_tx",["objectStoreNames","mode"]),P(L,"_tx",IDBTransaction,["abort"]),R.prototype.createObjectStore=function(){return new j(this._db.createObjectStore.apply(this._db,arguments))},N(R,"_db",["name","version","objectStoreNames"]),P(R,"_db",IDBDatabase,["deleteObjectStore","close"]),F.prototype.transaction=function(){return new L(this._db.transaction.apply(this._db,arguments))},N(F,"_db",["name","version","objectStoreNames"]),P(F,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach(function(i){[j,x].forEach(function(e){i in e.prototype&&(e.prototype[i.replace("open","iterate")]=function(){var e=(n=arguments,Array.prototype.slice.call(n)),t=e[e.length-1],n=this._store||this._index,r=n[i].apply(n,e.slice(0,-1));r.onsuccess=function(){t(r.result)}})})}),[x,j].forEach(function(e){e.prototype.getAll||(e.prototype.getAll=function(e,n){var r=this,i=[];return new Promise(function(t){r.iterateCursor(e,function(e){e?(i.push(e.value),void 0===n||i.length!=n?e.continue():t(i)):t(i)})})})});var M="0.4.32",B=1e4,H="w:"+M,q="FIS_v2",V="https://firebaseinstallations.googleapis.com/v1",G=36e5,K=((Re={})["missing-app-config-values"]='Missing App configuration value: "{$valueName}"',Re["not-registered"]="Firebase Installation is not registered.",Re["installation-not-found"]="Firebase Installation not found.",Re["request-failed"]='{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',Re["app-offline"]="Could not process request. Application offline.",Re["delete-pending-registration"]="Can't delete installation while there is a pending registration request.",Re),U=new m("installations","Installations",K);function W(e){return e instanceof f&&e.code.includes("request-failed")}function $(e){e=e.projectId;return V+"/projects/"+e+"/installations"}function z(e){return{token:e.token,requestStatus:2,expiresIn:(e=e.expiresIn,Number(e.replace("s","000"))),creationTime:Date.now()}}function J(n,r){return p(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return[4,r.json()];case 1:return t=e.sent(),t=t.error,[2,U.create("request-failed",{requestName:n,serverCode:t.code,serverMessage:t.message,serverStatus:t.status})]}})})}function Y(e){e=e.apiKey;return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}function X(e,t){t=t.refreshToken,e=Y(e);return e.append("Authorization",q+" "+t),e}function Z(n){return p(this,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return[4,n()];case 1:return 500<=(t=e.sent()).status&&t.status<600?[2,n()]:[2,t]}})})}function Q(t){return new Promise(function(e){setTimeout(e,t)})}function ee(e){return btoa(String.fromCharCode.apply(String,u([],function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||0a[0]&&t[1]=e.length?void 0:e)&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||0"})):"Error",e=this.serviceName+": "+e+" ("+o+").";return new c(o,e,i)},v);function v(e,t,n){this.service=e,this.serviceName=t,this.errors=n}var m=/\{\$([^}]+)}/g;function y(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function g(e,t){t=new b(e,t);return t.subscribe.bind(t)}var b=(I.prototype.next=function(t){this.forEachObserver(function(e){e.next(t)})},I.prototype.error=function(t){this.forEachObserver(function(e){e.error(t)}),this.close(t)},I.prototype.complete=function(){this.forEachObserver(function(e){e.complete()}),this.close()},I.prototype.subscribe=function(e,t,n){var r,i=this;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");void 0===(r=function(e,t){if("object"!=typeof e||null===e)return!1;for(var n=0,r=t;n=(null!=o?o:e.logLevel)&&a({level:R[t].toLowerCase(),message:i,args:n,type:e.name})}}(n[e])}var H=((H={})["no-app"]="No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",H["bad-app-name"]="Illegal App name: '{$appName}",H["duplicate-app"]="Firebase App named '{$appName}' already exists",H["app-deleted"]="Firebase App named '{$appName}' already deleted",H["invalid-app-argument"]="firebase.{$appName}() takes either no argument or a Firebase App instance.",H["invalid-log-argument"]="First argument to `onLog` must be null or a function.",H),V=new d("app","Firebase",H),B="@firebase/app",M="[DEFAULT]",U=((H={})[B]="fire-core",H["@firebase/analytics"]="fire-analytics",H["@firebase/app-check"]="fire-app-check",H["@firebase/auth"]="fire-auth",H["@firebase/database"]="fire-rtdb",H["@firebase/functions"]="fire-fn",H["@firebase/installations"]="fire-iid",H["@firebase/messaging"]="fire-fcm",H["@firebase/performance"]="fire-perf",H["@firebase/remote-config"]="fire-rc",H["@firebase/storage"]="fire-gcs",H["@firebase/firestore"]="fire-fst",H["fire-js"]="fire-js",H["firebase-wrapper"]="fire-js-all",H),W=new z("@firebase/app"),G=(Object.defineProperty($.prototype,"automaticDataCollectionEnabled",{get:function(){return this.checkDestroyed_(),this.automaticDataCollectionEnabled_},set:function(e){this.checkDestroyed_(),this.automaticDataCollectionEnabled_=e},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"name",{get:function(){return this.checkDestroyed_(),this.name_},enumerable:!1,configurable:!0}),Object.defineProperty($.prototype,"options",{get:function(){return this.checkDestroyed_(),this.options_},enumerable:!1,configurable:!0}),$.prototype.delete=function(){var t=this;return new Promise(function(e){t.checkDestroyed_(),e()}).then(function(){return t.firebase_.INTERNAL.removeApp(t.name_),Promise.all(t.container.getProviders().map(function(e){return e.delete()}))}).then(function(){t.isDeleted_=!0})},$.prototype._getService=function(e,t){void 0===t&&(t=M),this.checkDestroyed_();var n=this.container.getProvider(e);return n.isInitialized()||"EXPLICIT"!==(null===(e=n.getComponent())||void 0===e?void 0:e.instantiationMode)||n.initialize(),n.getImmediate({identifier:t})},$.prototype._removeServiceInstance=function(e,t){void 0===t&&(t=M),this.container.getProvider(e).clearInstance(t)},$.prototype._addComponent=function(t){try{this.container.addComponent(t)}catch(e){W.debug("Component "+t.name+" failed to register with FirebaseApp "+this.name,e)}},$.prototype._addOrOverwriteComponent=function(e){this.container.addOrOverwriteComponent(e)},$.prototype.toJSON=function(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}},$.prototype.checkDestroyed_=function(){if(this.isDeleted_)throw V.create("app-deleted",{appName:this.name_})},$);function $(e,t,n){var r=this;this.firebase_=n,this.isDeleted_=!1,this.name_=t.name,this.automaticDataCollectionEnabled_=t.automaticDataCollectionEnabled||!1,this.options_=h(void 0,e),this.container=new S(t.name),this._addComponent(new O("app",function(){return r},"PUBLIC")),this.firebase_.INTERNAL.components.forEach(function(e){return r._addComponent(e)})}G.prototype.name&&G.prototype.options||G.prototype.delete||console.log("dc");var K="8.10.1";function Y(a){var s={},l=new Map,c={__esModule:!0,initializeApp:function(e,t){void 0===t&&(t={});"object"==typeof t&&null!==t||(t={name:t});var n=t;void 0===n.name&&(n.name=M);t=n.name;if("string"!=typeof t||!t)throw V.create("bad-app-name",{appName:String(t)});if(y(s,t))throw V.create("duplicate-app",{appName:t});n=new a(e,n,c);return s[t]=n},app:u,registerVersion:function(e,t,n){var r=null!==(i=U[e])&&void 0!==i?i:e;n&&(r+="-"+n);var i=r.match(/\s|\//),e=t.match(/\s|\//);i||e?(n=['Unable to register library "'+r+'" with version "'+t+'":'],i&&n.push('library name "'+r+'" contains illegal characters (whitespace or "/")'),i&&e&&n.push("and"),e&&n.push('version name "'+t+'" contains illegal characters (whitespace or "/")'),W.warn(n.join(" "))):o(new O(r+"-version",function(){return{library:r,version:t}},"VERSION"))},setLogLevel:T,onLog:function(e,t){if(null!==e&&"function"!=typeof e)throw V.create("invalid-log-argument");x(e,t)},apps:null,SDK_VERSION:K,INTERNAL:{registerComponent:o,removeApp:function(e){delete s[e]},components:l,useAsService:function(e,t){return"serverAuth"!==t?t:null}}};function u(e){if(!y(s,e=e||M))throw V.create("no-app",{appName:e});return s[e]}function o(n){var e,r=n.name;if(l.has(r))return W.debug("There were multiple attempts to register component "+r+"."),"PUBLIC"===n.type?c[r]:null;l.set(r,n),"PUBLIC"===n.type&&(e=function(e){if("function"!=typeof(e=void 0===e?u():e)[r])throw V.create("invalid-app-argument",{appName:r});return e[r]()},void 0!==n.serviceProps&&h(e,n.serviceProps),c[r]=e,a.prototype[r]=function(){for(var e=[],t=0;t - - + +