Skip to content

Commit

Permalink
Merge pull request #91 from ZhuJHua/dev
Browse files Browse the repository at this point in the history
Release at 2.6.5
  • Loading branch information
ZhuJHua authored Jan 2, 2025
2 parents 453d3ca + 19cabc1 commit 6d569af
Show file tree
Hide file tree
Showing 192 changed files with 8,605 additions and 2,616 deletions.
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "3.27.1"
}
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.0-0.2.pre'
flutter-version: '3.27.1'

- name: Install Dependencies
run: flutter pub get
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.0-0.2.pre'
flutter-version: '3.27.1'

- name: Install Dependencies
run: flutter pub get
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# FVM Version Cache
.fvm/
4 changes: 3 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ linter:
prefer_const_declarations: true
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

analyzer:
plugins:
- custom_lint
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
24 changes: 21 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,40 @@ allprojects {
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven { url "https://maven.aliyun.com/repository/google" }
maven { url "https://maven.aliyun.com/repository/jcenter" }
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url "https://tencent-tds-maven.pkg.coding.net/repository/shiply/repo" }
maven { url "https://storage.googleapis.com/download.flutter.io" }
maven { url 'https://jitpack.io' }
maven { url 'https://developer.hihonor.com/repo' }
maven { url 'https://developer.huawei.com/repo' }

}
}

rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}

subprojects {
afterEvaluate { project ->
if (project.plugins.hasPlugin("com.android.application") ||
project.plugins.hasPlugin("com.android.library")) {
project.android {
compileSdkVersion 35
buildToolsVersion "35.0.0"
}
}
if (project.hasProperty("android")) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}

subprojects {
project.evaluationDependsOn(":app")
}
Expand Down
4 changes: 3 additions & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ pluginManagement {
maven { url "https://maven.aliyun.com/repository/google" }
maven { url "https://maven.aliyun.com/repository/jcenter" }
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url "https://tencent-tds-maven.pkg.coding.net/repository/shiply/repo" }
maven { url "https://storage.googleapis.com/download.flutter.io" }
maven { url 'https://jitpack.io' }
maven { url 'https://developer.hihonor.com/repo' }
maven { url 'https://developer.huawei.com/repo' }
}
}

Expand Down
52 changes: 36 additions & 16 deletions lib/api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import 'package:mood_diary/utils/signature_util.dart';
import '../utils/data/pref.dart';

