Skip to content

Commit

Permalink
feat: 更新日志 markdown 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
MiaoMint committed Jul 6, 2023
1 parent 85cb14e commit b48b85f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 84 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

- 支持 `windows`,`android`,`linux`
- 友好的扩展编写支持、调试日志
- 扩展使用 JavaScriptv 语言,开发简单
- 支持自定义扩展仓库
- 官方扩展仓库提供视频源,无需编写任何扩展即可使用.
- 支持在线观看多种视频、漫画、小说源,实现多平台的统一
- 官方扩展仓库提供视频源,无需编写任何扩展即可使用
- 支持在线观看多种视频、漫画、小说源,实现多平台的统一
- 统一系统 UI 的设计语言

## Todo
Expand All @@ -27,6 +28,8 @@
- [x] 影视支持
- [ ] TMDB 元数据
- [ ] 数据同步
- [ ] i18n 国际化
- [ ] 扩展设置支持

## 截图

Expand Down
116 changes: 34 additions & 82 deletions lib/pages/main/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:fluent_ui/fluent_ui.dart' as fluent;
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:get/get.dart';
import 'package:miru_app/main.dart';
import 'package:miru_app/utils/package_info.dart';
import 'package:miru_app/widgets/button.dart';
import 'package:miru_app/widgets/messenger.dart';
import 'package:url_launcher/url_launcher.dart';

class MainController extends GetxController {
Expand All @@ -28,99 +29,50 @@ class MainController extends GetxController {
(res.data["tag_name"] as String).replaceFirst('v', '');
if (packageInfo.version != remoteVersion) {
if (Platform.isAndroid) {
showDialog(
showPlatformDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'检测到新版本$remoteVersion',
style: Get.theme.textTheme.bodyLarge,
),
content: Text(res.data['body']),
actions: [
TextButton(
onPressed: () {
Get.back();
},
child: const Text('关闭'),
),
FilledButton(
onPressed: () {
Get.back();
launchUrl(
Uri.parse(res.data['html_url']),
mode: LaunchMode.externalApplication,
);
},
child: const Text('前往更新'),
)
],
);
},
title: '检测到新版本$remoteVersion',
content: Markdown(data: res.data['body']),
actions: [
PlatformTextButton(
onPressed: () {
Get.back();
},
child: const Text('关闭'),
),
PlatformFilledButton(
onPressed: () {
Get.back();
launchUrl(
Uri.parse(res.data['html_url']),
mode: LaunchMode.externalApplication,
);
},
child: const Text('前往更新'),
)
],
);
return;
}

fluent.showDialog(
context: context,
builder: (context) {
return fluent.ContentDialog(
title: Text('检测到新版本$remoteVersion'),
content: Text(res.data['body']),
actions: [
fluent.Button(
onPressed: () {
router.pop();
},
child: const Text('关闭'),
),
fluent.FilledButton(
child: const Text('前往更新'),
onPressed: () {
router.pop();
launchUrl(
Uri.parse(res.data['html_url']),
mode: LaunchMode.externalApplication,
);
},
),
],
);
},
);
} else {
if (!showSnackbar) {
return;
}

if (Platform.isAndroid) {
Get.rawSnackbar(
message: '当前已是最新版本',
);
return;
}

fluent.displayInfoBar(context, builder: (context, close) {
return const fluent.InfoBar(
title: Text('当前已是最新版本'),
);
});
showPlatformSnackbar(
context: context,
title: '检查更新',
content: "当前已是最新版本",
);
}
} catch (e) {
if (!showSnackbar) {
return;
}
if (Platform.isAndroid) {
Get.rawSnackbar(
message: '检查更新失败,网络出现异常',
);
return;
}
fluent.displayInfoBar(context, builder: (context, close) {
return const fluent.InfoBar(
title: Text('检查更新失败,网络出现异常'),
);
});
showPlatformSnackbar(
context: context,
title: '检查更新',
content: "检查更新失败,网络出现异常",
);
}
}
}
16 changes: 16 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_markdown:
dependency: "direct main"
description:
name: flutter_markdown
sha256: "86b76dbf30496024d6c816bdc13b97de9449dce1f035a73ee7b4ab7f67eab70b"
url: "https://pub.dev"
source: hosted
version: "0.6.16"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -597,6 +605,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
markdown:
dependency: transitive
description:
name: markdown
sha256: "8e332924094383133cee218b676871f42db2514f1f6ac617b6cf6152a7faab8e"
url: "https://pub.dev"
source: hosted
version: "7.1.0"
matcher:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
flutter_animate: ^4.1.1+1
flutter_code_editor: ^0.3.0
flutter_js: ^0.7.1
flutter_markdown: ^0.6.16
get: ^4.6.5
go_router: ^8.0.5
hive: ^2.2.3
Expand Down

0 comments on commit b48b85f

Please sign in to comment.