feat: 发布v5.3.0正式版本,完善跨平台适配与功能优化
本次更新包含多项核心改进: 1. 新增统一跨平台导航扩展,替换原有GoRouter调用,适配鸿蒙平台路由逻辑 2. 重构状态初始化逻辑,使用Future.microtask避免BuildContext异常 3. 完善Linux桌面端支持,添加桌面文件、AppData配置与WSL构建脚本 4. 修复鸿蒙平台动画渲染异常问题,移除平台特判逻辑 5. 优化NFC配对扫描参数,精简不必要的配置项 6. 更新依赖版本与项目版本号 7. 修复Drift数据库缓存问题,移除冗余的表检测逻辑 8. 添加路由观察者日志,优化鸿蒙端路由调试体验 9. 完善签到与文章发布后的用户数据刷新逻辑 10. 删除冗余的子模块与日志文件,清理项目结构
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
// ============================================================
|
||||
// 闲言APP (WordsLeisure) — main.cc
|
||||
// 创建时间: 2026-04-20
|
||||
// 更新时间: 2026-05-18
|
||||
// 作用: Linux平台应用入口
|
||||
// 上次更新: 添加标准注释头
|
||||
// ============================================================
|
||||
|
||||
#include "my_application.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
// ============================================================
|
||||
// 闲言APP (WordsLeisure) — my_application.cc
|
||||
// 创建时间: 2026-04-20
|
||||
// 更新时间: 2026-05-18
|
||||
// 作用: Linux平台GTK应用主类实现
|
||||
// 上次更新: 完善窗口标题/暗色主题/Wayland适配/桌面集成
|
||||
// ============================================================
|
||||
|
||||
#include "my_application.h"
|
||||
|
||||
#include <flutter_linux/flutter_linux.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
#include <gdk/gdkwayland.h>
|
||||
#endif
|
||||
|
||||
#include "flutter/generated_plugin_registrant.h"
|
||||
|
||||
@@ -14,25 +25,16 @@ struct _MyApplication {
|
||||
|
||||
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
||||
|
||||
// Called when first Flutter frame received.
|
||||
static void first_frame_cb(MyApplication* self, FlView *view)
|
||||
{
|
||||
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
|
||||
}
|
||||
|
||||
// Implements GApplication::activate.
|
||||
static void my_application_activate(GApplication* application) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
GtkWindow* window =
|
||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||
|
||||
// Use a header bar when running in GNOME as this is the common style used
|
||||
// by applications and is the setup most users will be using (e.g. Ubuntu
|
||||
// desktop).
|
||||
// If running on X and not using GNOME then just use a traditional title bar
|
||||
// in case the window manager does more exotic layout, e.g. tiling.
|
||||
// If running on Wayland assume the header bar will work (may need changing
|
||||
// if future cases occur).
|
||||
gboolean use_header_bar = TRUE;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen* screen = gtk_window_get_screen(window);
|
||||
@@ -43,31 +45,52 @@ static void my_application_activate(GApplication* application) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
GdkDisplay* display = gdk_display_get_default();
|
||||
if (GDK_IS_WAYLAND_DISPLAY(display)) {
|
||||
use_header_bar = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (use_header_bar) {
|
||||
GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new());
|
||||
gtk_widget_show(GTK_WIDGET(header_bar));
|
||||
gtk_header_bar_set_title(header_bar, "xianyan");
|
||||
gtk_header_bar_set_title(header_bar, "闲言");
|
||||
gtk_header_bar_set_subtitle(header_bar, "文字阅读更纯粹");
|
||||
gtk_header_bar_set_show_close_button(header_bar, TRUE);
|
||||
gtk_window_set_titlebar(window, GTK_WIDGET(header_bar));
|
||||
} else {
|
||||
gtk_window_set_title(window, "xianyan");
|
||||
gtk_window_set_title(window, "闲言");
|
||||
}
|
||||
|
||||
gtk_window_set_default_size(window, 1280, 720);
|
||||
gtk_window_set_position(window, GTK_WIN_POS_CENTER);
|
||||
|
||||
GdkGeometry hints;
|
||||
hints.min_width = 360;
|
||||
hints.min_height = 640;
|
||||
gtk_window_set_geometry_hints(window, nullptr, &hints, GDK_HINT_MIN_SIZE);
|
||||
|
||||
g_autoptr(GtkCssProvider*) provider = gtk_css_provider_new();
|
||||
gtk_css_provider_load_from_data(provider,
|
||||
"window { background-color: #000000; }"
|
||||
"headerbar { background-color: #1a1a1a; color: #ffffff; }",
|
||||
-1, nullptr);
|
||||
gtk_style_context_add_provider_for_screen(
|
||||
gtk_window_get_screen(window),
|
||||
GTK_STYLE_PROVIDER(provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
g_autoptr(FlDartProject) project = fl_dart_project_new();
|
||||
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
|
||||
|
||||
FlView* view = fl_view_new(project);
|
||||
GdkRGBA background_color;
|
||||
// Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
|
||||
gdk_rgba_parse(&background_color, "#000000");
|
||||
fl_view_set_background_color(view, &background_color);
|
||||
gtk_widget_show(GTK_WIDGET(view));
|
||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
|
||||
|
||||
// Show the window when Flutter renders.
|
||||
// Requires the view to be realized so we can start rendering.
|
||||
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
|
||||
gtk_widget_realize(GTK_WIDGET(view));
|
||||
|
||||
@@ -76,10 +99,8 @@ static void my_application_activate(GApplication* application) {
|
||||
gtk_widget_grab_focus(GTK_WIDGET(view));
|
||||
}
|
||||
|
||||
// Implements GApplication::local_command_line.
|
||||
static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) {
|
||||
MyApplication* self = MY_APPLICATION(application);
|
||||
// Strip out the first argument as it is the binary name.
|
||||
self->dart_entrypoint_arguments = g_strdupv(*arguments + 1);
|
||||
|
||||
g_autoptr(GError) error = nullptr;
|
||||
@@ -95,25 +116,19 @@ static gboolean my_application_local_command_line(GApplication* application, gch
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Implements GApplication::startup.
|
||||
static void my_application_startup(GApplication* application) {
|
||||
//MyApplication* self = MY_APPLICATION(object);
|
||||
|
||||
// Perform any actions required at application startup.
|
||||
|
||||
G_APPLICATION_CLASS(my_application_parent_class)->startup(application);
|
||||
|
||||
g_object_set(gtk_settings_get_default(),
|
||||
"gtk-application-prefer-dark-theme", TRUE,
|
||||
"gtk-icon-theme-name", "Adwaita",
|
||||
nullptr);
|
||||
}
|
||||
|
||||
// Implements GApplication::shutdown.
|
||||
static void my_application_shutdown(GApplication* application) {
|
||||
//MyApplication* self = MY_APPLICATION(object);
|
||||
|
||||
// Perform any actions required at application shutdown.
|
||||
|
||||
G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application);
|
||||
}
|
||||
|
||||
// Implements GObject::dispose.
|
||||
static void my_application_dispose(GObject* object) {
|
||||
MyApplication* self = MY_APPLICATION(object);
|
||||
g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev);
|
||||
@@ -131,10 +146,6 @@ static void my_application_class_init(MyApplicationClass* klass) {
|
||||
static void my_application_init(MyApplication* self) {}
|
||||
|
||||
MyApplication* my_application_new() {
|
||||
// Set the program name to the application ID, which helps various systems
|
||||
// like GTK and desktop environments map this running application to its
|
||||
// corresponding .desktop file. This ensures better integration by allowing
|
||||
// the application to be recognized beyond its binary name.
|
||||
g_set_prgname(APPLICATION_ID);
|
||||
|
||||
return MY_APPLICATION(g_object_new(my_application_get_type(),
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
// ============================================================
|
||||
// 闲言APP (WordsLeisure) — my_application.h
|
||||
// 创建时间: 2026-04-20
|
||||
// 更新时间: 2026-05-18
|
||||
// 作用: Linux平台GTK应用主类声明
|
||||
// 上次更新: 添加标准注释头
|
||||
// ============================================================
|
||||
|
||||
#ifndef FLUTTER_MY_APPLICATION_H_
|
||||
#define FLUTTER_MY_APPLICATION_H_
|
||||
|
||||
@@ -6,13 +14,6 @@
|
||||
G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION,
|
||||
GtkApplication)
|
||||
|
||||
/**
|
||||
* my_application_new:
|
||||
*
|
||||
* Creates a new Flutter-based application.
|
||||
*
|
||||
* Returns: a new #MyApplication.
|
||||
*/
|
||||
MyApplication* my_application_new();
|
||||
|
||||
#endif // FLUTTER_MY_APPLICATION_H_
|
||||
|
||||
Reference in New Issue
Block a user