mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 新增电脑版登录
This commit is contained in:
@@ -40,9 +40,9 @@ class WebviewController extends GetxController {
|
||||
webviewInit();
|
||||
}
|
||||
|
||||
webviewInit() {
|
||||
webviewInit({String uaType = 'mob'}) {
|
||||
controller
|
||||
..setUserAgent(Request().headerUa())
|
||||
..setUserAgent(Request().headerUa(type: uaType))
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
|
||||
@@ -27,29 +27,32 @@ class _WebviewPageState extends State<WebviewPage> {
|
||||
actions: [
|
||||
const SizedBox(width: 4),
|
||||
IconButton(
|
||||
tooltip: '刷新',
|
||||
tooltip: '刷新网页',
|
||||
onPressed: () {
|
||||
_webviewController.controller.reload();
|
||||
},
|
||||
icon: Icon(Icons.refresh_outlined,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: '用外部浏览器打开',
|
||||
onPressed: () {
|
||||
launchUrl(Uri.parse(_webviewController.url));
|
||||
},
|
||||
icon: Icon(Icons.open_in_browser_outlined,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
Obx(
|
||||
() => _webviewController.type.value == 'login'
|
||||
? TextButton(
|
||||
onPressed: () => _webviewController.confirmLogin(null),
|
||||
child: const Text('刷新登录状态'),
|
||||
)
|
||||
: const SizedBox(),
|
||||
),
|
||||
if (_webviewController.type.value != 'login')
|
||||
IconButton(
|
||||
tooltip: '用外部浏览器打开',
|
||||
onPressed: () {
|
||||
launchUrl(Uri.parse(_webviewController.url));
|
||||
},
|
||||
icon: Icon(Icons.open_in_browser_outlined,
|
||||
color: Theme.of(context).colorScheme.primary),
|
||||
),
|
||||
if (_webviewController.type.value == 'login')...<Widget>[
|
||||
TextButton(
|
||||
onPressed: () => _webviewController.confirmLogin(null),
|
||||
child: const Text('刷新登录态'),
|
||||
),
|
||||
TextButton(
|
||||
child: const Text('电脑版'),
|
||||
onPressed: () => _webviewController.webviewInit(uaType: 'pc'),
|
||||
)
|
||||
],
|
||||
const SizedBox(width: 12)
|
||||
],
|
||||
),
|
||||
@@ -66,14 +69,23 @@ class _WebviewPageState extends State<WebviewPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_webviewController.type.value == 'login')
|
||||
if (_webviewController.type.value == 'login') ...<Widget>[
|
||||
Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12, right: 12, top: 6, bottom: 6),
|
||||
child: const Text('登录成功未自动跳转? 请点击右上角「刷新登录状态」'),
|
||||
child: const Text('登录成功未自动跳转? 请点击右上角「刷新登录态」'),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).colorScheme.onInverseSurface,
|
||||
padding: const EdgeInsets.only(
|
||||
left: 12, right: 12, top: 6, bottom: 6),
|
||||
child: const Text('如需二维码登录,请点击「电脑版」,放大左侧二维码,截图后官方app或另一设备扫码,授权后点击「刷新登录态」'),
|
||||
),
|
||||
],
|
||||
Expanded(
|
||||
child: WebViewWidget(controller: _webviewController.controller),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user