Skip to content

Commit

Permalink
🔖 v1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
iota9star committed Jun 3, 2023
1 parent 0541156 commit 20113dc
Show file tree
Hide file tree
Showing 33 changed files with 967 additions and 718 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/build-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ jobs:
channel: stable
- name: Set up xcode
uses: devbotsxyz/xcode-select@v1
- name: Build iOS
run: |
cp -f pubspec.yaml assets/
flutter pub get
flutter build ios --release --tree-shake-icons
mkdir -p Payload
mv build/ios/iphoneos/Runner.app Payload
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install zip
zip -r ios-release.ipa Payload
- name: Build macos
env:
MACOS_APP_RELEASE_PATH: build/macos/Build/Products/Release
Expand All @@ -136,11 +126,27 @@ jobs:
"mikan.app"
cd ../../../../../
mv $MACOS_APP_RELEASE_PATH/MikanProject.dmg macos-release.dmg
- name: Release build
- name: Release Mac
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "macos-release.dmg,ios-release.ipa"
artifacts: "macos-release.dmg"
token: ${{ secrets.ACTION_TOKEN }}
tag: ${{ github.event.inputs.TAG }}
- name: Build iOS
run: |
cp -f pubspec.yaml assets/
flutter pub get
flutter build ios --release --tree-shake-icons --no-codesign
mkdir -p Payload
mv build/ios/iphoneos/Runner.app Payload
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install zip
zip -r ios-release.ipa Payload
- name: Release iOS
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: "ios-release.ipa"
token: ${{ secrets.ACTION_TOKEN }}
tag: ${{ github.event.inputs.TAG }}

27 changes: 23 additions & 4 deletions lib/internal/hive.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import 'dart:io';

import 'package:collection/collection.dart';
import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';