class Api {
static Future<Stream<String>?> getHunYuan(String id, String key, List<Message> messages, int model) async {
static Future<Stream<String>?> getHunYuan(
String id, String key, List<Message> messages, int model) async {
//获取时间戳
var timestamp = DateTime.now().millisecondsSinceEpoch;
var hunyuanModel = switch (model) {
Expand All @@ -37,11 +38,14 @@ class Api {
};

//获取签名
var authorization = SignatureUtil.generateSignature(id, key, timestamp, body);
var authorization =
SignatureUtil.generateSignature(id, key, timestamp, body);
//构造请求头
var header = PublicHeader('ChatCompletions', timestamp ~/ 1000, '2023-09-01', authorization);
var header = PublicHeader(
'ChatCompletions', timestamp ~/ 1000, '2023-09-01', authorization);
//发起请求
return await HttpUtil().postStream('https://hunyuan.tencentcloudapi.com', header: header.toMap(), data: body);
return await HttpUtil().postStream('https://hunyuan.tencentcloudapi.com',
header: header.toMap(), data: body);
}

static Future<Uint8List?> getImageData(String url) async {
Expand All @@ -63,8 +67,10 @@ class Api {
}
}
if (await Geolocator.isLocationServiceEnabled()) {
position = await Geolocator.getLastKnownPosition(forceAndroidLocationManager: true);
position ??= await Geolocator.getCurrentPosition(locationSettings: AndroidSettings(forceLocationManager: true));
position = await Geolocator.getLastKnownPosition(
forceAndroidLocationManager: true);
position ??= await Geolocator.getCurrentPosition(
locationSettings: AndroidSettings(forceLocationManager: true));
}
if (position != null) {
var local = Localizations.localeOf(Get.context!);
Expand All @@ -74,11 +80,18 @@ class Api {
'key': PrefUtil.getValue<String>('qweatherKey'),
'lang': local
};
var res = await HttpUtil().get('https://geoapi.qweather.com/v2/city/lookup', parameters: parameters);
var geo = await compute(GeoResponse.fromJson, res.data as Map<String, dynamic>);
var res = await HttpUtil().get(
'https://geoapi.qweather.com/v2/city/lookup',
parameters: parameters);
var geo =
await compute(GeoResponse.fromJson, res.data as Map<String, dynamic>);
if (geo.location != null && geo.location!.isNotEmpty) {
var city = geo.location!.first;
return [position.latitude.toString(), position.longitude.toString(), '${city.adm2} ${city.name}'];
return [
position.latitude.toString(),
position.longitude.toString(),
'${city.adm2} ${city.name}'
];
} else {
return null;
}
Expand All @@ -95,8 +108,10 @@ class Api {
'key': PrefUtil.getValue<String>('qweatherKey'),
'lang': local
};
var res = await HttpUtil().get('https://devapi.qweather.com/v7/weather/now', parameters: parameters);
var weather = await compute(WeatherResponse.fromJson, res.data as Map<String, dynamic>);
var res = await HttpUtil().get('https://devapi.qweather.com/v7/weather/now',
parameters: parameters);
var weather = await compute(
WeatherResponse.fromJson, res.data as Map<String, dynamic>);
if (weather.now != null) {
return [
weather.now!.icon!,
Expand All @@ -109,23 +124,28 @@ class Api {
}

static Future<GithubRelease?> getGithubRelease() async {
var res = await HttpUtil().get('https://api.github.com/repos/ZhuJHua/moodiary/releases/latest');
var res = await HttpUtil()
.get('https://api.github.com/repos/ZhuJHua/moodiary/releases/latest');
if (res.data != null) {
var githubRelease = await compute(GithubRelease.fromJson, res.data as Map<String, dynamic>);
var githubRelease = await compute(
GithubRelease.fromJson, res.data as Map<String, dynamic>);
return githubRelease;
}
return null;
}

static Future<List<String>?> updateHitokoto() async {
var res = await HttpUtil().get('https://v1.hitokoto.cn');
var hitokoto = await compute(HitokotoResponse.fromJson, res.data as Map<String, dynamic>);
var hitokoto = await compute(
HitokotoResponse.fromJson, res.data as Map<String, dynamic>);
return [hitokoto.hitokoto!];
}

static Future<List<String>?> updateImageUrl() async {
var res = await HttpUtil().get('https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1');
BingImage bingImage = await compute(BingImage.fromJson, res.data as Map<String, dynamic>);
var res = await HttpUtil()
.get('https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1');
BingImage bingImage =
await compute(BingImage.fromJson, res.data as Map<String, dynamic>);
return ['https://cn.bing.com${bingImage.images?[0].url}'];
}
}
10 changes: 7 additions & 3 deletions lib/common/models/geo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class GeoResponse {

GeoResponse.fromJson(Map<String, dynamic> json) {
code = json["code"];
location = json["location"] == null ? null : (json["location"] as List).map((e) => Location.fromJson(e)).toList();
location = json["location"] == null
? null
: (json["location"] as List).map((e) => Location.fromJson(e)).toList();
refer = json["refer"] == null ? null : Refer.fromJson(json["refer"]);
}

Expand All @@ -27,8 +29,10 @@ class Refer {
Refer({this.sources, this.license});

Refer.fromJson(Map<String, dynamic> json) {
sources = json["sources"] == null ? null : List<String>.from(json["sources"]);
license = json["license"] == null ? null : List<String>.from(json["license"]);
sources =
json["sources"] == null ? null : List<String>.from(json["sources"]);
license =
json["license"] == null ? null : List<String>.from(json["license"]);
}

Map<String, dynamic> toJson() {
Expand Down
7 changes: 5 additions & 2 deletions lib/common/models/github.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class GithubRelease {
prerelease = json["prerelease"];
createdAt = json["created_at"];
publishedAt = json["published_at"];
assets = json["assets"] == null ? null : (json["assets"] as List).map((e) => Assets.fromJson(e)).toList();
assets = json["assets"] == null
? null
: (json["assets"] as List).map((e) => Assets.fromJson(e)).toList();
tarballUrl = json["tarball_url"];
zipballUrl = json["zipball_url"];
body = json["body"];
Expand Down Expand Up @@ -123,7 +125,8 @@ class Assets {
nodeId = json["node_id"];
name = json["name"];
label = json["label"];
uploader = json["uploader"] == null ? null : Uploader.fromJson(json["uploader"]);
uploader =
json["uploader"] == null ? null : Uploader.fromJson(json["uploader"]);
contentType = json["content_type"];
state = json["state"];
size = json["size"];
Expand Down
4 changes: 3 additions & 1 deletion lib/common/models/hunyuan.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class HunyuanResponse {

HunyuanResponse.fromJson(Map<String, dynamic> json) {
note = json["Note"];
choices = json["Choices"] == null ? null : (json["Choices"] as List).map((e) => Choices.fromJson(e)).toList();
choices = json["Choices"] == null
? null
: (json["Choices"] as List).map((e) => Choices.fromJson(e)).toList();
created = json["Created"];
id = json["Id"];
usage = json["Usage"] == null ? null : Usage.fromJson(json["Usage"]);
Expand Down
7 changes: 5 additions & 2 deletions lib/common/models/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ class BingImage {
BingImage({this.images, this.tooltips});

BingImage.fromJson(Map<String, dynamic> json) {
images = json["images"] == null ? null : (json["images"] as List).map((e) => Images.fromJson(e)).toList();
tooltips = json["tooltips"] == null ? null : Tooltips.fromJson(json["tooltips"]);
images = json["images"] == null
? null
: (json["images"] as List).map((e) => Images.fromJson(e)).toList();
tooltips =
json["tooltips"] == null ? null : Tooltips.fromJson(json["tooltips"]);
}

Map<String, dynamic> toJson() {
Expand Down
23 changes: 22 additions & 1 deletion lib/common/models/isar/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ class Category {
@Id()
late String id;

//分类名称
late String categoryName;

String? parentId;

@Index()
String get level => parentId ?? 'root';

Category();

Map<String, dynamic> toJson() {
return {
'id': id,
'categoryName': categoryName,
'parentId': parentId,
};
}

factory Category.fromJson(Map<String, dynamic> json) {
return Category()
..id = json['id'] as String
..categoryName = json['categoryName'] as String
..parentId = json['parentId'] as String?;
}
}
Loading

0 comments on commit 6d569af

Please sign in to comment.