mirror of https://github.com/Wox-launcher/Wox
Unify ui and wox log
This commit is contained in:
parent
1c7c9faa34
commit
7ad0a5c76f
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:chinese_font_library/chinese_font_library.dart';
|
||||
|
@ -15,15 +16,26 @@ import 'package:wox/utils/log.dart';
|
|||
import 'package:wox/utils/wox_setting_util.dart';
|
||||
import 'package:wox/utils/wox_theme_util.dart';
|
||||
import 'package:wox/utils/wox_websocket_msg_util.dart';
|
||||
import 'package:wox/utils/wox_window_util.dart';
|
||||
|
||||
void main(List<String> arguments) async {
|
||||
await initialServices(arguments);
|
||||
await initWindow();
|
||||
runApp(const MyApp());
|
||||
if (WoxWindowUtil.instance.isMultiWindow(arguments)) {
|
||||
} else {
|
||||
await initWindow();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initArgs(List<String> arguments) async {
|
||||
Logger.instance.info(const UuidV4().generate(), "Arguments: $arguments");
|
||||
if (WoxWindowUtil.instance.isMultiWindow(arguments)) {
|
||||
var parsArguments = json.decode(arguments[2]);
|
||||
Env.serverPort = parsArguments["serverPort"];
|
||||
Env.serverPid = parsArguments["serverPid"];
|
||||
Env.isDev = parsArguments["isDev"];
|
||||
return;
|
||||
}
|
||||
if (arguments.isEmpty) {
|
||||
// dev env
|
||||
Env.isDev = true;
|
||||
|
@ -47,10 +59,12 @@ Future<void> initialServices(List<String> arguments) async {
|
|||
await initArgs(arguments);
|
||||
await WoxThemeUtil.instance.loadTheme();
|
||||
await WoxSettingUtil.instance.loadSetting();
|
||||
var controller = WoxLauncherController()..startRefreshSchedule();
|
||||
await WoxWebsocketMsgUtil.instance.initialize(Uri.parse("ws://localhost:${Env.serverPort}/ws"), onMessageReceived: controller.handleWebSocketMessage);
|
||||
HeartbeatChecker().startChecking();
|
||||
Get.put(controller);
|
||||
if (!WoxWindowUtil.instance.isMultiWindow(arguments)) {
|
||||
var controller = WoxLauncherController()..startRefreshSchedule();
|
||||
await WoxWebsocketMsgUtil.instance.initialize(Uri.parse("ws://localhost:${Env.serverPort}/ws"), onMessageReceived: controller.handleWebSocketMessage);
|
||||
HeartbeatChecker().startChecking();
|
||||
Get.put(controller);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initWindow() async {
|
||||
|
@ -78,6 +92,8 @@ Future<void> initWindow() async {
|
|||
await windowManager.setMaximizable(false);
|
||||
await windowManager.setMinimizable(false);
|
||||
await windowManager.waitUntilReadyToShow(windowOptions);
|
||||
//Create Other Multi Windows
|
||||
WoxWindowUtil.instance.createWindow("setting", {});
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
|
|
|
@ -23,9 +23,11 @@ import 'package:wox/enums/wox_query_type_enum.dart';
|
|||
import 'package:wox/enums/wox_selection_type_enum.dart';
|
||||
import 'package:wox/interfaces/wox_launcher_interface.dart';
|
||||
import 'package:wox/utils/consts.dart';
|
||||
import 'package:wox/utils/env.dart';
|
||||
import 'package:wox/utils/log.dart';
|
||||
import 'package:wox/utils/wox_theme_util.dart';
|
||||
import 'package:wox/utils/wox_websocket_msg_util.dart';
|
||||
import 'package:wox/utils/wox_window_util.dart';
|
||||
|
||||
class WoxLauncherController extends GetxController implements WoxLauncherInterface {
|
||||
final _query = WoxChangeQuery.empty().obs;
|
||||
|
@ -361,6 +363,8 @@ class WoxLauncherController extends GetxController implements WoxLauncherInterfa
|
|||
final pickFilesParams = PickFilesParams.fromJson(msg.data);
|
||||
final files = await pickFiles(msg.traceId, pickFilesParams);
|
||||
responseWoxWebsocketRequest(msg, true, files);
|
||||
} else if (msg.method == "OpenSettingWindow") {
|
||||
WoxWindowUtil.instance.showWindow("setting", "WoxSetting", const Size(1280, 720));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:desktop_multi_window/desktop_multi_window.dart';
|
||||
import 'package:wox/utils/env.dart';
|
||||
|
||||
class WoxWindowUtil {
|
||||
late final Map<String, WindowController> _windowMap = {};
|
||||
late final List<int> _windowIdList = [];
|
||||
|
||||
WoxWindowUtil._privateConstructor();
|
||||
|
||||
static final WoxWindowUtil _instance = WoxWindowUtil._privateConstructor();
|
||||
|
||||
static WoxWindowUtil get instance => _instance;
|
||||
|
||||
Future<void> createWindow(String name, Map<String, dynamic> params) async {
|
||||
params["serverPort"] = Env.serverPort;
|
||||
params["serverPid"] = Env.serverPid;
|
||||
params["isDev"] = Env.isDev;
|
||||
final window = await DesktopMultiWindow.createWindow(jsonEncode(params));
|
||||
_windowMap[name] = window;
|
||||
_windowIdList.add(window.windowId);
|
||||
}
|
||||
|
||||
void showWindow(String name, String title, Size size) {
|
||||
if (_windowMap.containsKey(name) && _windowMap[name] != null) {
|
||||
_windowMap[name]
|
||||
?..setFrame(const Offset(0, 0) & size)
|
||||
..center()
|
||||
..setTitle(title)
|
||||
..resizable(false)
|
||||
..show();
|
||||
}
|
||||
}
|
||||
|
||||
bool isMultiWindow(List<String> arguments) {
|
||||
if (arguments.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
return arguments[0] == "multi_window";
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <desktop_drop/desktop_drop_plugin.h>
|
||||
#include <desktop_multi_window/desktop_multi_window_plugin.h>
|
||||
#include <flutter_acrylic/flutter_acrylic_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
|
@ -16,6 +17,9 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
|||
g_autoptr(FlPluginRegistrar) desktop_drop_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin");
|
||||
desktop_drop_plugin_register_with_registrar(desktop_drop_registrar);
|
||||
g_autoptr(FlPluginRegistrar) desktop_multi_window_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopMultiWindowPlugin");
|
||||
desktop_multi_window_plugin_register_with_registrar(desktop_multi_window_registrar);
|
||||
g_autoptr(FlPluginRegistrar) flutter_acrylic_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterAcrylicPlugin");
|
||||
flutter_acrylic_plugin_register_with_registrar(flutter_acrylic_registrar);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
desktop_drop
|
||||
desktop_multi_window
|
||||
flutter_acrylic
|
||||
screen_retriever
|
||||
url_launcher_linux
|
||||
|
|
|
@ -6,6 +6,7 @@ import FlutterMacOS
|
|||
import Foundation
|
||||
|
||||
import desktop_drop
|
||||
import desktop_multi_window
|
||||
import device_info_plus
|
||||
import macos_window_utils
|
||||
import path_provider_foundation
|
||||
|
@ -16,6 +17,7 @@ import window_manager
|
|||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin"))
|
||||
FlutterMultiWindowPlugin.register(with: registry.registrar(forPlugin: "FlutterMultiWindowPlugin"))
|
||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||
MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
PODS:
|
||||
- desktop_drop (0.0.1):
|
||||
- FlutterMacOS
|
||||
- desktop_multi_window (0.0.1):
|
||||
- FlutterMacOS
|
||||
- device_info_plus (0.0.1):
|
||||
- FlutterMacOS
|
||||
- FlutterMacOS (1.0.0)
|
||||
|
@ -20,6 +22,7 @@ PODS:
|
|||
|
||||
DEPENDENCIES:
|
||||
- desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`)
|
||||
- desktop_multi_window (from `Flutter/ephemeral/.symlinks/plugins/desktop_multi_window/macos`)
|
||||
- device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`)
|
||||
- FlutterMacOS (from `Flutter/ephemeral`)
|
||||
- macos_window_utils (from `Flutter/ephemeral/.symlinks/plugins/macos_window_utils/macos`)
|
||||
|
@ -32,6 +35,8 @@ DEPENDENCIES:
|
|||
EXTERNAL SOURCES:
|
||||
desktop_drop:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos
|
||||
desktop_multi_window:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/desktop_multi_window/macos
|
||||
device_info_plus:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos
|
||||
FlutterMacOS:
|
||||
|
@ -51,6 +56,7 @@ EXTERNAL SOURCES:
|
|||
|
||||
SPEC CHECKSUMS:
|
||||
desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898
|
||||
desktop_multi_window: 566489c048b501134f9d7fb6a2354c60a9126486
|
||||
device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f
|
||||
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
|
||||
macos_window_utils: 933f91f64805e2eb91a5bd057cf97cd097276663
|
||||
|
@ -62,4 +68,4 @@ SPEC CHECKSUMS:
|
|||
|
||||
PODFILE CHECKSUM: 16208599a12443d53889ba2270a4985981cfb204
|
||||
|
||||
COCOAPODS: 1.15.2
|
||||
COCOAPODS: 1.14.3
|
||||
|
|
|
@ -258,7 +258,7 @@
|
|||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0920;
|
||||
LastUpgradeCheck = 1510;
|
||||
LastUpgradeCheck = 1430;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
331C80D4294CF70F00263BE5 = {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1510"
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
|
|
@ -89,6 +89,14 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.4"
|
||||
desktop_multi_window:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: desktop_multi_window
|
||||
sha256: "29971186ae0790e32b156f127f9c22c5ee77bdb94b14f7cea23f2356d0c76cfc"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
device_info_plus:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -248,30 +256,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.7"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker
|
||||
sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.0.0"
|
||||
leak_tracker_flutter_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_flutter_testing
|
||||
sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
leak_tracker_testing:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: leak_tracker_testing
|
||||
sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -316,34 +300,34 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16+1"
|
||||
version: "0.12.16"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.0"
|
||||
version: "0.5.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
|
||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
version: "1.10.0"
|
||||
path:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path
|
||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
version: "1.8.3"
|
||||
path_parsing:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -669,14 +653,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "13.0.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
@ -51,6 +51,7 @@ dependencies:
|
|||
syncfusion_flutter_pdfviewer: ^24.1.43
|
||||
desktop_drop: ^0.4.4
|
||||
file_picker: ^6.1.1
|
||||
desktop_multi_window: ^0.2.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <desktop_drop/desktop_drop_plugin.h>
|
||||
#include <desktop_multi_window/desktop_multi_window_plugin.h>
|
||||
#include <flutter_acrylic/flutter_acrylic_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <syncfusion_pdfviewer_windows/syncfusion_pdfviewer_windows_plugin.h>
|
||||
|
@ -16,6 +17,8 @@
|
|||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
DesktopDropPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopDropPlugin"));
|
||||
DesktopMultiWindowPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopMultiWindowPlugin"));
|
||||
FlutterAcrylicPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterAcrylicPlugin"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
desktop_drop
|
||||
desktop_multi_window
|
||||
flutter_acrylic
|
||||
screen_retriever
|
||||
syncfusion_pdfviewer_windows
|
||||
|
|
Loading…
Reference in New Issue