mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: fav note page
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -725,5 +725,13 @@ class Api {
|
||||
|
||||
static const String pgcIndexResult = '/pgc/season/index/result';
|
||||
|
||||
static const String noteList = '/x/note/publish/list/archive';
|
||||
static const String archiveNoteList = '/x/note/publish/list/archive';
|
||||
|
||||
static const String noteList = '/x/note/list';
|
||||
|
||||
static const String userNoteList = '/x/note/publish/list/user';
|
||||
|
||||
static const String addNote = '/x/note/add';
|
||||
|
||||
static const String archiveNote = '/x/note/list/archive';
|
||||
}
|
||||
|
||||
@@ -272,8 +272,10 @@ class Request {
|
||||
static String headerUa({type = 'mob'}) {
|
||||
return type == 'mob'
|
||||
? Platform.isIOS
|
||||
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 Safari/604.1'
|
||||
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 BiliApp/62000200'
|
||||
: 'Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36'
|
||||
: type == 'ios'
|
||||
? 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 BiliApp/62000200'
|
||||
: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15';
|
||||
}
|
||||
|
||||
|
||||
@@ -1074,7 +1074,7 @@ class VideoHttp {
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.noteList,
|
||||
Api.archiveNoteList,
|
||||
queryParameters: {
|
||||
'csrf': Accounts.main.csrf,
|
||||
'oid': oid,
|
||||
@@ -1090,4 +1090,88 @@ class VideoHttp {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> noteList({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.noteList,
|
||||
queryParameters: {
|
||||
'pn': page,
|
||||
'ps': 10,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']?['list']);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> userNoteList({
|
||||
required int page,
|
||||
}) async {
|
||||
var res = await Request().get(
|
||||
Api.userNoteList,
|
||||
queryParameters: {
|
||||
'pn': page,
|
||||
'ps': 10,
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']?['list']);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<LoadingState> addNote({
|
||||
required oid,
|
||||
required String title,
|
||||
required String summary,
|
||||
}) async {
|
||||
String noteId = '';
|
||||
try {
|
||||
final res = await Request().get(Api.archiveNote, queryParameters: {
|
||||
'oid': oid,
|
||||
'oid_type': 0,
|
||||
'csrf': Accounts.main.csrf,
|
||||
});
|
||||
if (res.data['code'] == 0) {
|
||||
if (res.data['data']['noteIds'] != null) {
|
||||
noteId = res.data['data']['noteIds'].first;
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
|
||||
var res = await Request().post(
|
||||
Api.addNote,
|
||||
data: {
|
||||
'cont_len': summary.length,
|
||||
'note_id': noteId,
|
||||
'oid': oid,
|
||||
'oid_type': 0,
|
||||
'platform': 'web',
|
||||
'title': title,
|
||||
'summary': summary,
|
||||
'content': jsonEncode([
|
||||
{"insert": summary},
|
||||
]),
|
||||
'from': 'close',
|
||||
'hash': DateTime.now().millisecondsSinceEpoch,
|
||||
'tags': '',
|
||||
'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: Options(
|
||||
contentType: Headers.formUrlEncodedContentType,
|
||||
),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
return LoadingState.success(res.data['data']?['list']);
|
||||
} else {
|
||||
return LoadingState.error(res.data['message']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,18 +59,19 @@ abstract class CommonController extends GetxController
|
||||
LoadingState response = await customGetData();
|
||||
if (response is Success) {
|
||||
if (!customHandleResponse(response)) {
|
||||
if ((response.response as List?).isNullOrEmpty) {
|
||||
List dataList = (response.response as List?) ?? [];
|
||||
if (dataList.isEmpty) {
|
||||
isEnd = true;
|
||||
}
|
||||
List currentList = loadingState.value is Success
|
||||
? (loadingState.value as Success).response
|
||||
: [];
|
||||
List? handleList = handleListResponse(currentList, response.response);
|
||||
List? handleList = handleListResponse(currentList, dataList);
|
||||
loadingState.value = isRefresh
|
||||
? handleList != null
|
||||
? LoadingState.success(handleList)
|
||||
: response
|
||||
: LoadingState.success(currentList + response.response);
|
||||
: LoadingState.success(currentList + dataList);
|
||||
// handleSuccess(currentList, response.response);
|
||||
}
|
||||
currentPage++;
|
||||
|
||||
85
lib/pages/fav/note/child_view.dart
Normal file
85
lib/pages/fav/note/child_view.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/skeleton/video_card_h.dart';
|
||||
import 'package:PiliPlus/common/widgets/http_error.dart';
|
||||
import 'package:PiliPlus/common/widgets/refresh_indicator.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/fav/note/controller.dart';
|
||||
import 'package:PiliPlus/pages/fav/note/widget/item.dart';
|
||||
import 'package:PiliPlus/utils/grid.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class FavNoteChildPage extends StatefulWidget {
|
||||
const FavNoteChildPage({super.key, required this.isPublish});
|
||||
|
||||
final bool isPublish;
|
||||
|
||||
@override
|
||||
State<FavNoteChildPage> createState() => _FavNoteChildPageState();
|
||||
}
|
||||
|
||||
class _FavNoteChildPageState extends State<FavNoteChildPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
late final FavNoteController _favNoteController =
|
||||
Get.put(FavNoteController(widget.isPublish), tag: '${widget.isPublish}');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return refreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _favNoteController.onRefresh();
|
||||
},
|
||||
child: CustomScrollView(
|
||||
slivers: [
|
||||
Obx(() => _buildBody(_favNoteController.loadingState.value)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody(LoadingState loadingState) {
|
||||
return switch (loadingState) {
|
||||
Loading() => SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 2,
|
||||
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
|
||||
childAspectRatio: StyleString.aspectRatio * 2.2,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return const VideoCardHSkeleton();
|
||||
},
|
||||
childCount: 10,
|
||||
),
|
||||
),
|
||||
Success() => (loadingState.response as List?)?.isNotEmpty == true
|
||||
? SliverPadding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.paddingOf(context).bottom + 80),
|
||||
sliver: SliverGrid(
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
mainAxisSpacing: 2,
|
||||
maxCrossAxisExtent: Grid.mediumCardWidth * 2,
|
||||
childAspectRatio: StyleString.aspectRatio * 2.7,
|
||||
),
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
return FavNoteItem(item: loadingState.response[index]);
|
||||
},
|
||||
childCount: loadingState.response.length,
|
||||
),
|
||||
),
|
||||
)
|
||||
: HttpError(callback: _favNoteController.onReload),
|
||||
Error() => HttpError(
|
||||
errMsg: loadingState.errMsg,
|
||||
callback: _favNoteController.onReload,
|
||||
),
|
||||
LoadingState() => throw UnimplementedError(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
22
lib/pages/fav/note/controller.dart
Normal file
22
lib/pages/fav/note/controller.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/pages/common/multi_select_controller.dart';
|
||||
|
||||
class FavNoteController extends MultiSelectController {
|
||||
FavNoteController(this.isPublish);
|
||||
|
||||
final bool isPublish;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
queryData();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<LoadingState> customGetData() {
|
||||
return isPublish
|
||||
? VideoHttp.userNoteList(page: currentPage)
|
||||
: VideoHttp.noteList(page: currentPage);
|
||||
}
|
||||
}
|
||||
87
lib/pages/fav/note/view.dart
Normal file
87
lib/pages/fav/note/view.dart
Normal file
@@ -0,0 +1,87 @@
|
||||
import 'package:PiliPlus/pages/fav/note/child_view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FavNotePage extends StatefulWidget {
|
||||
const FavNotePage({super.key});
|
||||
|
||||
@override
|
||||
State<FavNotePage> createState() => _FavNotePageState();
|
||||
}
|
||||
|
||||
class _FavNotePageState extends State<FavNotePage>
|
||||
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
|
||||
late final TabController _tabController =
|
||||
TabController(length: 2, vsync: this);
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: TabBar(
|
||||
overlayColor: WidgetStateProperty.all(Colors.transparent),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
isScrollable: true,
|
||||
tabAlignment: TabAlignment.start,
|
||||
controller: _tabController,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
dividerHeight: 0,
|
||||
indicatorWeight: 0,
|
||||
indicatorPadding:
|
||||
const EdgeInsets.symmetric(horizontal: 3, vertical: 8),
|
||||
indicator: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
labelStyle: TabBarTheme.of(context)
|
||||
.labelStyle
|
||||
?.copyWith(fontSize: 14) ??
|
||||
const TextStyle(fontSize: 14),
|
||||
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
||||
tabs: [
|
||||
Tab(text: '未发布笔记'),
|
||||
Tab(text: '公开笔记'),
|
||||
],
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
visualDensity: VisualDensity(horizontal: -2, vertical: -2),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
onPressed: () {},
|
||||
child: const Text('管理'),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
controller: _tabController,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
FavNoteChildPage(isPublish: false),
|
||||
FavNoteChildPage(isPublish: true),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
84
lib/pages/fav/note/widget/item.dart
Normal file
84
lib/pages/fav/note/widget/item.dart
Normal file
@@ -0,0 +1,84 @@
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:PiliPlus/common/widgets/network_img_layer.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FavNoteItem extends StatelessWidget {
|
||||
const FavNoteItem({super.key, required this.item});
|
||||
|
||||
final dynamic item;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Utils.handleWebview(item['web_url'], inApp: true);
|
||||
},
|
||||
onLongPress: () {},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: StyleString.safeSpace,
|
||||
vertical: 5,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
item['title'],
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
height: 1.4,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
Text(
|
||||
item['summary'],
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
Text(
|
||||
item['message'],
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (item['arc']?['pic'] != null) ...[
|
||||
const SizedBox(width: 10),
|
||||
AspectRatio(
|
||||
aspectRatio: StyleString.aspectRatio,
|
||||
child: LayoutBuilder(
|
||||
builder:
|
||||
(BuildContext context, BoxConstraints boxConstraints) {
|
||||
return NetworkImgLayer(
|
||||
src: item['arc']?['pic'],
|
||||
width: boxConstraints.maxWidth,
|
||||
height: boxConstraints.maxHeight,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,16 @@ class FavVideoPage extends StatefulWidget {
|
||||
State<FavVideoPage> createState() => _FavVideoPageState();
|
||||
}
|
||||
|
||||
class _FavVideoPageState extends State<FavVideoPage> {
|
||||
class _FavVideoPageState extends State<FavVideoPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final FavController _favController = Get.find<FavController>();
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return refreshIndicator(
|
||||
onRefresh: () async {
|
||||
await _favController.onRefresh();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/pages/fav/note/view.dart';
|
||||
import 'package:PiliPlus/pages/fav/video/index.dart';
|
||||
import 'package:PiliPlus/pages/fav_search/view.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -95,7 +96,7 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
|
||||
_FavType.bangumi => Center(child: Text(item.title)),
|
||||
_FavType.cinema => Center(child: Text(item.title)),
|
||||
_FavType.article => Center(child: Text(item.title)),
|
||||
_FavType.note => Center(child: Text(item.title)),
|
||||
_FavType.note => const FavNotePage(),
|
||||
},
|
||||
)
|
||||
.toList(),
|
||||
|
||||
@@ -43,15 +43,9 @@ class _MemberContributeState extends State<MemberContribute>
|
||||
return _controller.tabs != null
|
||||
? Column(
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Theme(
|
||||
data: ThemeData(
|
||||
splashColor: Colors.transparent,
|
||||
highlightColor: Colors.transparent,
|
||||
),
|
||||
child: TabBar(
|
||||
TabBar(
|
||||
overlayColor: WidgetStateProperty.all(Colors.transparent),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
isScrollable: true,
|
||||
tabs: _controller.tabs!,
|
||||
@@ -70,12 +64,9 @@ class _MemberContributeState extends State<MemberContribute>
|
||||
.labelStyle
|
||||
?.copyWith(fontSize: 14) ??
|
||||
const TextStyle(fontSize: 14),
|
||||
labelColor:
|
||||
Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
unselectedLabelColor: Theme.of(context).colorScheme.outline,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
|
||||
@@ -86,17 +86,12 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Container(
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
child: Theme(
|
||||
data: ThemeData(
|
||||
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明
|
||||
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明
|
||||
),
|
||||
child: TabBar(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
overlayColor: WidgetStateProperty.all(Colors.transparent),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
padding: const EdgeInsets.only(top: 4, left: 8, right: 8),
|
||||
controller: _tabController,
|
||||
tabs: SearchType.values
|
||||
.map(
|
||||
@@ -120,9 +115,8 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
labelColor: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
labelStyle: TabBarTheme.of(context)
|
||||
.labelStyle
|
||||
?.copyWith(fontSize: 13) ??
|
||||
labelStyle:
|
||||
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
|
||||
const TextStyle(fontSize: 13),
|
||||
dividerColor: Colors.transparent,
|
||||
dividerHeight: 0,
|
||||
@@ -137,7 +131,6 @@ class _SearchResultPageState extends State<SearchResultPage>
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
controller: _tabController,
|
||||
|
||||
@@ -1622,6 +1622,11 @@ class VideoDetailController extends GetxController
|
||||
}
|
||||
|
||||
void showNoteList(BuildContext context) async {
|
||||
String? title;
|
||||
try {
|
||||
title =
|
||||
Get.find<VideoIntroController>(tag: heroTag).videoDetail.value.title;
|
||||
} catch (_) {}
|
||||
if (plPlayerController.isFullScreen.value) {
|
||||
Utils.showFSSheet(
|
||||
context,
|
||||
@@ -1633,6 +1638,7 @@ class VideoDetailController extends GetxController
|
||||
enableSlide: false,
|
||||
heroTag: heroTag,
|
||||
isStein: graphVersion != null,
|
||||
title: title,
|
||||
),
|
||||
)
|
||||
: NoteListPage(
|
||||
@@ -1640,6 +1646,7 @@ class VideoDetailController extends GetxController
|
||||
enableSlide: false,
|
||||
heroTag: heroTag,
|
||||
isStein: graphVersion != null,
|
||||
title: title,
|
||||
),
|
||||
isFullScreen: () => plPlayerController.isFullScreen.value,
|
||||
);
|
||||
@@ -1650,6 +1657,7 @@ class VideoDetailController extends GetxController
|
||||
oid: oid.value,
|
||||
heroTag: heroTag,
|
||||
isStein: graphVersion != null,
|
||||
title: title,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@ class NoteListPage extends CommonSlidePage {
|
||||
this.oid,
|
||||
this.upperMid,
|
||||
required this.isStein,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
final dynamic heroTag;
|
||||
final dynamic oid;
|
||||
final dynamic upperMid;
|
||||
final bool isStein;
|
||||
final dynamic title;
|
||||
|
||||
@override
|
||||
State<NoteListPage> createState() => _NoteListPageState();
|
||||
@@ -109,6 +111,8 @@ class _NoteListPageState extends CommonSlidePageState<NoteListPage> {
|
||||
onPressed: () {
|
||||
_key.currentState?.showBottomSheet(
|
||||
(context) => WebviewPageNew(
|
||||
oid: widget.oid,
|
||||
title: widget.title,
|
||||
url:
|
||||
'https://www.bilibili.com/h5/note-app?oid=${widget.oid}&pagefrom=ugcvideo&is_stein_gate=${widget.isStein ? 1 : 0}',
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/app_scheme.dart';
|
||||
import 'package:PiliPlus/utils/cache_manage.dart';
|
||||
@@ -33,17 +34,23 @@ extension _WebviewMenuItemExt on _WebviewMenuItem {
|
||||
}
|
||||
|
||||
class WebviewPageNew extends StatefulWidget {
|
||||
const WebviewPageNew({super.key, this.url});
|
||||
const WebviewPageNew(
|
||||
{super.key, this.url, this.oid, this.title, this.uaType});
|
||||
|
||||
final String? url;
|
||||
|
||||
// note
|
||||
final int? oid;
|
||||
final String? title;
|
||||
final String? uaType;
|
||||
|
||||
@override
|
||||
State<WebviewPageNew> createState() => _WebviewPageNewState();
|
||||
}
|
||||
|
||||
class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||
late final String _url = widget.url ?? Get.parameters['url'] ?? '';
|
||||
final uaType = Get.parameters['uaType'] ?? 'mob';
|
||||
late final uaType = widget.uaType ?? Get.parameters['uaType'] ?? 'mob';
|
||||
final _titleStream = StreamController<String?>();
|
||||
final _progressStream = StreamController<double>();
|
||||
bool? _inApp;
|
||||
@@ -183,7 +190,21 @@ class _WebviewPageNewState extends State<WebviewPageNew> {
|
||||
_webViewController?.addJavaScriptHandler(
|
||||
handlerName: 'finishButtonClicked',
|
||||
callback: (args) {
|
||||
_webViewController?.evaluateJavascript(source: """
|
||||
Array.from(document.querySelectorAll('.ql-editor > p')).map(p => p.textContent).join('\\n');
|
||||
""").then((value) {
|
||||
try {
|
||||
String? summary = (value as String?);
|
||||
if (summary?.isNotEmpty == true) {
|
||||
VideoHttp.addNote(
|
||||
oid: widget.oid!,
|
||||
title: widget.title!,
|
||||
summary: summary!,
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
Get.back();
|
||||
});
|
||||
},
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user