mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: create/edit/del fav folder
This commit is contained in:
@@ -172,6 +172,14 @@ class Api {
|
||||
// https://api.bilibili.com/x/v3/fav/folder/created/list?pn=1&ps=10&up_mid=17340771
|
||||
static const String userFavFolder = '/x/v3/fav/folder/created/list';
|
||||
|
||||
static const String folderInfo = '/x/v3/fav/folder/info';
|
||||
|
||||
static const String addFolder = '/x/v3/fav/folder/add';
|
||||
|
||||
static const String editFolder = '/x/v3/fav/folder/edit';
|
||||
|
||||
static const String deleteFolder = '/x/v3/fav/folder/del';
|
||||
|
||||
/// 收藏夹 详情
|
||||
/// media_id 当前收藏夹id 搜索全部时为默认收藏夹id
|
||||
/// pn int 当前页
|
||||
@@ -664,6 +672,8 @@ class Api {
|
||||
|
||||
static const String uploadBfs = '/x/dynamic/feed/draw/upload_bfs';
|
||||
|
||||
static const String uploadImage = '/x/upload/web/image';
|
||||
|
||||
static const String videoRelation = '/x/web-interface/archive/relation';
|
||||
|
||||
static const String seasonFav = '/x/v3/fav/season/'; // + fav unfav
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'package:PiliPalaX/http/constants.dart';
|
||||
import 'package:PiliPalaX/pages/dynamics/view.dart' show ReplyOption;
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../models/msg/account.dart';
|
||||
@@ -205,6 +206,33 @@ class MsgHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future uploadImage({
|
||||
required dynamic path,
|
||||
required String bucket,
|
||||
required String dir,
|
||||
}) async {
|
||||
var res = await Request().post(
|
||||
Api.uploadImage,
|
||||
data: FormData.fromMap({
|
||||
'bucket': bucket,
|
||||
'file': await MultipartFile.fromFile(path),
|
||||
'dir': dir,
|
||||
'csrf': await Request.getCsrf(),
|
||||
}),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return {
|
||||
'status': true,
|
||||
'data': res.data['data'],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
'status': false,
|
||||
'msg': res.data['message'],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static Future uploadBfs(
|
||||
dynamic path,
|
||||
) async {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPalaX/http/loading_state.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import '../common/constants.dart';
|
||||
@@ -65,6 +66,65 @@ class UserHttp {
|
||||
}
|
||||
}
|
||||
|
||||
static Future deleteFolder({
|
||||
required List<dynamic> mediaIds,
|
||||
}) async {
|
||||
var res = await Request().post(Api.deleteFolder,
|
||||
data: {
|
||||
'media_ids': mediaIds.join(','),
|
||||
'platform': 'web',
|
||||
'csrf': await Request.getCsrf(),
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
));
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future addOrEditFolder({
|
||||
required bool isAdd,
|
||||
dynamic mediaId,
|
||||
required String title,
|
||||
required int privacy,
|
||||
required String cover,
|
||||
required String intro,
|
||||
}) async {
|
||||
var res = await Request().post(isAdd ? Api.addFolder : Api.editFolder,
|
||||
data: {
|
||||
'title': title,
|
||||
'intro': intro,
|
||||
'privacy': privacy,
|
||||
'cover': cover.isNotEmpty ? Uri.encodeFull(cover) : cover,
|
||||
'csrf': await Request.getCsrf(),
|
||||
if (mediaId != null) 'media_id': mediaId,
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
));
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future folderInfo({
|
||||
dynamic mediaId,
|
||||
}) async {
|
||||
var res = await Request().get(Api.folderInfo, data: {
|
||||
'media_id': mediaId,
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
return {'status': true, 'data': res.data['data']};
|
||||
} else {
|
||||
return {'status': false, 'msg': res.data['message']};
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> userFavFolderDetail(
|
||||
{required int mediaId,
|
||||
required int pn,
|
||||
|
||||
Reference in New Issue
Block a user