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