mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: fav article
Closes #727 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -773,4 +773,6 @@ class Api {
|
||||
|
||||
static const String searchRecommend =
|
||||
'${HttpString.appBaseUrl}/x/v2/search/recommend';
|
||||
|
||||
static const String articleInfo = '/x/article/viewinfo';
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../models/dynamics/result.dart';
|
||||
@@ -137,4 +138,23 @@ class DynamicsHttp {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future articleInfo({
|
||||
required dynamic cvId,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.articleInfo,
|
||||
queryParameters: await WbiSign.makSign({
|
||||
'id': cvId,
|
||||
'mobi_app': 'pc',
|
||||
'from': 'web',
|
||||
'gaia_source': 'main_web',
|
||||
}),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,14 +72,18 @@ class HtmlHttp {
|
||||
// List imgList = opusDetail.querySelectorAll('bili-album__preview__picture__img');
|
||||
|
||||
dynamic mid;
|
||||
Map? favorite;
|
||||
try {
|
||||
final regex = RegExp(r'window\.__INITIAL_STATE__\s*=\s*(\{.*?\});');
|
||||
final match = regex.firstMatch(response.data);
|
||||
if (match != null) {
|
||||
final json = jsonDecode(match.group(1)!);
|
||||
mid = json['detail']['basic']['uid'];
|
||||
favorite = json['detail']['modules'].last['module_stat']['favorite'];
|
||||
}
|
||||
} catch (_) {}
|
||||
} catch (e) {
|
||||
debugPrint('req html: $e');
|
||||
}
|
||||
|
||||
return {
|
||||
'status': true,
|
||||
@@ -90,6 +94,7 @@ class HtmlHttp {
|
||||
'content': (test ?? '') + opusContent,
|
||||
'commentType': int.parse(comment[1]),
|
||||
'commentId': int.parse(comment[2]),
|
||||
'favorite': favorite,
|
||||
};
|
||||
} catch (err) {
|
||||
debugPrint('err: $err');
|
||||
|
||||
@@ -496,7 +496,7 @@ class UserHttp {
|
||||
}
|
||||
|
||||
static Future addFavArticle({
|
||||
required int id,
|
||||
required dynamic id,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.addFavArticle,
|
||||
@@ -516,7 +516,7 @@ class UserHttp {
|
||||
}
|
||||
|
||||
static Future delFavArticle({
|
||||
required int id,
|
||||
required dynamic id,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.delFavArticle,
|
||||
|
||||
Reference in New Issue
Block a user