Skip to content

Commit

Permalink
Merge pull request #63 from Muska-Ami/dev
Browse files Browse the repository at this point in the history
Add issue template
  • Loading branch information
Muska-Ami authored Jan 28, 2024
2 parents ea40594 + 5d119d2 commit d774a8b
Show file tree
Hide file tree
Showing 12 changed files with 201 additions and 43 deletions.
46 changes: 46 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: 问题报告
description: 有的东西坏掉了吗?
title: "[BUG]: "
labels: ["bug:漏洞"]
projects: ["Muska-Ami/5"]
assignees: []
body:
- type: markdown
attributes:
value: |
感谢您前来提交问题报告。在提交之前,有几个小小的要求~
- type: checkboxes
id: before-issue
attributes:
label: 问前检查
options:
- label: 我在提问之前,已经自己排查过问题
required: true
- label: 我确保我已经搜索了相关资料,但仍无法解决
required: true
- label: 我确保这个BUG未曾被报告过
required: true
- label: 我确保这个BUG在最新版本可复现
required: true
- type: textarea
id: what-happened
attributes:
label: 问题描述&复现过程
description: 发生什么事了
placeholder: 请描述问题...
validations:
required: true
- type: input
id: version
attributes:
label: 版本
description: 您正在使用的 NyaLCF 版本号
placeholder: 请提供版本号...
validations:
required: true
- type: textarea
id: logs
attributes:
label: 运行日志
description: 请提供您的运行日志,以便分析原因。日志位于 `${SupportPath}/moe.xmcn.nyanana/nyanana/run.log`
render: shell
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- name: Install Dependencies
run: |-
sudo apt-get install clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev rpm patchelf locate libfuse2
sudo apt-get install clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev rpm libayatana-appindicator3-dev patchelf locate libfuse2
dart pub global activate -s path tool/flutter_distributor/packages/flutter_distributor
flutter pub get
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install Dependencies
run: |-
flutter pub get
sudo apt-get install clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libstdc++-12-dev
sudo apt-get install clang cmake git ninja-build pkg-config libgtk-3-dev liblzma-dev libayatana-appindicator3-dev libstdc++-12-dev
- name: Build Application
run: flutter build linux --release

Expand Down
84 changes: 82 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:flutter/material.dart';
import 'package:nyalcf/ui/model/AppbarActions.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'dart:io';
import 'package:nyalcf/io/frpcManagerStorage.dart';
import 'package:nyalcf/io/launcherSettingStorage.dart';
import 'package:nyalcf/model/LauncherSettingModel.dart';
Expand All @@ -24,6 +27,7 @@ import 'package:nyalcf/util/Updater.dart';
LauncherSettingModel? _settings = null;

void main() async {

await Logger.clear();

/// 初始化配置文件
Expand All @@ -44,16 +48,44 @@ void main() async {
appWindow.alignment = Alignment.center;
appWindow.title = 'Nya LoCyanFrp! - LCF启动器';
appWindow.show();
await trayManager.setToolTip('Nya~');
await trayManager.setIcon(
Platform.isWindows
? 'asset/icon/icon.ico'
: 'asset/icon/icon.png',
);
Menu menu = Menu(
items: [
MenuItem(
key: 'show_window',
label: '打开界面',
),
MenuItem(
key: 'hide_window',
label: '隐藏界面',
),
MenuItem.separator(),
MenuItem(
key: 'exit_app',
label: '退出',
),
],
);
trayManager.setContextMenu(menu);

await ProtocolActivation.registerProtocolActivation(callback);
});
}

class App extends StatelessWidget {
class App extends StatefulWidget {
const App({super.key});

final title = 'Nya LoCyanFrp!';
@override
_AppState createState() => _AppState();
}

class _AppState extends State<App> with TrayListener {
final title = 'Nya LoCyanFrp!';
/// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -98,6 +130,54 @@ class App extends StatelessWidget {
theme: _theme_data,
);
}

/// 组件初始化时操作
@override
void initState() {
trayManager.addListener(this);
super.initState();
}

/// 组件销毁时操作
@override
void dispose() {
trayManager.removeListener(this);
super.dispose();
}

/// 鼠标左件托盘图标
@override
void onTrayIconMouseDown() {
appWindow.restore();
}

/// 鼠标右键托盘图标
@override
void onTrayIconRightMouseDown() {
trayManager.popUpContextMenu();
}

// /// 保留备用
// @override
// void onTrayIconRightMouseUp() {}

/// 托盘菜单点击事件
@override
void onTrayMenuItemClick(MenuItem menuItem) {
switch (menuItem.key) {
case 'show_window':
appWindow.restore();
break;
case 'hide_window':
appWindow.hide();
break;
case 'exit_app':
appWindow.restore();
AppbarActionsX().closeAlertDialog();
break;
}
}

}

