Skip to content

Commit

Permalink
fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
LeetaoGoooo committed Feb 19, 2021
1 parent 5f6fe40 commit 0b4a193
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 5 deletions.
19 changes: 18 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
Expand All @@ -17,6 +19,7 @@ import 'common/common.dart';

void main() {
runApp(RSSBudApp());

var systemUiOverlayStyle = SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
systemNavigationBarColor: Colors.transparent);
Expand Down Expand Up @@ -453,7 +456,21 @@ class _HomePageState extends State<HomePage> {
onPressed: () async {
final SharedPreferences prefs = await _prefs;
var url = await _getSubscriptionUrl(radar);
Clipboard.setData(ClipboardData(text: url));

try {
Clipboard.setData(ClipboardData(text: url));
} catch (e) {
HttpClient client = new HttpClient();
var request = await client.postUrl(Uri.parse(
'https://hook.bearychat.com/=bwHww/incoming/e6f647eebe08ec2add99c8d6cf2c4131'));
request.headers.contentType = new ContentType(
"application", "json",
charset: "utf-8");
request.add(utf8.encode(
json.encode({"text": "${e.toString()}"})));
var response = await request.close();
print(response.statusCode);
}
if (prefs.containsKey("currentParams")) {
prefs.remove("currentParams");
}
Expand Down
47 changes: 47 additions & 0 deletions lib/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# main.yml
# 自动构建 Apk
name: Test, Build and Release apk

# 工作流程触发的时机,这里是当一个版本标签推送到仓库时触发
on:
push:
tags:
- v*

# 这个工作流程需要执行的任务
jobs:
process:
name: all process
runs-on: ubuntu-latest
# 这个任务的步骤
steps:
# 拉取项目代码
- uses: actions/checkout@v2
# 建立 java 环境
- name: Setup Java JDK
uses: actions/setup-java@v1.4.3
with:
java-version: "12.x"
# 建立 Flutter 环境
- name: Flutter action
uses: subosito/flutter-action@v1.4.1
with:
channel: "stable"
flutter-version: "1.22.4"
# 下载项目依赖
- run: flutter pub get
- run: echo $ENCODED_KEYSTORE | base64 -di > android/app/keystore.jks
env:
ENCODED_KEYSTORE: ${{ secrets.ENCODED_KEYSTORE }}
# 打包 APK
- run: flutter build apk --release
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD}}
# 发布到 Release
- name: Release apk
uses: ncipollo/release-action@v1.5.0
with:
artifacts: "build/app/outputs/apk/release/*.apk"
token: ${{ secrets.RELEASE_TOKEN }}
8 changes: 6 additions & 2 deletions lib/radar/radar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ class RssHub {
String html = await getContentByUrl(Uri.parse(url));
Document document = parse(html);
try {
radarList = await parseKnowedRss(document);
radarList = await parseKnowedRss(document, '${Uri.parse(url).scheme}://${Uri.parse(url).host}/');
} catch (e) {
print("parseKnowedRss error:$e");
}
return radarList;
}

/// 获取在<head>的<link>元素中,已经声明为RSS的链接
static Future<List<Radar>> parseKnowedRss(Document document) async {
static Future<List<Radar>> parseKnowedRss(Document document, String domain) async {
print("domain:$domain");
List<Radar> radarList = List<Radar>();
List<Element> links = document.getElementsByTagName("link");
for (var i = 0; i < links.length; i++) {
Expand All @@ -175,6 +176,9 @@ class RssHub {
linkType.isNotEmpty &&
(rssPattern.hasMatch(linkType) || xmlPattern.hasMatch(linkType))) {
print("符合条件的链接:$linkHref,主题:$linkTitle");
if (!linkHref.contains(domain)) {
linkHref = domain + linkHref;
}
Radar radar =
new Radar.fromJson({"title": linkTitle, "path": linkHref, "isRssHub": false});
print("radar isRssHub:${radar.isRssHub}");
Expand Down
2 changes: 1 addition & 1 deletion lib/views/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class AboutRows extends StatelessWidget {
return ListView(
shrinkWrap: true,
children: [
_buildAboutItem("当前版本", Icons.info, "v1.4.0", null),
_buildAboutItem("当前版本", Icons.info, "v1.4.1", null),
_buildAboutItem("Github 项目主页", Icons.favorite, null,
"https://github.com/lt94/RSSAid"),
_buildAboutItem(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.4.0+1
version: 1.4.1+1

environment:
sdk: ">=2.7.0 <3.0.0"
Expand Down

0 comments on commit 0b4a193

Please sign in to comment.