more web api
This commit is contained in:
parent
3d77365edc
commit
16218a731b
@ -202,6 +202,6 @@ Color str2color(String str, [alpha = 0xFF]) {
|
||||
return Color((hash & 0xFF7FFF) | (alpha << 24));
|
||||
}
|
||||
|
||||
bool isAndroid;
|
||||
bool isIOS;
|
||||
bool isWeb;
|
||||
bool isAndroid = false;
|
||||
bool isIOS = false;
|
||||
bool isWeb = false;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'dart:async';
|
||||
import 'common.dart';
|
||||
@ -342,13 +341,13 @@ void showServer(BuildContext context) {
|
||||
}
|
||||
|
||||
Future<Null> showAbout(BuildContext context) async {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
var version = await FFI.getVersion();
|
||||
showAlertDialog(
|
||||
context,
|
||||
(setState) => Tuple3(
|
||||
null,
|
||||
Wrap(direction: Axis.vertical, spacing: 12, children: [
|
||||
Text('Version: ${packageInfo.version}'),
|
||||
Text('Version: $version'),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
const url = 'https://rustdesk.com/';
|
||||
|
@ -611,6 +611,10 @@ class FFI {
|
||||
static void setByName(String name, [String value = '']) {
|
||||
PlatformFFI.setByName(name, value);
|
||||
}
|
||||
|
||||
static Future<String> getVersion() async {
|
||||
return await PlatformFFI.getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
class Peer {
|
||||
@ -690,32 +694,11 @@ void initializeCursorAndCanvas() async {
|
||||
FFI.canvasModel.update(xCanvas, yCanvas, scale);
|
||||
}
|
||||
|
||||
final langs = <String, Map<String, String>>{
|
||||
'cn': <String, String>{
|
||||
'Remote ID': '远程ID',
|
||||
'Paste': '粘贴',
|
||||
'Are you sure to close the connection?': '是否确认关闭连接?',
|
||||
'Download new version': '下载新版本',
|
||||
'Touch mode': '触屏模式',
|
||||
'Reset canvas': '重置画布',
|
||||
},
|
||||
'en': <String, String>{}
|
||||
};
|
||||
|
||||
final bool isCn = localeName.startsWith('zh') &&
|
||||
(localeName.endsWith('CN') || localeName.endsWith('SG'));
|
||||
|
||||
String translate(String name) {
|
||||
if (name.startsWith('Failed') && name.contains(':')) {
|
||||
return name.split(': ').map((x) => translate(x)).join(': ');
|
||||
}
|
||||
final tmp = isCn ? langs['cn'] : langs['en'];
|
||||
final v = tmp[name];
|
||||
if (v == null) {
|
||||
var a = 'translate';
|
||||
var b = '{"locale": "$localeName", "text": "$name"}';
|
||||
return FFI.getByName(a, b);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
var a = 'translate';
|
||||
var b = '{"locale": "$localeName", "text": "$name"}';
|
||||
return FFI.getByName(a, b);
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import 'dart:ffi';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:device_info/device_info.dart';
|
||||
import "common.dart";
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'common.dart';
|
||||
|
||||
class RgbaFrame extends Struct {
|
||||
@Uint32()
|
||||
@ -38,6 +39,11 @@ class PlatformFFI {
|
||||
return Uint8List.sublistView(ref.data.asTypedList(ref.len));
|
||||
}
|
||||
|
||||
static Future<String> getVersion() async {
|
||||
PackageInfo packageInfo = await PackageInfo.fromPlatform();
|
||||
return packageInfo.version;
|
||||
}
|
||||
|
||||
static String getByName(String name, [String arg = '']) {
|
||||
if (_getByName == null) return '';
|
||||
var a = name.toNativeUtf8();
|
||||
|
@ -78,7 +78,8 @@ class _RemotePageState extends State<RemotePage> {
|
||||
return _bottom >= 100;
|
||||
}
|
||||
|
||||
void interval() {
|
||||
// crash on web before widgit initiated.
|
||||
void intervalUnsafe() {
|
||||
var v = MediaQuery.of(context).viewInsets.bottom;
|
||||
if (v != _bottom) {
|
||||
resetTool();
|
||||
@ -92,6 +93,12 @@ class _RemotePageState extends State<RemotePage> {
|
||||
FFI.ffiModel.update(widget.id, context, handleMsgbox);
|
||||
}
|
||||
|
||||
void interval() {
|
||||
try {
|
||||
intervalUnsafe();
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
void handleMsgbox(Map<String, dynamic> evt, String id) {
|
||||
var type = evt['type'];
|
||||
var title = evt['title'];
|
||||
|
@ -10,6 +10,10 @@ class PlatformFFI {
|
||||
// return Uint8List.sublistView(ref.data.asTypedList(ref.len));
|
||||
}
|
||||
|
||||
static Future<String> getVersion() async {
|
||||
return '';
|
||||
}
|
||||
|
||||
static String getByName(String name, [String arg = '']) {
|
||||
return js.context.callMethod('getByName', [name, arg]);
|
||||
}
|
||||
@ -20,6 +24,7 @@ class PlatformFFI {
|
||||
|
||||
static Future<Null> init() async {
|
||||
isWeb = true;
|
||||
js.context.callMethod('init');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@
|
||||
<title>RustDesk</title>
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<script src="ogvjs/ogv.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index.d55bf9f9.js"></script>
|
||||
<link rel="modulepreload" href="/assets/vendor.fd8ceed9.js">
|
||||
</head>
|
||||
<body>
|
||||
<!-- This script installs service_worker.js to provide PWA functionality to
|
||||
|
Loading…
x
Reference in New Issue
Block a user