增加底栏插槽和沉浸式底栏效果
parent
484810d390
commit
8ee569bcef
@ -1,6 +1,15 @@
|
||||
package cn.isekai.wiki.isekai_wiki
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
window.setDecorFitsSystemWindows(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1,53 @@
|
||||
class MWApiParse {}
|
||||
import 'package:isekai_wiki/api/mw/mw_api.dart';
|
||||
import 'package:isekai_wiki/api/response/parse.dart';
|
||||
import 'package:isekai_wiki/global.dart';
|
||||
|
||||
class MWApiParse {
|
||||
static Future<MWResponse<MWParseInfo>> parse({
|
||||
String? title,
|
||||
int? pageId,
|
||||
List<String>? prop,
|
||||
String? useSkin,
|
||||
String? section,
|
||||
bool disableEditSection = true,
|
||||
bool disableTOC = true,
|
||||
bool mobileMode = true,
|
||||
}) async {
|
||||
prop ??= [
|
||||
"text",
|
||||
"langlinks",
|
||||
"categories",
|
||||
"links",
|
||||
"templates",
|
||||
"images",
|
||||
"externallinks",
|
||||
"sections",
|
||||
"revid",
|
||||
"displaytitle",
|
||||
"iwlinks",
|
||||
"properties",
|
||||
"parsewarnings",
|
||||
"modules",
|
||||
"jsconfigvars",
|
||||
];
|
||||
|
||||
useSkin ??= Global.siteConfig.renderTheme;
|
||||
|
||||
Map<String, dynamic> query = {
|
||||
"prop": prop.join("|"),
|
||||
"useskin": useSkin,
|
||||
};
|
||||
|
||||
if (title != null) query["page"] = title;
|
||||
if (pageId != null) query["pageid"] = pageId;
|
||||
if (disableEditSection) query["disableeditsection"] = 1;
|
||||
if (section != null) query["section"] = section;
|
||||
if (disableTOC) query["disabletoc"] = 1;
|
||||
if (mobileMode) query["mobilenode"] = 1;
|
||||
|
||||
var mwRes = await MWApi.get("parse", params: query);
|
||||
var parseInfo = MWParseInfo.fromJson(mwRes.data);
|
||||
|
||||
return mwRes.replaceData(parseInfo);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
class SimpleTemplate {
|
||||
String? tpl;
|
||||
|
||||
SimpleTemplate({this.tpl});
|
||||
|
||||
String fetch(Map<String, String> params) {
|
||||
if (tpl == null) return "";
|
||||
|
||||
var re = RegExp(r"{{(?<name>[^,;:'\n]+?)}}");
|
||||
|
||||
return tpl!.replaceAllMapped(re, (match) {
|
||||
var key = match.group(1)!.trim();
|
||||
if (params.containsKey(key)) {
|
||||
return params[key]!;
|
||||
}
|
||||
return match.group(0)!;
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue