mirror of
https://github.com/EasyTier/astral.git
synced 2025-05-19 10:30:24 +00:00
feat: 添加窗口标题并优化Windows应用配置
- 在`windowconfiguration.dart`中添加窗口标题"Astral"并确保窗口管理器初始化 - 在`runner.exe.manifest`中添加UTF-8编码、长路径支持和SegmentHeap堆类型配置 - 在`Runner.rc`中更新应用描述、内部名称、原始文件名和产品名称为"Astral" - 在`main.cpp`中实现单实例应用逻辑并更新窗口标题为"Astral"
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
Future<void> setupWindow() async {
|
||||
await windowManager.ensureInitialized();
|
||||
WindowOptions windowOptions = const WindowOptions(
|
||||
size: Size(850, 520),
|
||||
minimumSize: Size(300, 300),
|
||||
@@ -9,6 +10,7 @@ Future<void> setupWindow() async {
|
||||
backgroundColor: Colors.transparent,
|
||||
skipTaskbar: false,
|
||||
titleBarStyle: TitleBarStyle.hidden, // 隐藏标题栏
|
||||
title: "Astral", // 添加窗口标题
|
||||
);
|
||||
|
||||
await windowManager.waitUntilReadyToShow(windowOptions, () async {
|
||||
|
||||
+150
-150
File diff suppressed because it is too large
Load Diff
@@ -90,12 +90,12 @@ BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "com.example" "\0"
|
||||
VALUE "FileDescription", "fltier" "\0"
|
||||
VALUE "FileDescription", "Astral" "\0"
|
||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||
VALUE "InternalName", "fltier" "\0"
|
||||
VALUE "InternalName", "Astral" "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0"
|
||||
VALUE "OriginalFilename", "fltier.exe" "\0"
|
||||
VALUE "ProductName", "fltier" "\0"
|
||||
VALUE "OriginalFilename", "Astral.exe" "\0"
|
||||
VALUE "ProductName", "Astral" "\0"
|
||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||
END
|
||||
END
|
||||
|
||||
+33
-3
@@ -1,12 +1,42 @@
|
||||
#include <flutter/dart_project.h>
|
||||
#include <flutter/dart_project.h>
|
||||
#include <flutter/flutter_view_controller.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "flutter_window.h"
|
||||
#include "utils.h"
|
||||
|
||||
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) {
|
||||
const int bufferSize = 256;
|
||||
wchar_t windowTitle[bufferSize];
|
||||
|
||||
if (GetWindowTextW(hwnd, windowTitle, bufferSize)) {
|
||||
if (_wcsicmp(windowTitle, L"Astral") == 0) {
|
||||
*((HWND*)lParam) = hwnd;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
_In_ wchar_t *command_line, _In_ int show_command) {
|
||||
HANDLE hMutex = CreateMutexW(NULL, TRUE, L"AstralAppSingleInstanceMutex");
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||
HWND hWnd = NULL;
|
||||
EnumWindows(EnumWindowsProc, (LPARAM)&hWnd);
|
||||
|
||||
if (hWnd != NULL) {
|
||||
if (IsIconic(hWnd)) {
|
||||
ShowWindow(hWnd, SW_RESTORE);
|
||||
}
|
||||
SetForegroundWindow(hWnd);
|
||||
}
|
||||
CloseHandle(hMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Attach to console when present (e.g., 'flutter run') or create a
|
||||
// new console when running with a debugger.
|
||||
if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) {
|
||||
@@ -27,7 +57,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
if (!window.Create(L"fltier", origin, size)) {
|
||||
if (!window.Create(L"Astral", origin, size)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
window.SetQuitOnClose(true);
|
||||
@@ -38,6 +68,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
::DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
::CoUninitialize();
|
||||
CloseHandle(hMutex);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
|
||||
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
|
||||
<heapType xmlns="http://schemas.microsoft.com/SMI/2020/WindowsSettings">SegmentHeap</heapType>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
|
||||
Reference in New Issue
Block a user