mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-03-15 04:23:17 +08:00
windows single instance
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,3 +47,4 @@ app.*.map.json
|
||||
|
||||
l10n_errors.txt
|
||||
pubspec.lock
|
||||
/dist/
|
||||
@@ -29,12 +29,22 @@ import 'package:proxypin/ui/mobile/mobile.dart';
|
||||
import 'package:proxypin/utils/navigator.dart';
|
||||
import 'package:proxypin/utils/platform.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:windows_single_instance/windows_single_instance.dart';
|
||||
|
||||
import 'network/util/logger.dart';
|
||||
|
||||
///主入口
|
||||
///@author wanghongen
|
||||
void main(List<String> args) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
if (Platform.isWindows) {
|
||||
await WindowsSingleInstance.ensureSingleInstance([], "ProxyPin", onSecondWindow: (args) {
|
||||
logger.d('WindowsSingleInstance onSecondWindow $args');
|
||||
windowManager.show();
|
||||
});
|
||||
}
|
||||
|
||||
var instance = AppConfiguration.instance;
|
||||
//多窗口
|
||||
if (args.firstOrNull == 'multi_window') {
|
||||
|
||||
@@ -18,6 +18,7 @@ dependencies:
|
||||
logger: ^2.5.0
|
||||
date_format: ^2.0.9
|
||||
window_manager: ^0.4.3
|
||||
windows_single_instance: ^1.0.1
|
||||
desktop_multi_window:
|
||||
git:
|
||||
url: https://gitee.com/wanghongenpin/flutter-plugins.git
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
#include <win32audio/win32audio_plugin_c_api.h>
|
||||
#include <window_manager/window_manager_plugin.h>
|
||||
#include <windows_single_instance/windows_single_instance_plugin.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
DesktopMultiWindowPluginRegisterWithRegistrar(
|
||||
@@ -38,4 +39,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("Win32audioPluginCApi"));
|
||||
WindowManagerPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("WindowManagerPlugin"));
|
||||
WindowsSingleInstancePluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("WindowsSingleInstancePlugin"));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
||||
url_launcher_windows
|
||||
win32audio
|
||||
window_manager
|
||||
windows_single_instance
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
AppId={{APP_ID}}
|
||||
AppVersion={{APP_VERSION}}
|
||||
AppName={{DISPLAY_NAME}}
|
||||
AppPublisher={{PUBLISHER_NAME}}
|
||||
AppPublisher={{PUBLISHER}}
|
||||
AppPublisherURL={{PUBLISHER_URL}}
|
||||
AppSupportURL={{PUBLISHER_URL}}
|
||||
AppUpdatesURL={{PUBLISHER_URL}}
|
||||
@@ -26,8 +26,9 @@ CloseApplications=force
|
||||
{% endfor %}
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: {% if CREATE_DESKTOP_ICON != true %}unchecked{% else %}checkedonce{% endif %}
|
||||
Name: "launchAtStartup"; Description: "{cm:AutoStartProgram,{{DISPLAY_NAME}}}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: {% if LAUNCH_AT_STARTUP != true %}unchecked{% else %}checkedonce{% endif %}
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: {% if CREATE_DESKTOP_ICON != true %}unchecked{% else %}checkablealone{% endif %}
|
||||
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: "{{SOURCE_DIR}}\\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
|
||||
@@ -35,6 +36,6 @@ Source: "{{SOURCE_DIR}}\\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdi
|
||||
[Icons]
|
||||
Name: "{autoprograms}\\{{DISPLAY_NAME}}"; Filename: "{app}\\{{EXECUTABLE_NAME}}"
|
||||
Name: "{autodesktop}\\{{DISPLAY_NAME}}"; Filename: "{app}\\{{EXECUTABLE_NAME}}"; Tasks: desktopicon
|
||||
Name: "{userstartup}\\{{DISPLAY_NAME}}"; Filename: "{app}\\{{EXECUTABLE_NAME}}"; WorkingDir: "{app}"; Tasks: launchAtStartup
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\\{{EXECUTABLE_NAME}}"; Description: "{cm:LaunchProgram,{{DISPLAY_NAME}}}"; Flags: nowait postinstall skipifsilent
|
||||
|
||||
@@ -4,6 +4,7 @@ publisher_url: https://github.com/wanghongenpin/proxypin
|
||||
display_name: ProxyPin
|
||||
create_desktop_icon: true
|
||||
install_dir_name: "{autopf64}\\ProxyPin"
|
||||
setup_icon_file: windows\runner\resources\app_icon.ico
|
||||
locales:
|
||||
- en
|
||||
- zh
|
||||
|
||||
Reference in New Issue
Block a user