|
|
|
|
@ -38,17 +38,14 @@ class WikiInfoPageController extends GetxController {
|
|
|
|
|
pageInfoRes = await MWApiList.getPageInfoList(pageids: [
|
|
|
|
|
pageId.value
|
|
|
|
|
], prop: [
|
|
|
|
|
"extracts",
|
|
|
|
|
"info",
|
|
|
|
|
"pageimages",
|
|
|
|
|
"pageviews"
|
|
|
|
|
], extraParams: {
|
|
|
|
|
"inprop":
|
|
|
|
|
"url|protection|watched|watchers|visitingwatchers|displaytitle",
|
|
|
|
|
"inprop": "url|protection|watched|watchers|visitingwatchers|displaytitle",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
pageInfoRes =
|
|
|
|
|
await MWApiList.getPageInfoList(titles: [pageTitle.value]);
|
|
|
|
|
pageInfoRes = await MWApiList.getPageInfoList(titles: [pageTitle.value]);
|
|
|
|
|
}
|
|
|
|
|
if (pageInfoRes.data.isEmpty) {
|
|
|
|
|
throw MWApiErrorException(code: 'no-page', info: "页面信息丢失");
|
|
|
|
|
@ -58,8 +55,7 @@ class WikiInfoPageController extends GetxController {
|
|
|
|
|
pageId.value = pageInfo.value!.pageid;
|
|
|
|
|
pageTitle.value = pageInfo.value!.title;
|
|
|
|
|
} catch (err, stack) {
|
|
|
|
|
alert(Get.overlayContext!, ErrorUtils.getErrorMessage(err),
|
|
|
|
|
title: "错误");
|
|
|
|
|
alert(Get.overlayContext!, ErrorUtils.getErrorMessage(err), title: "错误");
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
print("Exception in page: $err");
|
|
|
|
|
stack.printError();
|
|
|
|
|
@ -90,13 +86,14 @@ class _WikiInfoPageState extends ReactiveState<WikiInfoPage> {
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
c = Get.put(c);
|
|
|
|
|
Get.put(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
c.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
|
|
|
|
Get.delete<WikiInfoPageController>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -112,16 +109,14 @@ class _WikiInfoPageState extends ReactiveState<WikiInfoPage> {
|
|
|
|
|
children: <CupertinoListTile>[
|
|
|
|
|
CupertinoListTile.notched(
|
|
|
|
|
title: Center(
|
|
|
|
|
child: CupertinoActivityIndicator(
|
|
|
|
|
radius: 10 * MediaQuery.of(context).textScaleFactor),
|
|
|
|
|
child: CupertinoActivityIndicator(radius: 10 * MediaQuery.of(context).textScaleFactor),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CupertinoListTile buildPageInfo(
|
|
|
|
|
BuildContext context, String label, dynamic value,
|
|
|
|
|
CupertinoListTile buildPageInfo(BuildContext context, String label, dynamic value,
|
|
|
|
|
{VoidFutureCallback? onTap}) {
|
|
|
|
|
final Locale appLocale = Localizations.localeOf(context);
|
|
|
|
|
var valueStr = "未知";
|
|
|
|
|
@ -129,8 +124,7 @@ class _WikiInfoPageState extends ReactiveState<WikiInfoPage> {
|
|
|
|
|
valueStr = value;
|
|
|
|
|
}
|
|
|
|
|
if (value is int) {
|
|
|
|
|
valueStr =
|
|
|
|
|
NumberFormat.decimalPattern(appLocale.toLanguageTag()).format(value);
|
|
|
|
|
valueStr = NumberFormat.decimalPattern(appLocale.toLanguageTag()).format(value);
|
|
|
|
|
} else if (value is double) {
|
|
|
|
|
var pattern = NumberFormat.decimalPattern(appLocale.toLanguageTag());
|
|
|
|
|
pattern.maximumFractionDigits = 2;
|
|
|
|
|
@ -146,48 +140,62 @@ class _WikiInfoPageState extends ReactiveState<WikiInfoPage> {
|
|
|
|
|
padding: const EdgeInsetsDirectional.fromSTEB(20.0, 10.0, 14.0, 10.0),
|
|
|
|
|
title: Container(
|
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
|
child: AutoWrap(
|
|
|
|
|
child: ResponsivePair(
|
|
|
|
|
children: [
|
|
|
|
|
Text(label),
|
|
|
|
|
Text(
|
|
|
|
|
valueStr,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: CupertinoColors.systemGrey2.resolveFrom(context)),
|
|
|
|
|
style: TextStyle(color: CupertinoColors.systemGrey2.resolveFrom(context)),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
trailing: onTap != null ? const CupertinoListTileChevron() : null,
|
|
|
|
|
trailing: onTap != null
|
|
|
|
|
? const Padding(
|
|
|
|
|
padding: EdgeInsets.only(left: 8),
|
|
|
|
|
child: CupertinoListTileChevron(),
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int? getPageViews(Map<DateTime, int?>? pageViews) {
|
|
|
|
|
if (pageViews == null) return null;
|
|
|
|
|
|
|
|
|
|
int validData = 0;
|
|
|
|
|
int visitSum = 0;
|
|
|
|
|
pageViews.forEach((key, value) {
|
|
|
|
|
if (value != null) {
|
|
|
|
|
validData++;
|
|
|
|
|
visitSum += value;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return validData != 0 ? visitSum : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget buildPageInfoList(BuildContext context) {
|
|
|
|
|
var pageInfo = c.pageInfo.value;
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
Obx(
|
|
|
|
|
() => CupertinoListSection.insetGrouped(
|
|
|
|
|
additionalDividerMargin: 6,
|
|
|
|
|
header: const Text("基本信息"),
|
|
|
|
|
backgroundColor: CupertinoTheme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
children: <CupertinoListTile>[
|
|
|
|
|
buildPageInfo(
|
|
|
|
|
context,
|
|
|
|
|
"显示标题",
|
|
|
|
|
pageInfo?.mainTitle,
|
|
|
|
|
onTap: () async {},
|
|
|
|
|
),
|
|
|
|
|
buildPageInfo(context, "页面长度(字节)", pageInfo?.length),
|
|
|
|
|
buildPageInfo(context, "页面ID", pageInfo?.pageid),
|
|
|
|
|
buildPageInfo(context, "页面内容语言", pageInfo?.pagelanguage),
|
|
|
|
|
buildPageInfo(context, "页面内容类型", pageInfo?.contentmodel),
|
|
|
|
|
buildPageInfo(context, "收藏者数", pageInfo?.watchers),
|
|
|
|
|
buildPageInfo(context, "最后修改于", pageInfo?.updatedTime),
|
|
|
|
|
buildPageInfo(context, "该页面的子页面数", null),
|
|
|
|
|
buildPageInfo(context, "过去30天的页面访问量", null),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
CupertinoListSection.insetGrouped(
|
|
|
|
|
additionalDividerMargin: 6,
|
|
|
|
|
header: const Text("基本信息"),
|
|
|
|
|
backgroundColor: CupertinoTheme.of(context).scaffoldBackgroundColor,
|
|
|
|
|
children: <CupertinoListTile>[
|
|
|
|
|
buildPageInfo(context, "页面标题", pageInfo?.title),
|
|
|
|
|
buildPageInfo(context, "显示标题", pageInfo?.mainTitle),
|
|
|
|
|
buildPageInfo(context, "页面长度(字节)", pageInfo?.length),
|
|
|
|
|
buildPageInfo(context, "页面ID", pageInfo?.pageid),
|
|
|
|
|
buildPageInfo(context, "页面内容语言", pageInfo?.pagelanguage),
|
|
|
|
|
buildPageInfo(context, "页面内容类型", pageInfo?.contentmodel),
|
|
|
|
|
buildPageInfo(context, "收藏者数", pageInfo?.watchers),
|
|
|
|
|
buildPageInfo(context, "更新后已查看的收藏者", pageInfo?.visitingwatchers),
|
|
|
|
|
buildPageInfo(context, "最后修改于", pageInfo?.updatedTime),
|
|
|
|
|
buildPageInfo(context, "该页面的子页面数", null),
|
|
|
|
|
buildPageInfo(context, "过去30天的页面访问量", getPageViews(pageInfo?.pageviews)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
@ -202,9 +210,7 @@ class _WikiInfoPageState extends ReactiveState<WikiInfoPage> {
|
|
|
|
|
child: SafeArea(
|
|
|
|
|
child: ListView(
|
|
|
|
|
children: [
|
|
|
|
|
Obx(() => c.loadingPageInfo.value
|
|
|
|
|
? buildLoading(context)
|
|
|
|
|
: buildPageInfoList(context))
|
|
|
|
|
Obx(() => c.loadingPageInfo.value ? buildLoading(context) : buildPageInfoList(context))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|