import '../model/announcement.dart';
import '../model/bangumi.dart';
import '../model/bangumi_row.dart';
import '../model/carousel.dart';
Expand All @@ -30,6 +32,8 @@ class MyHive {
static const int mikanSeason = mikanSubgroup + 1;
static const int mikanYearSeason = mikanSeason + 1;
static const int mikanRecordItem = mikanYearSeason + 1;
static const int mikanAnnouncement = mikanRecordItem + 1;
static const int mikanAnnouncementNode = mikanAnnouncement + 1;

static late final Box settings;
static late final Box db;
Expand All @@ -54,6 +58,8 @@ class MyHive {
Hive.registerAdapter(SeasonAdapter());
Hive.registerAdapter(YearSeasonAdapter());
Hive.registerAdapter(RecordItemAdapter());
Hive.registerAdapter(AnnouncementAdapter());
Hive.registerAdapter(AnnouncementNodeAdapter());
db = await Hive.openBox(HiveBoxKey.db);
settings = await Hive.openBox(HiveBoxKey.settings);
MikanUrls.baseUrl = MyHive.getMirrorUrl();
Expand Down Expand Up @@ -203,17 +209,29 @@ class MyHive {
return settings.put(SettingsHiveKey.tabletMode, mode.name);
}

static double getCardRatio() {
static Decimal getCardRatio() {
final value = settings.get(
SettingsHiveKey.cardRatio,
defaultValue: '0.9',
);
return double.parse(value);
return Decimal.parse(value);
}

static Future<void> setCardRatio(double ratio) {
static Future<void> setCardRatio(Decimal ratio) {
return settings.put(SettingsHiveKey.cardRatio, ratio.toString());
}

static Decimal getCardWidth() {
final value = settings.get(
SettingsHiveKey.cardWidth,
defaultValue: '200.0',
);
return Decimal.parse(value);
}

static Future<void> setCardWidth(Decimal width) {
return settings.put(SettingsHiveKey.cardWidth, width.toString());
}
}

class HiveDBKey {
Expand Down Expand Up @@ -242,9 +260,10 @@ class SettingsHiveKey {
static const String themeMode = 'THEME_MODE';
static const String mirrorUrl = 'MIRROR_URL';
static const String cardRatio = 'CARD_RATIO';
static const String cardWidth = 'CARD_WIDTH';
static const String cardStyle = 'CARD_STYLE';
static const String tabletMode = 'TABLET_MODE';
static const String dynamicColor = 'DYNAMIC_COLOR';
static const String cardStyle = 'cardStyle';
}

enum TabletMode {
Expand Down
10 changes: 5 additions & 5 deletions lib/internal/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ class MikanTransformer extends SyncTransformer {
RequestOptions options,
ResponseBody response,
) async {
final transformResponse = await super.transformResponse(options, response);
if (transformResponse is String) {
final rep = await super.transformResponse(options, response);
if (rep is String) {
final String? func = options.extra['$MikanFunc'];
if (func.isNotBlank) {
final document = parse(transformResponse);
final document = parse(rep);
MikanUrls.baseUrl = options.uri.origin;
switch (func) {
case MikanFunc.season:
Expand Down Expand Up @@ -81,10 +81,10 @@ class MikanTransformer extends SyncTransformer {

final extra = options.extra['$ExtraUrl'];
if (extra == ExtraUrl.fontsManifest) {
return jsonDecode(transformResponse);
return jsonDecode(rep);
}
}
return transformResponse;
return rep;
}
}

Expand Down
34 changes: 34 additions & 0 deletions lib/internal/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:collection/collection.dart';
import 'package:html/dom.dart';
import 'package:jiffy/jiffy.dart';

import '../model/announcement.dart';
import '../model/bangumi.dart';
import '../model/bangumi_details.dart';
import '../model/bangumi_row.dart';
Expand Down Expand Up @@ -400,6 +401,7 @@ class Resolver {
final List<Carousel> carousels = parseCarousel(document);
final List<YearSeason> years = parseYearSeason(document);
final User user = parseUser(document);
final List<Announcement> annos = parseAnnouncement(document);
final Map<String, List<RecordItem>> groupedRss =
groupBy(rss, (it) => it.id!);
return Index(
Expand All @@ -408,6 +410,7 @@ class Resolver {
rss: groupedRss,
carousels: carousels,
user: user,
announcements: annos,
);
}

Expand Down Expand Up @@ -834,4 +837,35 @@ class Resolver {
}
return bangumis;
}

static List<Announcement> parseAnnouncement(Document document) {
final annos = <Announcement>[];
final eles =
document.querySelectorAll('.announcement-popover-content > div');
for (final ele in eles) {
final date = ele.querySelector('.anndate');
date!.remove();
final nodes = <AnnouncementNode>[];
for (final e in ele.nodes) {
if (e is Element) {
if (e.localName == 'a') {
nodes.add(
AnnouncementNode(
text: '{${e.text}}',
place: e.attributes['href'],
type: 'url',
),
);
continue;
} else if (e.localName == 'b') {
nodes.add(AnnouncementNode(text: '{${e.text}}', type: 'bold'));
continue;
}
}
nodes.add(AnnouncementNode(text: e.text ?? ''));
}
annos.add(Announcement(date: date.text, nodes: nodes));
}
return annos;
}
}
13 changes: 12 additions & 1 deletion lib/mikan_route.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions lib/mikan_routes.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions lib/model/announcement.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import 'package:hive_flutter/hive_flutter.dart';

import '../internal/hive.dart';

part 'announcement.g.dart';

@HiveType(typeId: MyHive.mikanAnnouncement)
class Announcement extends HiveObject {
Announcement({
required this.date,
required this.nodes,
});

@HiveField(0)
late String date;
@HiveField(1)
late List<AnnouncementNode> nodes;

late final text = () {
final sb = StringBuffer()
..write('{')
..write(date)
..write('} ');
for (final node in nodes) {
sb.write(node.text);
}
return sb.toString();
}();

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Announcement &&
runtimeType == other.runtimeType &&
date == other.date;

@override
int get hashCode => date.hashCode;

@override
String toString() {
return 'Announcement{date: $date, nodes: $nodes, text: $text}';
}
}



@HiveType(typeId: MyHive.mikanAnnouncementNode)
class AnnouncementNode extends HiveObject {
AnnouncementNode({
required this.text,
this.type,
this.place,
});

@HiveField(0)
late String text;
@HiveField(1)
String? type;
@HiveField(2)
String? place;

@override
String toString() {
return 'AnnouncementNode{text: $text, type: $type, place: $place}';
}
}
Loading

0 comments on commit 20113dc

Please sign in to comment.