void callback(deepLink) {
Expand Down
68 changes: 31 additions & 37 deletions lib/ui/model/AppbarActions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import 'package:nyalcf/util/frpc/ProcessManager.dart';

class AppbarActionsX {
AppbarActionsX(
{required this.context,
{this.context = null,
List<Widget> this.append = const <Widget>[],
this.setting = true});

final UserController c = Get.find();

final BuildContext context;
final BuildContext? context;
bool setting;
final List<Widget> append;

Expand Down Expand Up @@ -48,7 +48,7 @@ class AppbarActionsX {

/// 关闭
IconButton(
onPressed: () => {_closeAlertDialog()},
onPressed: () => {closeAlertDialog()},
icon: Icon(Icons.close),
tooltip: '关闭',
color: Colors.white,
Expand Down Expand Up @@ -76,39 +76,33 @@ class AppbarActionsX {
return l;
}

_closeAlertDialog() async {
var result = await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text('关闭NyaLCF'),
content: Text('确定要关闭NyaLCF吗,要是Frpc没关掉猫猫会生气把Frpc一脚踹翻的哦!'),
actions: <Widget>[
TextButton(
child: Text(
'取消',
),
onPressed: () {
Navigator.pop(context, false);
}),
TextButton(
child: Text(
'确定',
style: TextStyle(color: Colors.red),
),
onPressed: () {
try {
FrpcProcessManager().killAll();
} catch (e) {
Logger.error('Failed to close all process: ${e}');
}
Navigator.pop(context, true);
},
),
],
);
});

if (result) appWindow.close();
closeAlertDialog() async {
await Get.dialog(AlertDialog(
title: Text('关闭NyaLCF'),
content: Text('确定要关闭NyaLCF吗,要是Frpc没关掉猫猫会生气把Frpc一脚踹翻的哦!'),
actions: <Widget>[
TextButton(
child: Text(
'取消',
),
onPressed: () async {
Get.close(0);
}),
TextButton(
child: Text(
'确定',
style: TextStyle(color: Colors.red),
),
onPressed: () {
try {
FrpcProcessManager().killAll();
} catch (e) {
Logger.error('Failed to close all process: ${e}');
}
appWindow.close();
},
),
],
));
}
}
4 changes: 4 additions & 0 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
#include "generated_plugin_registrant.h"

#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
#include <tray_manager/tray_manager_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>

void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
g_autoptr(FlPluginRegistrar) tray_manager_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "TrayManagerPlugin");
tray_manager_plugin_register_with_registrar(tray_manager_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
Expand Down
1 change: 1 addition & 0 deletions linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

list(APPEND FLUTTER_PLUGIN_LIST
bitsdojo_window_linux
tray_manager
url_launcher_linux
)

Expand Down
2 changes: 2 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import bitsdojo_window_macos
import package_info_plus
import path_provider_foundation
import shared_preferences_foundation
import tray_manager
import url_launcher_macos

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
TrayManagerPlugin.register(with: registry.registrar(forPlugin: "TrayManagerPlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.0"
menu_base:
dependency: transitive
description:
name: menu_base
sha256: "820368014a171bd1241030278e6c2617354f492f5c703d7b7d4570a6b8b84405"
url: "https://pub.dev"
source: hosted
version: "0.1.1"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -520,6 +528,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.3.2"
shortid:
dependency: transitive
description:
name: shortid
sha256: d0b40e3dbb50497dad107e19c54ca7de0d1a274eb9b4404991e443dadb9ebedb
url: "https://pub.dev"
source: hosted
version: "0.1.2"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -573,6 +589,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.1"
tray_manager:
dependency: "direct main"
description:
name: tray_manager
sha256: "4ab709d70a4374af172f8c39e018db33a4271265549c6fc9d269a65e5f4b0225"
url: "https://pub.dev"
source: hosted
version: "0.2.1"
tuple:
dependency: transitive
description:
Expand Down
7 changes: 5 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 0.1.5
version: 0.1.6

environment:
sdk: '>=3.1.5 <4.0.0'
Expand Down Expand Up @@ -47,6 +47,7 @@ dependencies:
package_info_plus: ^5.0.1
flutter_code_editor: ^0.3.1
logger: ^2.0.2+1
tray_manager: ^0.2.1

dev_dependencies:
flutter_test:
Expand Down Expand Up @@ -78,7 +79,9 @@ flutter:
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
assets:
- asset/icon/icon.png
- asset/icon/icon.ico
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

Expand Down
Loading

0 comments on commit d774a8b

Please sign in to comment.