Skip to content

Commit

Permalink
mod: analysis rules
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Nov 3, 2024
1 parent d3c138e commit 23c432f
Show file tree
Hide file tree
Showing 7 changed files with 353 additions and 309 deletions.
19 changes: 10 additions & 9 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PODS:
- Flutter
- share_plus (0.0.1):
- Flutter
- sqflite (0.0.3):
- sqflite_darwin (0.0.4):
- Flutter
- FlutterMacOS
- system_proxy (0.0.1):
Expand All @@ -40,6 +40,7 @@ PODS:
- FlutterMacOS
- webview_flutter_wkwebview (0.0.1):
- Flutter
- FlutterMacOS

DEPENDENCIES:
- appscheme (from `.symlinks/plugins/appscheme/ios`)
Expand All @@ -53,11 +54,11 @@ DEPENDENCIES:
- photo_manager (from `.symlinks/plugins/photo_manager/ios`)
- quick_actions_ios (from `.symlinks/plugins/quick_actions_ios/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`)
- sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
- system_proxy (from `.symlinks/plugins/system_proxy/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`)
- webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/darwin`)

SPEC REPOS:
trunk:
Expand Down Expand Up @@ -86,20 +87,20 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/quick_actions_ios/ios"
share_plus:
:path: ".symlinks/plugins/share_plus/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/darwin"
sqflite_darwin:
:path: ".symlinks/plugins/sqflite_darwin/darwin"
system_proxy:
:path: ".symlinks/plugins/system_proxy/ios"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"
video_player_avfoundation:
:path: ".symlinks/plugins/video_player_avfoundation/darwin"
webview_flutter_wkwebview:
:path: ".symlinks/plugins/webview_flutter_wkwebview/ios"
:path: ".symlinks/plugins/webview_flutter_wkwebview/darwin"

SPEC CHECKSUMS:
appscheme: b1c3f8862331cb20430cf9e0e4af85dbc1572ad8
device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview: acd4fc0f012cefd09015000c241137d82f01ba62
flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743
Expand All @@ -110,11 +111,11 @@ SPEC CHECKSUMS:
photo_manager: ff695c7a1dd5bc379974953a2b5c0a293f7c4c8a
quick_actions_ios: 56f3cbaa71e94f212838d1f9fe354bd0734779bf
share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
system_proxy: bec1a5c5af67dd3e3ebf43979400a8756c04cc44
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3
webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36
webview_flutter_wkwebview: 0982481e3d9c78fd5c6f62a002fcd24fc791f1e4

PODFILE CHECKSUM: abc46fbd35967699006ecac60273b298ad8f246d

Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit
import Flutter
import flutter_local_notifications

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
138 changes: 47 additions & 91 deletions lib/http/topic.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'package:dio/dio.dart';
import 'package:html/parser.dart';
import 'package:html/dom.dart' as dom;
Expand Down Expand Up @@ -60,8 +61,7 @@ class TopicWebApi {
return detailModel;
}

var rootDom = parse(response.data);
var userCellWrap = rootDom
var userCellWrap = document
.querySelectorAll('div#site-header-menu > div#menu-body > div.cell');
var onceHref = userCellWrap.last.querySelector('a')!.attributes['href'];
int once = int.parse(onceHref!.split('once=')[1]);
Expand Down Expand Up @@ -139,9 +139,9 @@ class TopicWebApi {
}

// 判断是否有正文
if (document.querySelector('$mainBoxQuery > div.cell > div') != null) {
var contentDom =
document.querySelector('$mainBoxQuery > div.cell > div')!;
final dom.Element? contentDom =
document.querySelector('$mainBoxQuery > div.cell > div');
if (contentDom != null) {
detailModel.content = contentDom.text;
// List decodeRes = Utils.base64Decode(contentDom);
// if (decodeRes.isNotEmpty) {
Expand Down Expand Up @@ -179,19 +179,6 @@ class TopicWebApi {
.text
.replaceFirst(' +08:00', ''); // 时间(去除+ 08:00);
var contentDom = node.querySelector('div.topic_content')!;
// List decodeRes = Utils.base64Decode(contentDom);
// if (decodeRes.isNotEmpty) {
// var decodeDom = '';
// for (var i = 0; i < decodeRes.length; i++) {
// decodeDom +=
// '<a href="base64Wechat: ${decodeRes[i]}">${decodeRes[i]}</a>';
// if (i != decodeRes.length - 1) {
// decodeDom += '<span>、</span>';
// }
// }
// contentDom.nodes.insert(contentDom.nodes.length,
// parseFragment('<p>base64解码:$decodeDom</p>'));
// }
subtleItem.content = Utils.linkMatch(contentDom);
if (node.querySelector('div.topic_content')!.querySelector('img') !=
null) {
Expand All @@ -209,15 +196,13 @@ class TopicWebApi {
detailModel.subtleList = subtleList;

// 收藏、感谢、屏蔽区域 未登录为null
if (document.querySelector("$innerQuery > div > a[class='op']") != null) {
var opElement = document.querySelector("$innerQuery > div > a[class='op']");
if (opElement != null) {
// 收藏状态 isFavorite:true 已收藏
String collect = document
.querySelector("$innerQuery > div > a[class='op']")!
.attributes["href"]!;
String collect = opElement.attributes["href"]!;
detailModel.isFavorite = collect.startsWith('/unfavorite');

// once

var menuBodyNode = document.querySelector("div[id='menu-body']");
var loginOutNode =
menuBodyNode!.querySelectorAll('div.cell').last.querySelector('a');
Expand All @@ -226,10 +211,12 @@ class TopicWebApi {
GStorage().setOnce(once);

// 收藏人数
if (document.querySelector("$innerQuery > div > span") != null) {
String count = document.querySelector("$innerQuery > div > span")!.text;
if (count.contains('人收藏')) {
detailModel.favoriteCount = int.parse(count.trim().split('人收藏')[0]);
var spanElement = document.querySelector("$innerQuery > div > span");
if (spanElement != null) {
final regex = RegExp(r'(\d+)');
final match = regex.firstMatch(spanElement.text);
if (match != null) {
detailModel.favoriteCount = int.parse(match.group(1)!);
}
}

Expand Down Expand Up @@ -280,32 +267,29 @@ class TopicWebApi {
/// 回复楼层
/// first td user avatar
/// third td main content
List<dom.Element> rootNode = document
.querySelectorAll("#Wrapper > div > div[class='box'] > div[id]");
List<dom.Element> rootNode =
document.querySelectorAll("#Wrapper .box > div[id].cell");
var replyTrQuery = 'table > tbody > tr';
for (var aNode in rootNode) {
ReplyItem replyItem = ReplyItem();
replyItem.avatar = Uri.encodeFull(aNode
.querySelector('$replyTrQuery > td:nth-child(1) > img')!
final dom.Element replyItemEl = aNode.querySelector(replyTrQuery)!;
final dom.Element mainContentEl =
replyItemEl.querySelector('td:nth-child(5)')!;

replyItem.avatar = Uri.encodeFull(replyItemEl
.querySelector('td:nth-child(1) > img')!
.attributes["src"]!);
replyItem.userName = aNode
.querySelector('$replyTrQuery > td:nth-child(5) > strong > a')!
.text;
if (aNode.querySelector(
'$replyTrQuery > td:nth-child(5) > div.badges > div.badge') !=
null) {
String status = aNode
.querySelector(
'$replyTrQuery > td:nth-child(5) > div.badges > div.badge')!
.text;
if (status == 'MOD') {
replyItem.isMod = true;
} else if (status == 'OP') {
replyItem.isOwner = true;
}
replyItem.userName = mainContentEl.querySelector('strong > a')!.text;
var badgeElement =
mainContentEl.querySelector('div.badges > div.badge');
String? status = badgeElement?.text;
if (status == 'MOD') {
replyItem.isMod = true;
} else if (status == 'OP') {
replyItem.isOwner = true;
}
replyItem.lastReplyTime = aNode
.querySelector('$replyTrQuery > td:nth-child(5) > span')!
replyItem.lastReplyTime = mainContentEl
.querySelector('span.fade.small')!
.text
.replaceFirst(' +08:00', ''); // 时间(去除+ 08:00)和平台(Android/iPhone)
if (replyItem.lastReplyTime.contains('via')) {
Expand All @@ -318,63 +302,35 @@ class TopicWebApi {
}

/// @user
if (aNode.querySelector(
"$replyTrQuery > td:nth-child(5) > span[class='small fade']") !=
null) {
replyItem.favorites = int.parse(aNode
.querySelector(
"$replyTrQuery > td:nth-child(5) > span[class='small fade']")!
if (mainContentEl.querySelector("span[class='small fade']") != null) {
replyItem.favorites = int.parse(mainContentEl
.querySelector("span[class='small fade']")!
.text
.split(" ")[1]);
// 感谢状态
if (aNode.querySelector(
"$replyTrQuery > td:nth-child(5) > div.fr > div.thanked") !=
null) {
if (mainContentEl.querySelector("div.fr > div.thanked") != null) {
replyItem.favoritesStatus = true;
}
}
// replyItem.number = aNode
// .querySelector(
// '$replyTrQuery > td:nth-child(5) > div.fr > span')!
// .text;
replyItem.floorNumber = int.parse(aNode
.querySelector('$replyTrQuery > td:nth-child(5) > div.fr > span')!
.text);
var contentDom = aNode.querySelector(
'$replyTrQuery > td:nth-child(5) > div.reply_content')!;
// List decodeRes = Utils.base64Decode(contentDom);
// if (decodeRes.isNotEmpty) {
// var decodeDom = '';
// for (var i = 0; i < decodeRes.length; i++) {
// decodeDom +=
// '<a href="base64Wechat: ${decodeRes[i]}">${decodeRes[i]}</a>';
// if (i != decodeRes.length - 1) {
// decodeDom += '<span>、</span>';
// }
// }
// contentDom.nodes.insert(contentDom.nodes.length,
// parseFragment('<p>base64解码:$decodeDom</p>'));
// }
replyItem.floorNumber =
int.parse(mainContentEl.querySelector('div.fr > span')!.text);
var contentDom = mainContentEl.querySelector('div.reply_content')!;
replyItem.contentRendered = Utils.linkMatch(contentDom);
replyItem.content = aNode
.querySelector(
'$replyTrQuery > td:nth-child(5) > div.reply_content')!
.text;
if (aNode
.querySelector(
'$replyTrQuery > td:nth-child(5) > div.reply_content')!
replyItem.content =
mainContentEl.querySelector('div.reply_content')!.text;
if (mainContentEl
.querySelector('div.reply_content')!
.querySelector('img') !=
null) {
var imgNodes = aNode
.querySelector(
'$replyTrQuery > td:nth-child(5) > div.reply_content')!
var imgNodes = mainContentEl
.querySelector('div.reply_content')!
.querySelectorAll('img');
for (var imgNode in imgNodes) {
replyItem.imgList.add(Utils().imageUrl(imgNode.attributes['src']!));
}
}
var replyMemberNodes = aNode.querySelectorAll(
'$replyTrQuery > td:nth-child(5) > div.reply_content > a');
var replyMemberNodes =
mainContentEl.querySelectorAll('div.reply_content > a');
if (replyMemberNodes.isNotEmpty) {
for (var aNode in replyMemberNodes) {
if (aNode.attributes['href']!.startsWith('/member')) {
Expand Down
Loading

0 comments on commit 23c432f

Please sign in to comment.