Using the backend API for getting the client version
This commit is contained in:
parent
b5b06164a7
commit
474ad7af01
2 changed files with 15 additions and 13 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
export type NativeClientVersionInfo = {
|
||||||
|
version: string,
|
||||||
|
|
||||||
|
os_architecture: string,
|
||||||
|
os_platform: string,
|
||||||
|
os_platform_version: string
|
||||||
|
}
|
||||||
|
|
||||||
export interface NativeClientBackend {
|
export interface NativeClientBackend {
|
||||||
openChangeLog() : void;
|
openChangeLog() : void;
|
||||||
openClientUpdater() : void;
|
openClientUpdater() : void;
|
||||||
|
@ -6,4 +14,6 @@ export interface NativeClientBackend {
|
||||||
showDeveloperOptions() : boolean;
|
showDeveloperOptions() : boolean;
|
||||||
openDeveloperTools() : void;
|
openDeveloperTools() : void;
|
||||||
reloadWindow() : void;
|
reloadWindow() : void;
|
||||||
|
|
||||||
|
getVersionInfo() : NativeClientVersionInfo;
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import {DisconnectReason} from "../ConnectionHandler";
|
||||||
import {tr} from "../i18n/localize";
|
import {tr} from "../i18n/localize";
|
||||||
import {ConnectParameters} from "tc-shared/ui/modal/connect/Controller";
|
import {ConnectParameters} from "tc-shared/ui/modal/connect/Controller";
|
||||||
import {LogCategory, logWarn} from "tc-shared/log";
|
import {LogCategory, logWarn} from "tc-shared/log";
|
||||||
|
import {getBackend} from "tc-shared/backend";
|
||||||
|
|
||||||
export interface HandshakeIdentityHandler {
|
export interface HandshakeIdentityHandler {
|
||||||
connection: AbstractServerConnection;
|
connection: AbstractServerConnection;
|
||||||
|
@ -95,30 +96,21 @@ export class HandshakeHandler {
|
||||||
};
|
};
|
||||||
|
|
||||||
if(__build.target === "client") {
|
if(__build.target === "client") {
|
||||||
const _native = window["native"];
|
const versionsInfo = getBackend("native").getVersionInfo();
|
||||||
let version;
|
data.client_version = "TeaClient " + versionsInfo.version;
|
||||||
try {
|
|
||||||
version = await _native.client_version();
|
|
||||||
} catch (error) {
|
|
||||||
logWarn(LogCategory.GENERAL, tr("Failed to fetch native client version: %o"), error);
|
|
||||||
version = "?.?.?";
|
|
||||||
}
|
|
||||||
|
|
||||||
data.client_version = "TeaClient " + version;
|
|
||||||
|
|
||||||
const os = __non_webpack_require__("os");
|
|
||||||
const arch_mapping = {
|
const arch_mapping = {
|
||||||
"x32": "32bit",
|
"x32": "32bit",
|
||||||
"x64": "64bit"
|
"x64": "64bit"
|
||||||
};
|
};
|
||||||
|
|
||||||
data.client_version += " " + (arch_mapping[os.arch()] || os.arch());
|
data.client_version += " " + (arch_mapping[versionsInfo.os_architecture] || versionsInfo.os_architecture);
|
||||||
|
|
||||||
const os_mapping = {
|
const os_mapping = {
|
||||||
"win32": "Windows",
|
"win32": "Windows",
|
||||||
"linux": "Linux"
|
"linux": "Linux"
|
||||||
};
|
};
|
||||||
data.client_platform = (os_mapping[os.platform()] || os.platform());
|
data.client_platform = (os_mapping[versionsInfo.os_platform] || versionsInfo.os_platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handshakeImpl.fillClientInitData(data);
|
this.handshakeImpl.fillClientInitData(data);
|
||||||
|
|
Loading…
Add table
Reference in a new issue