feat:筛选全来源专属化+抖音 Port 真机接线(6 轮迭代):
- 来源 chips 精简知乎/微博/抖音,小红书移除,通用筛选 UI 下线(配置保留) - 知乎专属筛选(卡片区间)+抖音专属筛选(前 N 条+标签过滤)落地 - 我的页统一通用配置命名,来源管理入口并入首页 - DouyinDevicePort 真机实现 + ACTION_TEST_DOUYIN 沙盒(清单/单条双模式) - 6 轮迭代修 5 真机缺陷:Splash 壳包名不可读/搜索钮判据/树摘要化改 OCR 路线/OCR 错字容错/浮层挡 Tab - 303 项 JVM 全过;沙盒推进至 OPEN_HOT_TAB(浮层修复待复验) Co-Authored-By: Claude Code <[email protected]>
This commit is contained in:
@@ -428,6 +428,8 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
|||||||
addAction("com.haorui.app.ACTION_TEST_ZHIHU")
|
addAction("com.haorui.app.ACTION_TEST_ZHIHU")
|
||||||
// 微博类目采集沙盒(debug APK:类目词条清单 + 单条内容全链)
|
// 微博类目采集沙盒(debug APK:类目词条清单 + 单条内容全链)
|
||||||
addAction("com.haorui.app.ACTION_TEST_WEIBO")
|
addAction("com.haorui.app.ACTION_TEST_WEIBO")
|
||||||
|
// 抖音热榜采集沙盒(debug APK:listOnly=清单;entryIndex=单条详情)
|
||||||
|
addAction("com.haorui.app.ACTION_TEST_DOUYIN")
|
||||||
// 调试输入法直写(M4 文章编辑器;需先 adb ime set 切到浩瑞调试输入法)
|
// 调试输入法直写(M4 文章编辑器;需先 adb ime set 切到浩瑞调试输入法)
|
||||||
addAction("com.haorui.app.ACTION_IME_COMMIT")
|
addAction("com.haorui.app.ACTION_IME_COMMIT")
|
||||||
// 文章发布机链路验证(debug APK:编辑器写入→回读→草稿确认;不碰「下一步」)
|
// 文章发布机链路验证(debug APK:编辑器写入→回读→草稿确认;不碰「下一步」)
|
||||||
@@ -671,6 +673,13 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
|||||||
"entry=$entryIndex collectOnlyList=$collectOnlyList composeVerify=$composeVerify topics=${topics.size})",
|
"entry=$entryIndex collectOnlyList=$collectOnlyList composeVerify=$composeVerify topics=${topics.size})",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
// 抖音采集沙盒(debug APK;listOnly=1 只拉清单;entryIndex=单条详情序号)
|
||||||
|
"com.haorui.app.ACTION_TEST_DOUYIN" -> {
|
||||||
|
val entryIndex = intent.getStringExtra("entryIndex")?.toIntOrNull() ?: 0
|
||||||
|
val listOnly = intent.getBooleanExtra("listOnly", true)
|
||||||
|
val accepted = startDouyinCollectSandbox(entryIndex, listOnly)
|
||||||
|
RunLogger.i(TAG, "抖音采集沙盒受理=$accepted(广播 ACTION_TEST_DOUYIN entry=$entryIndex listOnly=$listOnly)")
|
||||||
|
}
|
||||||
// 调试输入法直写(M4 文章编辑器自绘控件写入;commitText 分批,回读走 OCR)
|
// 调试输入法直写(M4 文章编辑器自绘控件写入;commitText 分批,回读走 OCR)
|
||||||
"com.haorui.app.ACTION_IME_COMMIT" -> {
|
"com.haorui.app.ACTION_IME_COMMIT" -> {
|
||||||
val text = intent.getStringExtra("text").orEmpty()
|
val text = intent.getStringExtra("text").orEmpty()
|
||||||
@@ -1223,6 +1232,63 @@ class HaoRuiAccessibilityService : AccessibilityService() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抖音采集沙盒(debug APK,只读):listOnly=1 拉热榜清单(OCR 行解析,日志逐条输出);
|
||||||
|
* 否则采集第 entryIndex 条词条详情(相对时间折算,作者/正文未核验留 null 记 unknowns)。
|
||||||
|
* 前台占用/互斥与知乎沙盒同口径。
|
||||||
|
*/
|
||||||
|
fun startDouyinCollectSandbox(entryIndex: Int, listOnly: Boolean): Boolean =
|
||||||
|
synchronized(stepLifecycleLock) {
|
||||||
|
if (applicationInfo.flags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE == 0 ||
|
||||||
|
!::scheduler.isInitialized || scheduler.isRunning || publisher.isWorking || interactor.isWorking ||
|
||||||
|
frontGuard.creditNavigating || !foregroundCoordinator.isIdle()) return@synchronized false
|
||||||
|
launchForegroundTask {
|
||||||
|
val ticket = foregroundCoordinator.tryEnterLegacy("DOUYIN-SANDBOX") ?: return@launchForegroundTask
|
||||||
|
try {
|
||||||
|
val port = com.haorui.app.crossplatform.source.douyin.DouyinDevicePort(this@HaoRuiAccessibilityService)
|
||||||
|
val machine = com.haorui.app.crossplatform.source.douyin.DouyinHotListCollector(port) { SystemClock.elapsedRealtime() }
|
||||||
|
machine.runGeneration = startGeneration.toLong()
|
||||||
|
if (listOnly) {
|
||||||
|
RunLogger.i(TAG, "抖音采集沙盒开始:清单模式")
|
||||||
|
val list = machine.collectHotList()
|
||||||
|
RunLogger.i(
|
||||||
|
TAG,
|
||||||
|
"抖音采集沙盒清单: outcome=${list.outcome} phase=${list.phase} " +
|
||||||
|
"entries=${list.entries.size} exited=${list.exitedSafely} reason=${list.reason}",
|
||||||
|
)
|
||||||
|
list.entries.forEachIndexed { i, e ->
|
||||||
|
RunLogger.i(
|
||||||
|
TAG,
|
||||||
|
"抖音热榜[$i]: 排名=${e.rank} 标题=${e.title.take(24)} " +
|
||||||
|
"标签=${e.label} 热度=${e.heatRaw}",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
RunLogger.i(TAG, "抖音采集沙盒开始:单条模式 entry=$entryIndex")
|
||||||
|
val result = machine.collectOne(entryIndex)
|
||||||
|
RunLogger.i(
|
||||||
|
TAG,
|
||||||
|
"抖音采集沙盒结果: outcome=${result.outcome} phase=${result.phase} " +
|
||||||
|
"exited=${result.exitedSafely} reason=${result.reason}",
|
||||||
|
)
|
||||||
|
result.observation?.let { obs ->
|
||||||
|
RunLogger.i(
|
||||||
|
TAG,
|
||||||
|
"抖音采集沙盒观察: 标题=${obs.hotEntry?.title?.take(24)} 排名=${obs.hotEntry?.rank} " +
|
||||||
|
"热度=${obs.hotEntry?.heatRaw} 发布时间=${obs.publishedAtText}(${obs.publishedAtMs}) " +
|
||||||
|
"未知=${obs.unknowns}",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (t: Throwable) {
|
||||||
|
RunLogger.e(TAG, "抖音采集沙盒异常: ${t.javaClass.simpleName}:${t.message}", t)
|
||||||
|
} finally {
|
||||||
|
foregroundCoordinator.release(ticket)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* M4 创作链真机验证(debug APK):采集单条 → OCR 全文 → 事实包 → 模型标题候选。
|
* M4 创作链真机验证(debug APK):采集单条 → OCR 全文 → 事实包 → 模型标题候选。
|
||||||
* 只读+模型调用,不落库、不发布;结果全走日志(标题候选逐条输出)。
|
* 只读+模型调用,不落库、不发布;结果全走日志(标题候选逐条输出)。
|
||||||
|
|||||||
@@ -35,9 +35,18 @@ data class CrossPlatformConfig(
|
|||||||
val weiboHotCategories: List<String> = emptyList(),
|
val weiboHotCategories: List<String> = emptyList(),
|
||||||
/** 微博热搜词条勾选(类目 id → 勾选的词条标题;重启不丢,重启后榜单已刷新——按标题在新榜单中匹配,匹配不到保留待核)。 */
|
/** 微博热搜词条勾选(类目 id → 勾选的词条标题;重启不丢,重启后榜单已刷新——按标题在新榜单中匹配,匹配不到保留待核)。 */
|
||||||
val weiboHotTopics: Map<String, List<String>> = emptyMap(),
|
val weiboHotTopics: Map<String, List<String>> = emptyMap(),
|
||||||
|
/** 知乎热榜采集卡片区间(榜单展示序,1 起;start≤end 由 normalized 归一)。 */
|
||||||
|
val zhihuCardRangeStart: Int = 1,
|
||||||
|
val zhihuCardRangeEnd: Int = 20,
|
||||||
|
/** 抖音热榜只采前 N 条(1 起)。 */
|
||||||
|
val douyinTopN: Int = 20,
|
||||||
|
/** 抖音标签过滤(热/新/挑战/辟谣;空=不过滤)。 */
|
||||||
|
val douyinLabelFilter: List<String> = emptyList(),
|
||||||
) {
|
) {
|
||||||
fun normalized(): CrossPlatformConfig {
|
fun normalized(): CrossPlatformConfig {
|
||||||
val maximumDuration = videoMaxSeconds.coerceIn(20, 4000)
|
val maximumDuration = videoMaxSeconds.coerceIn(20, 4000)
|
||||||
|
val cardStart = zhihuCardRangeStart.coerceIn(1, 50)
|
||||||
|
val cardEnd = zhihuCardRangeEnd.coerceIn(cardStart, 50)
|
||||||
return copy(
|
return copy(
|
||||||
mode = if (mode.trim().uppercase(Locale.ROOT) == MODE_AUTO) MODE_AUTO else MODE_DRY_RUN,
|
mode = if (mode.trim().uppercase(Locale.ROOT) == MODE_AUTO) MODE_AUTO else MODE_DRY_RUN,
|
||||||
scanIntervalMinutes = scanIntervalMinutes.coerceIn(5, 120),
|
scanIntervalMinutes = scanIntervalMinutes.coerceIn(5, 120),
|
||||||
@@ -56,6 +65,10 @@ data class CrossPlatformConfig(
|
|||||||
weiboHotTopics = weiboHotTopics.entries
|
weiboHotTopics = weiboHotTopics.entries
|
||||||
.filter { it.key.trim() in WEIBO_CATEGORY_IDS }
|
.filter { it.key.trim() in WEIBO_CATEGORY_IDS }
|
||||||
.associate { it.key.trim() to it.value.map { t -> t.trim() }.filter { t -> t.isNotEmpty() }.distinct() },
|
.associate { it.key.trim() to it.value.map { t -> t.trim() }.filter { t -> t.isNotEmpty() }.distinct() },
|
||||||
|
zhihuCardRangeStart = cardStart,
|
||||||
|
zhihuCardRangeEnd = cardEnd,
|
||||||
|
douyinTopN = douyinTopN.coerceIn(1, 50),
|
||||||
|
douyinLabelFilter = douyinLabelFilter.filter { it in DOUYIN_LABELS }.distinct(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +93,8 @@ data class CrossPlatformConfig(
|
|||||||
/** 微博热搜类目合法 id(见 WeiboHotCategories,2026-11-14 e2 实测清单)。 */
|
/** 微博热搜类目合法 id(见 WeiboHotCategories,2026-11-14 e2 实测清单)。 */
|
||||||
private val WEIBO_CATEGORY_IDS: Set<String> =
|
private val WEIBO_CATEGORY_IDS: Set<String> =
|
||||||
com.haorui.app.crossplatform.source.weibo.WeiboHotCategories.ALL.map { it.id }.toSet()
|
com.haorui.app.crossplatform.source.weibo.WeiboHotCategories.ALL.map { it.id }.toSet()
|
||||||
|
/** 抖音标签过滤合法词(见 DouyinHotListParser.LABELS,2026-11-16 e1 实测全集)。 */
|
||||||
|
val DOUYIN_LABELS = listOf("热", "新", "挑战", "辟谣")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +120,10 @@ object CrossPlatformConfigCodec {
|
|||||||
"categories" to c.categories.joinToString("|"),
|
"categories" to c.categories.joinToString("|"),
|
||||||
"weibo_hot_categories" to c.weiboHotCategories.joinToString("|"),
|
"weibo_hot_categories" to c.weiboHotCategories.joinToString("|"),
|
||||||
"weibo_hot_topics" to kotlinx.serialization.json.Json.encodeToString(c.weiboHotTopics),
|
"weibo_hot_topics" to kotlinx.serialization.json.Json.encodeToString(c.weiboHotTopics),
|
||||||
|
"zhihu_card_range_start" to c.zhihuCardRangeStart.toString(),
|
||||||
|
"zhihu_card_range_end" to c.zhihuCardRangeEnd.toString(),
|
||||||
|
"douyin_top_n" to c.douyinTopN.toString(),
|
||||||
|
"douyin_label_filter" to c.douyinLabelFilter.joinToString("|"),
|
||||||
).mapKeys { (key, _) -> PREFIX + key }
|
).mapKeys { (key, _) -> PREFIX + key }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +164,11 @@ object CrossPlatformConfigCodec {
|
|||||||
kotlinx.serialization.json.Json.decodeFromString<Map<String, List<String>>>(raw)
|
kotlinx.serialization.json.Json.decodeFromString<Map<String, List<String>>>(raw)
|
||||||
}.getOrDefault(d.weiboHotTopics)
|
}.getOrDefault(d.weiboHotTopics)
|
||||||
} ?: d.weiboHotTopics,
|
} ?: d.weiboHotTopics,
|
||||||
|
zhihuCardRangeStart = i("zhihu_card_range_start", d.zhihuCardRangeStart),
|
||||||
|
zhihuCardRangeEnd = i("zhihu_card_range_end", d.zhihuCardRangeEnd),
|
||||||
|
douyinTopN = i("douyin_top_n", d.douyinTopN),
|
||||||
|
douyinLabelFilter = value("douyin_label_filter")?.split('|')?.filter { it.isNotBlank() }
|
||||||
|
?: d.douyinLabelFilter,
|
||||||
).normalized()
|
).normalized()
|
||||||
return if (validEncoding) decoded else decoded.copy(enabled = false, mode = CrossPlatformConfig.MODE_DRY_RUN)
|
return if (validEncoding) decoded else decoded.copy(enabled = false, mode = CrossPlatformConfig.MODE_DRY_RUN)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,343 @@
|
|||||||
|
package com.haorui.app.crossplatform.source.douyin
|
||||||
|
|
||||||
|
import android.graphics.Bitmap
|
||||||
|
import android.os.SystemClock
|
||||||
|
import android.view.accessibility.AccessibilityNodeInfo
|
||||||
|
import com.haorui.app.automation.HaoRuiAccessibilityService
|
||||||
|
import com.haorui.app.automation.NodeLocator
|
||||||
|
import com.haorui.app.automation.RunLogger
|
||||||
|
import com.haorui.app.crossplatform.source.SourceBounds
|
||||||
|
import com.haorui.app.crossplatform.source.SourceNode
|
||||||
|
import com.haorui.app.crossplatform.source.SourceNodeAccessibility
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 抖音采集真机驱动([DouyinHotListCollector.Port] 实现,2026-11-16 e1 取证口径)。
|
||||||
|
*
|
||||||
|
* 入口链锚点(e1 dump 实证):
|
||||||
|
* - 首页右上「搜索」按钮:content-desc="搜索"、clickable、x>900、y<300;
|
||||||
|
* - 搜索页「抖音热榜」Tab:content-desc 以“抖音热榜”开头(选中态带“已选中”后缀),
|
||||||
|
* **页内切换不换 Activity**(e1 实证:focus 恒为 SearchResultActivity);
|
||||||
|
* - 热榜列表自绘渲染(XML 树无词条文本)→ OCR 行解析;
|
||||||
|
* - 词条点按按解析行 bounds 定位(e1 教训:屏上估算行位偏移一行,禁止盲估)。
|
||||||
|
*
|
||||||
|
* 详情页「投稿」「分享」按钮为外发动作红线,Port 不提供任何触发它们的方法。
|
||||||
|
*/
|
||||||
|
internal class DouyinDevicePort(
|
||||||
|
private val service: HaoRuiAccessibilityService,
|
||||||
|
) : DouyinHotListCollector.Port {
|
||||||
|
private companion object {
|
||||||
|
const val TAG = "Douyin-Port"
|
||||||
|
const val DOUYIN_PKG = "com.ss.android.ugc.aweme"
|
||||||
|
const val WAIT_STEP_MS = 400L
|
||||||
|
/** 榜单 Tab 行 y 区间(e1 实测 [299,1118][531,1190] 一带;键盘/弹层遮挡时此区间无匹配)。 */
|
||||||
|
const val TAB_Y_MIN = 900
|
||||||
|
const val TAB_Y_MAX = 1500
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── 基础工具(与知乎/微博 Port 同型) ─────────────────────
|
||||||
|
|
||||||
|
private fun log(message: String) = RunLogger.i(TAG, message)
|
||||||
|
|
||||||
|
private fun tree(): SourceNode? = service.root()?.let { SourceNodeAccessibility.from(it) }
|
||||||
|
|
||||||
|
private fun waitTree(timeoutMs: Long, until: (SourceNode) -> Boolean): Boolean {
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + timeoutMs
|
||||||
|
while (SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
val t = tree()
|
||||||
|
if (t != null && until(t)) return true
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 活树有界遍历找节点(供坐标点击;抖音热榜 Tab 为不可点击 ViewGroup,需按 bounds 手势点)。 */
|
||||||
|
private fun liveFind(
|
||||||
|
root: AccessibilityNodeInfo?,
|
||||||
|
budget: Int = 3_000,
|
||||||
|
predicate: (AccessibilityNodeInfo, android.graphics.Rect) -> Boolean,
|
||||||
|
): android.graphics.Rect? {
|
||||||
|
if (root == null) return null
|
||||||
|
var visited = 0
|
||||||
|
val rect = android.graphics.Rect()
|
||||||
|
fun walk(node: AccessibilityNodeInfo): android.graphics.Rect? {
|
||||||
|
if (visited++ > budget) return null
|
||||||
|
runCatching { node.getBoundsInScreen(rect) }
|
||||||
|
if (predicate(node, rect)) return android.graphics.Rect(rect)
|
||||||
|
for (i in 0 until node.childCount) {
|
||||||
|
val child = node.getChild(i) ?: continue
|
||||||
|
val found = try { walk(child) } finally { runCatching { child.recycle() } }
|
||||||
|
if (found != null) return found
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return walk(root)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单屏截屏+OCR 行文本(与微博 Port 的 ocrCurrentScreen 同型)。 */
|
||||||
|
private fun ocrCurrentScreen(): List<String> {
|
||||||
|
val bitmap: Bitmap = kotlinx.coroutines.runBlocking {
|
||||||
|
com.haorui.app.ocr.ScreenCapturer(service).capture()
|
||||||
|
} ?: return emptyList()
|
||||||
|
return try {
|
||||||
|
val blocks = kotlinx.coroutines.runBlocking { com.haorui.app.ocr.OcrProcessor.recognize(bitmap) }
|
||||||
|
blocks.flatMap { it.lines }.map { it.text.trim() }.filter { it.isNotEmpty() }
|
||||||
|
} finally {
|
||||||
|
bitmap.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** OCR 行轮询等待:until 命中即返回 true(有上限)。超时打印末轮采样辅助诊断。 */
|
||||||
|
private fun waitOcr(timeoutMs: Long, until: (List<String>) -> Boolean, tagForDebug: String = ""): Boolean {
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + timeoutMs
|
||||||
|
var lastLines: List<String> = emptyList()
|
||||||
|
while (SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
val lines = ocrCurrentScreen()
|
||||||
|
lastLines = lines
|
||||||
|
if (lines.isNotEmpty() && until(lines)) return true
|
||||||
|
Thread.sleep(1_000) // OCR 有成本,轮询间隔放宽
|
||||||
|
}
|
||||||
|
if (tagForDebug.isNotEmpty()) {
|
||||||
|
log("OCR 判据超时[$tagForDebug] 末轮 ${lastLines.size} 行采样: ${lastLines.take(8)}")
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/** OCR 定位含指定文本的行,返回该行 bounds(截屏坐标系);找不到返回 null。 */
|
||||||
|
private fun ocrFindLine(fragment: String): android.graphics.Rect? {
|
||||||
|
val bitmap: Bitmap = kotlinx.coroutines.runBlocking {
|
||||||
|
com.haorui.app.ocr.ScreenCapturer(service).capture()
|
||||||
|
} ?: return null
|
||||||
|
return try {
|
||||||
|
val blocks = kotlinx.coroutines.runBlocking { com.haorui.app.ocr.OcrProcessor.recognize(bitmap) }
|
||||||
|
blocks.asSequence()
|
||||||
|
.flatMap { it.lines.asSequence() }
|
||||||
|
.mapNotNull { line -> line.boundingBox?.let { rect -> line to rect } }
|
||||||
|
.firstOrNull { (line, _) -> line.text.replace(" ", "").contains(fragment) }
|
||||||
|
?.second
|
||||||
|
} finally {
|
||||||
|
bitmap.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Port 实现 ────────────────────────────────────────────
|
||||||
|
|
||||||
|
override fun ensureAppForeground(): Boolean {
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + 25_000
|
||||||
|
var backs = 0
|
||||||
|
var launches = 0
|
||||||
|
while (SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
// ⚠️ 包名判断兜底:抖音 Splash 常驻壳/沉浸视频页下 root().packageName 可能为 null
|
||||||
|
// (首跑实锤:launchApp 成功后 currentPackage() 仍判非抖音 → 死循环拉起)。
|
||||||
|
// 策略:只拉起一次,之后改用「树内有底栏 Tab」判定就绪——树读得到就是前台可操作。
|
||||||
|
val pkg = service.currentPackage()
|
||||||
|
if (pkg != DOUYIN_PKG) {
|
||||||
|
if (launches >= 1) {
|
||||||
|
// 已拉起过仍读不到包名:用树就绪判据直接验证(Splash 壳下的视频页是常态)
|
||||||
|
val readyByTree = tree()?.let { t ->
|
||||||
|
val flat = t.selfAndDescendants()
|
||||||
|
flat.any { n -> n.text == "首页" && (n.bounds?.top ?: 0) > 2_000 } &&
|
||||||
|
flat.any { n -> n.text == "我" && (n.bounds?.top ?: 0) > 2_000 }
|
||||||
|
} == true
|
||||||
|
if (readyByTree) {
|
||||||
|
log("包名不可读但树就绪(Splash 壳),按前台处理")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
launches++
|
||||||
|
service.launchApp(DOUYIN_PKG)
|
||||||
|
Thread.sleep(1_500)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val root = service.root()
|
||||||
|
if (root == null) {
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// 开屏广告/弹窗:只点「跳过」,不点广告本体(知乎同款口径)
|
||||||
|
val skip = NodeLocator.byTextContains(root, "跳过")
|
||||||
|
if (skip != null) {
|
||||||
|
runCatching { kotlinx.coroutines.runBlocking { service.gestures.tapNode(skip) } }
|
||||||
|
.onSuccess { log("开屏广告跳过") }
|
||||||
|
runCatching { skip.recycle() }
|
||||||
|
Thread.sleep(1_000)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// 就绪判据:底栏「首页」+「我」同在屏(y>2000,e1 实测底栏 y≈2175)
|
||||||
|
val ready = tree()?.let { t ->
|
||||||
|
val flat = t.selfAndDescendants()
|
||||||
|
flat.any { n -> n.text == "首页" && (n.bounds?.top ?: 0) > 2_000 } &&
|
||||||
|
flat.any { n -> n.text == "我" && (n.bounds?.top ?: 0) > 2_000 }
|
||||||
|
} == true
|
||||||
|
if (ready) return true
|
||||||
|
// 过渡态残留:有界 BACK 收拢
|
||||||
|
if (backs < 3) {
|
||||||
|
backs++
|
||||||
|
service.gestures.back()
|
||||||
|
log("残留页面收拢:第 $backs 次返回")
|
||||||
|
Thread.sleep(1_000)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
}
|
||||||
|
log("进入抖音前台失败")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openSearch(): Boolean {
|
||||||
|
// 右上「搜索」:desc="搜索"、clickable、x>900、y<300(e1 dump 实证 [924,108][1080,240])。
|
||||||
|
// 搜索钮本身在首页树可达(desc 形态);就绪判据走 OCR(搜索页内容树不可达,r4 实证)。
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + 15_000
|
||||||
|
var logged = false
|
||||||
|
while (SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
val root = service.root()
|
||||||
|
val rect = root?.let {
|
||||||
|
liveFind(it, budget = 2_000) { node, r ->
|
||||||
|
node.contentDescription?.toString() == "搜索" &&
|
||||||
|
node.isClickable && r.left > 900 && r.top < 300
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (rect != null) {
|
||||||
|
if (!logged) { log("定位到搜索钮 bounds=$rect"); logged = true }
|
||||||
|
val ok = kotlinx.coroutines.runBlocking {
|
||||||
|
service.gestures.tapAt(rect.centerX(), rect.centerY(), retry = false)
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
// 就绪判据走 OCR:搜索页特有锚点任一在屏。
|
||||||
|
// 容错口径:OCR 对「猜你想看/语音搜索」常出形近错字(r5 轮实测 8s 无命中),
|
||||||
|
// 用单字碎片「猜」「语音」「历史」宽松匹配 + 长超时兜底。
|
||||||
|
// ⚠️ 不能用树判——搜索页节点树对无障碍摘要化(r4/r5 实证);
|
||||||
|
// ⚠️ 也不能用 text=="搜索" 判——首页顶栏搜索钮本身就叫“搜索”。
|
||||||
|
val entered = waitOcr(12_000, until = { lines ->
|
||||||
|
lines.any { line ->
|
||||||
|
val clean = line.replace(" ", "")
|
||||||
|
clean.contains("猜") || clean.contains("语音") || clean.contains("历史")
|
||||||
|
}
|
||||||
|
}, tagForDebug = "search-page")
|
||||||
|
if (entered) return true
|
||||||
|
}
|
||||||
|
} else if (!logged) {
|
||||||
|
log("搜索钮未定位(树${if (root == null) "空" else "有"},抖音可能未落首页)")
|
||||||
|
}
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
}
|
||||||
|
log("搜索入口未打开")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openHotListTab(): Boolean {
|
||||||
|
// 「抖音热榜」Tab:树不可达(r4 实证),按 OCR 行 bounds 定位点击;
|
||||||
|
// 选中态判据 = 热榜列表行出现(「排名+标题+热度」形态,见 DouyinHotListParser)。
|
||||||
|
// ⚠️ 进入搜索页后输入法+「语音搜索」浮层会压住 Tab 行(r6 实锤:点不动),
|
||||||
|
// 先 BACK 收键盘再定位(BACK 在搜索页只收键盘不退出页面)。
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + 12_000
|
||||||
|
var dismissed = false
|
||||||
|
while (SystemClock.elapsedRealtime() < deadline) {
|
||||||
|
if (!dismissed) {
|
||||||
|
service.gestures.back()
|
||||||
|
Thread.sleep(800) // 键盘收起动画
|
||||||
|
dismissed = true
|
||||||
|
log("已收起键盘/浮层(BACK 一次)")
|
||||||
|
}
|
||||||
|
val tabRect = ocrFindLine("抖音热榜") ?: run {
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
if (tabRect != null) {
|
||||||
|
val ok = kotlinx.coroutines.runBlocking {
|
||||||
|
service.gestures.tapAt(tabRect.centerX(), tabRect.centerY(), retry = false)
|
||||||
|
}
|
||||||
|
if (ok) {
|
||||||
|
// 选中态判据走 OCR:热榜榜单行出现(≥3 条合格行 = 已切到热榜列表)
|
||||||
|
val selected = waitOcr(8_000, until = { lines ->
|
||||||
|
DouyinHotListParser.parse(lines).size >= 3
|
||||||
|
}, tagForDebug = "hot-tab-selected")
|
||||||
|
if (selected) return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Thread.sleep(WAIT_STEP_MS)
|
||||||
|
}
|
||||||
|
log("「抖音热榜」Tab 未切换成功")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun readHotListOcrLines(): List<String> {
|
||||||
|
// 榜单渲染稳定后单屏 OCR;滚动采集(多屏拼接)属采集机后续扩展,首版取当屏快照。
|
||||||
|
Thread.sleep(800) // 切 Tab 后渲染稳定
|
||||||
|
val lines = ocrCurrentScreen()
|
||||||
|
log("热榜 OCR ${lines.size} 行")
|
||||||
|
return lines
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun openEntry(index: Int): Boolean {
|
||||||
|
// 按解析序定位:重读当前屏 OCR 行 → 找到第 index 条合格行的**行 y 区间** → 按区间中线手势点击。
|
||||||
|
// 禁止屏上估算(e1 教训:估算偏移一行)——OCR 行块自带 bounds,按块定位。
|
||||||
|
val lines = ocrCurrentScreen()
|
||||||
|
val parsed = DouyinHotListParser.parse(lines)
|
||||||
|
val entry = parsed.getOrNull(index) ?: run {
|
||||||
|
log("重读后第 $index 条不存在(解析 ${parsed.size} 条)")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// 找该条目在 OCR 块中的行 bounds:按标题碎片匹配行块
|
||||||
|
val titleFragment = entry.title.take(8)
|
||||||
|
val bitmap: Bitmap? = kotlinx.coroutines.runBlocking {
|
||||||
|
com.haorui.app.ocr.ScreenCapturer(service).capture()
|
||||||
|
}
|
||||||
|
val target = bitmap?.let { bmp ->
|
||||||
|
try {
|
||||||
|
val blocks = kotlinx.coroutines.runBlocking { com.haorui.app.ocr.OcrProcessor.recognize(bmp) }
|
||||||
|
blocks.asSequence()
|
||||||
|
.flatMap { it.lines.asSequence() }
|
||||||
|
.mapNotNull { line -> line.boundingBox?.let { rect -> line to rect } }
|
||||||
|
.firstOrNull { (line, _) -> line.text.replace(" ", "").contains(titleFragment) }
|
||||||
|
?.second
|
||||||
|
} finally {
|
||||||
|
bmp.recycle()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target == null || target.width() <= 0) {
|
||||||
|
log("词条「${entry.title.take(12)}」OCR 行块定位失败")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
val ok = kotlinx.coroutines.runBlocking {
|
||||||
|
service.gestures.tapAt(target.centerX(), target.centerY(), retry = false)
|
||||||
|
}
|
||||||
|
if (!ok) return false
|
||||||
|
// 就绪判据走 OCR:热榜 TOP10 横条出现(详情页=搜索结果页顶部横条,e1 实证「热榜 TOP10 5630.1万人在看」)
|
||||||
|
val entered = waitOcr(8_000, until = { lines ->
|
||||||
|
lines.any { it.replace(" ", "").contains("热榜TOP") || it.contains("万人在看") }
|
||||||
|
}, tagForDebug = "entry-detail")
|
||||||
|
if (!entered) {
|
||||||
|
log("词条详情未打开(热榜 TOP 横条未出现)")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun readDetailOcrLines(): List<String> {
|
||||||
|
Thread.sleep(800) // 详情渲染稳定
|
||||||
|
return ocrCurrentScreen()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun readDetailTree(): SourceNode = tree() ?: SourceNode()
|
||||||
|
|
||||||
|
override fun backToHotList(): Boolean {
|
||||||
|
// 详情→热榜:一次 BACK(详情=搜索结果页内的词条视图)。
|
||||||
|
// 判据走 OCR:「抖音热榜」Tab 行回到屏上(树不可达,r4 实证)。
|
||||||
|
val deadline = SystemClock.elapsedRealtime() + 10_000
|
||||||
|
var backs = 0
|
||||||
|
while (SystemClock.elapsedRealtime() < deadline && backs < 4) {
|
||||||
|
if (service.currentPackage() != DOUYIN_PKG && service.currentPackage() != null) return false
|
||||||
|
val backOnList = runCatching { ocrFindLine("抖音热榜") }.getOrNull() != null
|
||||||
|
if (backOnList) return true
|
||||||
|
service.gestures.back()
|
||||||
|
backs++
|
||||||
|
Thread.sleep(1_000)
|
||||||
|
}
|
||||||
|
// 收尾不强求回热榜:BACK 兜底收拢弹层后让出前台(采集机 finally 口径)
|
||||||
|
runCatching { service.gestures.back() }
|
||||||
|
log("退出导航:BACK $backs 次后收尾")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -139,10 +139,10 @@ private fun HeroMetric(value: String, label: String) {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CrossSettingsEntries(onNavigate: (String) -> Unit) {
|
fun CrossSettingsEntries(onNavigate: (String) -> Unit) {
|
||||||
Section(title = "创作工作台", help = "来源与发布设置;热点选题已并入首页") {
|
// 来源 App 管理入口已并入首页「管理来源」;此处不再放任何链接。
|
||||||
SettingsLink("来源 App 管理", "安装版本与适配状态", { onNavigate(Routes.CROSS_SOURCES) })
|
Section(title = "通用配置", help = "自动化与采集设置的调整入口") {
|
||||||
SettingsLink("自动化设置", "作品形式、每日额度与草稿模式", { onNavigate(Routes.CROSS_AUTOMATION) })
|
SettingsLink("自动化设置", "作品形式、每日额度与草稿模式", { onNavigate(Routes.CROSS_AUTOMATION) })
|
||||||
SettingsLink("既有视频采集设置", "头条 / 百度配置、时段与每日重置", { onNavigate(Routes.COLLECT) })
|
SettingsLink("既有视频采集设置", "头条配置、时段与每日重置", { onNavigate(Routes.COLLECT) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,13 +194,13 @@ fun SourcesScreen(config: AppConfig, versions: Map<String, String?>, onConfigCha
|
|||||||
ScreenHeading("来源 App", "在本机管理来源选择,安装与适配状态分别显示")
|
ScreenHeading("来源 App", "在本机管理来源选择,安装与适配状态分别显示")
|
||||||
StatusBanner("来源均待真机适配。勾选仅保存使用偏好,不代表已接通。", StatusLevel.WARN)
|
StatusBanner("来源均待真机适配。勾选仅保存使用偏好,不代表已接通。", StatusLevel.WARN)
|
||||||
Section(title = "内容来源") {
|
Section(title = "内容来源") {
|
||||||
SourceRegistry.definitions.forEach { source ->
|
// 小红书已搁置(用户判定内容调性不适合头条),不提供启用项
|
||||||
|
SourceRegistry.definitions.filter { it.id != "xiaohongshu" }.forEach { source ->
|
||||||
val installed = versions[source.id]
|
val installed = versions[source.id]
|
||||||
val reason = SourceRegistry.executionStatus(source.id, installed, draft).reason
|
val reason = SourceRegistry.executionStatus(source.id, installed, draft).reason
|
||||||
ToggleRow(source.label, "${installed?.let { "已安装 $it" } ?: "未安装或版本不可读"} · ${if (source.verified) reason else "待真机适配"}", draft.sourceEnabled(source.id)) { checked ->
|
ToggleRow(source.label, "${installed?.let { "已安装 $it" } ?: "未安装或版本不可读"} · ${if (source.verified) reason else "待真机适配"}", draft.sourceEnabled(source.id)) { checked ->
|
||||||
draft = when (source.id) {
|
draft = when (source.id) {
|
||||||
"zhihu" -> draft.copy(zhihuEnabled = checked)
|
"zhihu" -> draft.copy(zhihuEnabled = checked)
|
||||||
"xiaohongshu" -> draft.copy(xiaohongshuEnabled = checked)
|
|
||||||
"weibo" -> draft.copy(weiboEnabled = checked)
|
"weibo" -> draft.copy(weiboEnabled = checked)
|
||||||
"douyin" -> draft.copy(douyinEnabled = checked)
|
"douyin" -> draft.copy(douyinEnabled = checked)
|
||||||
else -> draft
|
else -> draft
|
||||||
@@ -223,46 +223,6 @@ fun SourcesScreen(config: AppConfig, versions: Map<String, String?>, onConfigCha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalLayoutApi::class)
|
|
||||||
@Composable
|
|
||||||
fun TopicFilterSection(config: AppConfig, onConfigChange: (AppConfig) -> Unit) {
|
|
||||||
// 各数值字段以文本草稿编辑,失焦即按范围归一化写回配置(改即生效,无保存按钮)
|
|
||||||
var maxAge by rememberSaveable(config.crossPlatform.maxAgeHours) { mutableStateOf(config.crossPlatform.maxAgeHours.toString()) }
|
|
||||||
var likes by rememberSaveable(config.crossPlatform.likesMin) { mutableStateOf(config.crossPlatform.likesMin.toString()) }
|
|
||||||
var fans by rememberSaveable(config.crossPlatform.fansMax) { mutableStateOf(config.crossPlatform.fansMax.toString()) }
|
|
||||||
Section(title = "通用筛选", help = "所有来源共用的分类、时效与指标条件;修改立即生效") {
|
|
||||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
|
||||||
CrossPlatformConfig.CATEGORY_CATALOGUE.forEach { category ->
|
|
||||||
val selected = category in config.crossPlatform.categories
|
|
||||||
FilterChip(selected = selected, onClick = {
|
|
||||||
val next = if (selected) config.crossPlatform.categories - category else config.crossPlatform.categories + category
|
|
||||||
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(categories = next)))
|
|
||||||
}, label = { Text(category) })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FieldHelp("分类选择与图文 / 视频形式分开设置,素材许可、事实核验与账号条件仍需通过。")
|
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
|
||||||
OutlinedNumberField("时效不超过(小时)", maxAge, 1..72, { maxAge = it }) {
|
|
||||||
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(maxAgeHours = it)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ToggleRow("点赞数限制", "启用后,点赞数未知的候选不放行", config.crossPlatform.likesGateEnabled) {
|
|
||||||
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(likesGateEnabled = it)))
|
|
||||||
}
|
|
||||||
OutlinedNumberField("作品点赞至少", likes, 0..1_000_000_000, { likes = it }) {
|
|
||||||
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(likesMin = it)))
|
|
||||||
}
|
|
||||||
ToggleRow("作者粉丝数限制", "启用后,粉丝数未知的候选不放行", config.crossPlatform.fansGateEnabled) {
|
|
||||||
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(fansGateEnabled = it)))
|
|
||||||
}
|
|
||||||
OutlinedNumberField("作者粉丝不超过", fans, 0..1_000_000_000, { fans = it }) {
|
|
||||||
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(fansMax = it)))
|
|
||||||
}
|
|
||||||
Text("优选与去重按来源与指标口径比较热度;增长需要两次真实快照。同一事件在图文与视频之间共用去重记录。",
|
|
||||||
style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 带范围归一化的数字输入:编辑中文本自由变化,归一化成功后回写配置 */
|
/** 带范围归一化的数字输入:编辑中文本自由变化,归一化成功后回写配置 */
|
||||||
@Composable
|
@Composable
|
||||||
private fun OutlinedNumberField(label: String, value: String, range: IntRange, onText: (String) -> Unit, onCommit: (Int) -> Unit) {
|
private fun OutlinedNumberField(label: String, value: String, range: IntRange, onText: (String) -> Unit, onCommit: (Int) -> Unit) {
|
||||||
@@ -366,26 +326,26 @@ private val topicStates = setOf(CrossTaskState.DISCOVERED, CrossTaskState.FILTER
|
|||||||
@Composable
|
@Composable
|
||||||
fun TopicSourceSection(config: AppConfig, tasks: List<CrossPublishTask>, loaded: Boolean, loadError: String?,
|
fun TopicSourceSection(config: AppConfig, tasks: List<CrossPublishTask>, loaded: Boolean, loadError: String?,
|
||||||
onConfigChange: (AppConfig) -> Unit, onNavigate: (String) -> Unit) {
|
onConfigChange: (AppConfig) -> Unit, onNavigate: (String) -> Unit) {
|
||||||
var source by rememberSaveable { mutableStateOf("all") }
|
var source by rememberSaveable { mutableStateOf("weibo") }
|
||||||
var kind by rememberSaveable { mutableStateOf("all") }
|
var kind by rememberSaveable { mutableStateOf("all") }
|
||||||
var selected by remember { mutableStateOf<CrossPublishTask?>(null) }
|
var selected by remember { mutableStateOf<CrossPublishTask?>(null) }
|
||||||
val candidates = tasks.filter { it.state in topicStates && (source == "all" || it.sourcePlatform == source) && (kind == "all" || it.contentKind.name == kind) }
|
val candidates = tasks.filter { it.state in topicStates && it.sourcePlatform == source && (kind == "all" || it.contentKind.name == kind) }
|
||||||
Section(title = "热点选题", help = "选来源 → 配置该来源的选题条件 → 勾选词条采集;通用筛选对所有来源生效") {
|
Section(title = "热点选题", help = "选来源 → 配置该来源的选题条件 → 勾选词条采集") {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
TextButton({ onNavigate(Routes.CROSS_SOURCES) }) { Text("管理来源") }
|
TextButton({ onNavigate(Routes.CROSS_SOURCES) }) { Text("管理来源") }
|
||||||
}
|
}
|
||||||
// ── 来源切换:决定下方显示哪个来源的专属筛选 ────
|
// ── 来源切换:决定下方显示哪个来源的专属筛选(小红书已搁置,不提供) ────
|
||||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
FlowRow(horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
||||||
FilterChip(selected = source == "all", onClick = { source = "all" }, label = { Text("通用") })
|
listOf("zhihu", "weibo", "douyin").forEach { id ->
|
||||||
SourceRegistry.definitions.forEach { item -> FilterChip(selected = source == item.id, onClick = { source = item.id }, label = { Text(item.label) }) }
|
val def = SourceRegistry.find(id) ?: return@forEach
|
||||||
|
FilterChip(selected = source == id, onClick = { source = id }, label = { Text(def.label) })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ── 来源专属筛选:不同来源的选题维度不同 ────
|
// ── 来源专属筛选:不同来源的选题维度不同 ────
|
||||||
when (source) {
|
when (source) {
|
||||||
|
"zhihu" -> ZhihuSourceFilter(config, onConfigChange)
|
||||||
"weibo" -> WeiboSourceFilter(config, onConfigChange)
|
"weibo" -> WeiboSourceFilter(config, onConfigChange)
|
||||||
"zhihu" -> FieldHelp("知乎专属筛选待取证适配:暂按通用筛选执行(热榜词条 + 问题创建时间)。")
|
"douyin" -> DouyinSourceFilter(config, onConfigChange)
|
||||||
"douyin" -> FieldHelp("抖音专属筛选待取证适配:暂按通用筛选执行(热榜词条 + 相对时间折算)。")
|
|
||||||
"xiaohongshu" -> FieldHelp("小红书已搁置(内容调性判定不适合头条),专属筛选不再开发。")
|
|
||||||
else -> FieldHelp("「通用」为全部来源共用的筛选条件;切到具体来源可配置其专属维度(如微博热搜类目)。")
|
|
||||||
}
|
}
|
||||||
// ── 作品形式过滤 + 候选列表 ────
|
// ── 作品形式过滤 + 候选列表 ────
|
||||||
FlowRow(horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
FlowRow(horizontalArrangement = Arrangement.spacedBy(7.dp)) {
|
||||||
@@ -393,18 +353,57 @@ fun TopicSourceSection(config: AppConfig, tasks: List<CrossPublishTask>, loaded:
|
|||||||
FilterChip(selected = kind == id, onClick = { kind = id }, label = { Text(label) })
|
FilterChip(selected = kind == id, onClick = { kind = id }, label = { Text(label) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text("通用筛选:${config.crossPlatform.categories.joinToString("、").ifBlank { "未选择分类" }} · ${config.crossPlatform.maxAgeHours} 小时内", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant)
|
|
||||||
when {
|
when {
|
||||||
loadError != null -> StatusBanner("本地任务读取失败:$loadError", StatusLevel.BAD)
|
loadError != null -> StatusBanner("本地任务读取失败:$loadError", StatusLevel.BAD)
|
||||||
!loaded -> EmptyPanel("正在读取本地候选", "请稍候")
|
!loaded -> EmptyPanel("正在读取本地候选", "请稍候")
|
||||||
candidates.isEmpty() -> EmptyPanel("暂时没有热点候选", "来源适配通过后,这里将显示真实采集结果。可以先保存分类、作品形式和指标条件。")
|
candidates.isEmpty() -> EmptyPanel("此来源暂无热点候选", "采集落库后,这里将显示真实候选记录。")
|
||||||
else -> candidates.forEach { TaskCard(it, { selected = it }) }
|
else -> candidates.forEach { TaskCard(it, { selected = it }) }
|
||||||
}
|
}
|
||||||
FieldHelp("本页读取真实本地记录,不填充演示热榜或虚构热度。当前来源均待真机适配。")
|
|
||||||
}
|
}
|
||||||
selected?.let { prior -> TaskPreview(tasks.firstOrNull { it.id == prior.id } ?: prior) { selected = null } }
|
selected?.let { prior -> TaskPreview(tasks.firstOrNull { it.id == prior.id } ?: prior) { selected = null } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 知乎来源专属筛选:热榜卡片范围(按榜单序号区间采集)。 */
|
||||||
|
@Composable
|
||||||
|
private fun ZhihuSourceFilter(config: AppConfig, onConfigChange: (AppConfig) -> Unit) {
|
||||||
|
var rangeStart by rememberSaveable(config.crossPlatform.zhihuCardRangeStart) { mutableStateOf(config.crossPlatform.zhihuCardRangeStart.toString()) }
|
||||||
|
var rangeEnd by rememberSaveable(config.crossPlatform.zhihuCardRangeEnd) { mutableStateOf(config.crossPlatform.zhihuCardRangeEnd.toString()) }
|
||||||
|
Section(title = "知乎热榜范围", help = "采集热榜第 N~M 条卡片;卡片序号按榜单展示序(1 起)") {
|
||||||
|
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
|
OutlinedNumberField("起始条(1~50)", rangeStart, 1..50, { rangeStart = it }) {
|
||||||
|
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(zhihuCardRangeStart = it)))
|
||||||
|
}
|
||||||
|
OutlinedNumberField("结束条(起始~50)", rangeEnd, 1..50, { rangeEnd = it }) {
|
||||||
|
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(zhihuCardRangeEnd = it)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 抖音来源专属筛选:榜单前 N 条 + 标签过滤(OCR 可读标签:热/新/挑战/辟谣)。 */
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
|
@Composable
|
||||||
|
private fun DouyinSourceFilter(config: AppConfig, onConfigChange: (AppConfig) -> Unit) {
|
||||||
|
var topN by rememberSaveable(config.crossPlatform.douyinTopN) { mutableStateOf(config.crossPlatform.douyinTopN.toString()) }
|
||||||
|
val selectedLabels = config.crossPlatform.douyinLabelFilter.toSet()
|
||||||
|
Section(title = "抖音热榜范围", help = "采集榜单前 N 条;标签过滤为空表示不过滤(全部标签都采)") {
|
||||||
|
OutlinedNumberField("只采前(1~50)条", topN, 1..50, { topN = it }) {
|
||||||
|
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(douyinTopN = it)))
|
||||||
|
}
|
||||||
|
FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
|
listOf("热", "新", "挑战", "辟谣").forEach { label ->
|
||||||
|
FilterChip(selected = label in selectedLabels, onClick = {
|
||||||
|
val next = if (label in selectedLabels) selectedLabels - label else selectedLabels + label
|
||||||
|
// 保持稳定顺序(热/新/挑战/辟谣)
|
||||||
|
onConfigChange(config.copy(crossPlatform = config.crossPlatform.copy(
|
||||||
|
douyinLabelFilter = listOf("热", "新", "挑战", "辟谣").filter { it in next },
|
||||||
|
)))
|
||||||
|
}, label = { Text(label) })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 微博来源专属筛选:热搜类目多选 + 词条勾选器(选什么采什么)。 */
|
/** 微博来源专属筛选:热搜类目多选 + 词条勾选器(选什么采什么)。 */
|
||||||
@Composable
|
@Composable
|
||||||
private fun WeiboSourceFilter(config: AppConfig, onConfigChange: (AppConfig) -> Unit) {
|
private fun WeiboSourceFilter(config: AppConfig, onConfigChange: (AppConfig) -> Unit) {
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import androidx.compose.ui.unit.dp
|
|||||||
import com.haorui.app.data.model.AppConfig
|
import com.haorui.app.data.model.AppConfig
|
||||||
import com.haorui.app.crossplatform.model.CrossPublishTask
|
import com.haorui.app.crossplatform.model.CrossPublishTask
|
||||||
import com.haorui.app.crossplatform.ui.CrossWorkspaceOverview
|
import com.haorui.app.crossplatform.ui.CrossWorkspaceOverview
|
||||||
import com.haorui.app.crossplatform.ui.TopicFilterSection
|
|
||||||
import com.haorui.app.crossplatform.ui.TopicSourceSection
|
import com.haorui.app.crossplatform.ui.TopicSourceSection
|
||||||
import com.haorui.app.ui.components.CheckRow
|
import com.haorui.app.ui.components.CheckRow
|
||||||
import com.haorui.app.ui.components.NumberField
|
import com.haorui.app.ui.components.NumberField
|
||||||
@@ -85,10 +84,8 @@ fun HomeScreen(
|
|||||||
onConfigChange = onConfigChange,
|
onConfigChange = onConfigChange,
|
||||||
)
|
)
|
||||||
|
|
||||||
// ── ③ 热点选题(来源切换:不同来源的专属筛选不同,微博=类目+词条勾选) ────
|
// ── ③ 热点选题(来源切换:知乎/微博/抖音各自专属筛选;小红书已搁置不提供) ────
|
||||||
TopicSourceSection(config, crossTasks, crossTasksLoaded, crossTasksError, onConfigChange, onNavigate)
|
TopicSourceSection(config, crossTasks, crossTasksLoaded, crossTasksError, onConfigChange, onNavigate)
|
||||||
// ── ④ 通用筛选(全来源共用,改即生效) ────
|
|
||||||
TopicFilterSection(config, onConfigChange)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ fun MineScreen(
|
|||||||
) {
|
) {
|
||||||
CrossSettingsEntries(onNavigate)
|
CrossSettingsEntries(onNavigate)
|
||||||
|
|
||||||
// ── 互动设置(原「互动」tab 全部内容,2026-11-16 并入本页) ────
|
// ── 互动设置(原「互动」tab 内容,并入本页通用配置) ────
|
||||||
InteractSettingsSections(config, onConfigChange, onToast)
|
InteractSettingsSections(config, onConfigChange, onToast)
|
||||||
|
|
||||||
Section(
|
Section(
|
||||||
title = "系统设置",
|
title = "通用配置 · 系统开关",
|
||||||
help = "影响任务能否正常运行的关键配置",
|
help = "影响任务能否正常运行的关键配置",
|
||||||
) {
|
) {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
@@ -111,7 +111,7 @@ fun MineScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Section(
|
Section(
|
||||||
title = "本机数据",
|
title = "通用配置 · 本机数据",
|
||||||
help = "清理本地缓存与去重记录",
|
help = "清理本地缓存与去重记录",
|
||||||
) {
|
) {
|
||||||
StatusBanner("已发布去重索引:$dedupCount 条", StatusLevel.NEUTRAL)
|
StatusBanner("已发布去重索引:$dedupCount 条", StatusLevel.NEUTRAL)
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ gradle --offline :app:testDebugUnitTest :app:assembleDebug :app:assembleDebugAnd
|
|||||||
|
|
||||||
| 日期 | 事项 | 验证范围 |
|
| 日期 | 事项 | 验证范围 |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-11-16 | **筛选重构(全来源专属化)+ 抖音 Port 真机接线(6 轮迭代)**:①热点选题区来源 chips 精简为知乎/微博/抖音(通用 chip 删、小红书从来源管理与选题区全部移除),知乎专属筛选落地(热榜卡片区间 start/end,normalized 保证 start≤end)、抖音专属筛选落地(前 N 条 + 标签过滤 热/新/挑战/辟谣),全部"待适配/搁置"提示文字与首页通用筛选区块(分类/时效/点赞/粉丝)删除——通用筛选字段 UI 下线但配置保留(执行链未消费已验证);②我的页:来源 App 管理入口删除(并入首页),自动化设置/既有视频采集/互动三区块/本机数据统一"通用配置"命名;③抖音 Port 真机实现 `DouyinDevicePort`+服务沙盒 `ACTION_TEST_DOUYIN`(listOnly/entryIndex 双模式);6 轮真机迭代修掉 5 个真机缺陷:①Splash 常驻壳包名不可读死循环拉起(改树就绪判据)②openSearch 就绪判据误命中首页顶栏搜索钮(改搜索页特有锚点)③**搜索页节点树对无障碍摘要化**(Tab 行/历史区不可达,r4/r5 截屏实锤——全锚点改 OCR 路线)④OCR 形近错字致判据不命中(单字碎片宽松匹配)⑤**「语音搜索」浮层压住热榜 Tab 致点击无效**(进 Tab 前先 BACK 收键盘,待复验) | 303 项 JVM 全过;真机六轮日志 `.tmp/douyin-evidence/`+服务日志;UI 验收:chips 三来源 ✓、知乎/抖音专属筛选 ✓、我的页通用配置 ✓;沙盒进展:OPEN_APP✓→OPEN_SEARCH✓→OPEN_HOT_TAB 卡浮层遮挡(修复待复验,手机被企业微信占用中断);配置新字段 zhihuCardRangeStart/End、douyinTopN、douyinLabelFilter 双通道 codec |
|
||||||
| 2026-11-16 | **UI 二轮整合 + 抖音解析器/状态机落地**:①热点选题区按来源切换——来源 chips(通用/知乎/小红书/微博/抖音)决定显示哪个来源的专属筛选(微博=热搜类目多选+词条勾选器;知乎/抖音=待取证适配提示;小红书=搁置说明),通用筛选(分类/时效/点赞/粉丝)独立区块对全来源生效,候选列表按来源+形式过滤;②首页视觉重做——品牌紫 Hero 卡(工作台指标白字反白)替代旧工作台卡,删三步引导;③互动 tab 并入「我的」——底部三 tab(首页/任务/我的),互动三区块(新粉互动/信用分门控/评论辅助)改为 `InteractSettingsSections` 嵌入我的页;④抖音解析器+状态机:`douyin/` 包四件(DouyinModels/DouyinHotListParser/DouyinDetailParser/DouyinHotListCollector),热榜解析按 e1 取证 OCR 行口径(行首 1~2 位排名+标题+独立标签词 热/新/挑战/辟谣+行尾数值万热度),**正常榜单行必有排名:无排名行一律拒绝**(置顶/官宣/搜索历史/OCR 混入非榜单内容),标签粘连不剥离留 null;详情相对时间白名单(分钟/小时/天前)折算,作者/正文未核验留 null;SourceRegistry 门控未放行 | **303 项 JVM 全过**(284+19 抖音新:解析器 9/采集机 7/详情 3,0 失败,`.tmp/round2-build4.log`);真机验收通过:三 tab ✓、Hero 卡 ✓、热点选题来源切换(微博专属筛选出现/抖音待适配提示)✓、我的页互动三区块 ✓;无障碍绑定装机后完好;迭代修 2 真缺陷(heatValue 恒 null 忘调 parseHeat;READ_DETAIL 相位读取顺序)+2 口径收敛(无排名行拒绝;SAVE_OBSERVATION 非 Port 调用不记 calls) |
|
| 2026-11-16 | **UI 二轮整合 + 抖音解析器/状态机落地**:①热点选题区按来源切换——来源 chips(通用/知乎/小红书/微博/抖音)决定显示哪个来源的专属筛选(微博=热搜类目多选+词条勾选器;知乎/抖音=待取证适配提示;小红书=搁置说明),通用筛选(分类/时效/点赞/粉丝)独立区块对全来源生效,候选列表按来源+形式过滤;②首页视觉重做——品牌紫 Hero 卡(工作台指标白字反白)替代旧工作台卡,删三步引导;③互动 tab 并入「我的」——底部三 tab(首页/任务/我的),互动三区块(新粉互动/信用分门控/评论辅助)改为 `InteractSettingsSections` 嵌入我的页;④抖音解析器+状态机:`douyin/` 包四件(DouyinModels/DouyinHotListParser/DouyinDetailParser/DouyinHotListCollector),热榜解析按 e1 取证 OCR 行口径(行首 1~2 位排名+标题+独立标签词 热/新/挑战/辟谣+行尾数值万热度),**正常榜单行必有排名:无排名行一律拒绝**(置顶/官宣/搜索历史/OCR 混入非榜单内容),标签粘连不剥离留 null;详情相对时间白名单(分钟/小时/天前)折算,作者/正文未核验留 null;SourceRegistry 门控未放行 | **303 项 JVM 全过**(284+19 抖音新:解析器 9/采集机 7/详情 3,0 失败,`.tmp/round2-build4.log`);真机验收通过:三 tab ✓、Hero 卡 ✓、热点选题来源切换(微博专属筛选出现/抖音待适配提示)✓、我的页互动三区块 ✓;无障碍绑定装机后完好;迭代修 2 真缺陷(heatValue 恒 null 忘调 parseHeat;READ_DETAIL 相位读取顺序)+2 口径收敛(无排名行拒绝;SAVE_OBSERVATION 非 Port 调用不记 calls) |
|
||||||
| 2026-11-16 | **抖音 e1 取证完成(M2 启动)**:入口链实测——首页右上搜索按钮(content-desc="搜索",[924,108][1080,240])→搜索页(SearchResultActivity,历史/猜你想看/榜单 Tab 行)→「抖音热榜」Tab(ViewGroup content-desc,**页内切换不换 Activity**,"已选中"状态可读)→热榜列表(**自绘渲染 XML 树无词条文本,OCR 主路线**,与微博同款)→词条详情(搜索结果页:热榜 TOP10 横条+综合/视频/图文/用户/直播/商品 Tab+图文/视频卡+作者相对时间+分享 ↗ 按钮)。榜单条目形态:排名徽章+标题+热/新/挑战/辟谣彩色标签+热度值(X万),滚动流畅 Tab 吸顶。样本 7 组落盘 `.tmp/douyin-evidence/`(dy-01~07)。全程只读:未点赞/关注/发布/投稿;BACK+HOME 干净退出 | dump+截图取证;详情页点按偏移一行(点到第 10 条)已记录——后续 Port 实现须按解析结果定位而非屏上估算行位 |
|
| 2026-11-16 | **抖音 e1 取证完成(M2 启动)**:入口链实测——首页右上搜索按钮(content-desc="搜索",[924,108][1080,240])→搜索页(SearchResultActivity,历史/猜你想看/榜单 Tab 行)→「抖音热榜」Tab(ViewGroup content-desc,**页内切换不换 Activity**,"已选中"状态可读)→热榜列表(**自绘渲染 XML 树无词条文本,OCR 主路线**,与微博同款)→词条详情(搜索结果页:热榜 TOP10 横条+综合/视频/图文/用户/直播/商品 Tab+图文/视频卡+作者相对时间+分享 ↗ 按钮)。榜单条目形态:排名徽章+标题+热/新/挑战/辟谣彩色标签+热度值(X万),滚动流畅 Tab 吸顶。样本 7 组落盘 `.tmp/douyin-evidence/`(dy-01~07)。全程只读:未点赞/关注/发布/投稿;BACK+HOME 干净退出 | dump+截图取证;详情页点按偏移一行(点到第 10 条)已记录——后续 Port 实现须按解析结果定位而非屏上估算行位 |
|
||||||
| 2026-11-16 | **UI 整合轮:热点 tab 下线并入首页 + 任务删除 + LazyColumn + 百度空壳下线**:①底部五 tab→四 tab(首页/任务/互动/我的),热点 tab 全部功能并入首页——`TopicSourceSection`(管理来源/来源形式筛选/微博热搜类目/词条勾选器/候选列表)+`TopicFilterSection`(18 分类/时效/点赞/粉丝门槛,改即生效无保存按钮);②`CrossPublishTaskStore.deleteTask(id)` 事务删除(quota_ledger→attempts→assets→tasks 按 FK 依赖顺序),UI 二次确认(UNKNOWN/待核对高危文案明示"放弃核对保护+额度释放"),素材文件删除前核对两份保护清单;③任务页全量组合改 LazyColumn(修数据量大卡顿)+每卡删除按钮;④百度采集确认空壳(BAIDU_FEED 零引用无解析器/Port)下线:采集模式下拉/采集页入口/BaiduConfigScreen/BAIDU 路由全删,AppConfig.baidu 数据字段保留不迁移;⑤任务页"发布设置"入口删除、我的页选题筛选入口删除、自动化设置页死链接删除 | **284 项 JVM 全量重跑全过**(0 失败,`.tmp/ui-consolidate-test.log`);assembleDebug+assembleDebugAndroidTest 通过(`.tmp/ui-consolidate-build.log`);真机验收通过:四 tab 布局 ✓、首页无百度下拉 ✓、任务页 LazyColumn+删除按钮 ✓、删除全链实测(待处理 1057→1056,二次确认弹窗文案正确,vivo「继续安装」弹窗按记忆处置);无障碍绑定装机后完好;仪器测试(deleteTask 2 用例)待下轮随批执行 |
|
| 2026-11-16 | **UI 整合轮:热点 tab 下线并入首页 + 任务删除 + LazyColumn + 百度空壳下线**:①底部五 tab→四 tab(首页/任务/互动/我的),热点 tab 全部功能并入首页——`TopicSourceSection`(管理来源/来源形式筛选/微博热搜类目/词条勾选器/候选列表)+`TopicFilterSection`(18 分类/时效/点赞/粉丝门槛,改即生效无保存按钮);②`CrossPublishTaskStore.deleteTask(id)` 事务删除(quota_ledger→attempts→assets→tasks 按 FK 依赖顺序),UI 二次确认(UNKNOWN/待核对高危文案明示"放弃核对保护+额度释放"),素材文件删除前核对两份保护清单;③任务页全量组合改 LazyColumn(修数据量大卡顿)+每卡删除按钮;④百度采集确认空壳(BAIDU_FEED 零引用无解析器/Port)下线:采集模式下拉/采集页入口/BaiduConfigScreen/BAIDU 路由全删,AppConfig.baidu 数据字段保留不迁移;⑤任务页"发布设置"入口删除、我的页选题筛选入口删除、自动化设置页死链接删除 | **284 项 JVM 全量重跑全过**(0 失败,`.tmp/ui-consolidate-test.log`);assembleDebug+assembleDebugAndroidTest 通过(`.tmp/ui-consolidate-build.log`);真机验收通过:四 tab 布局 ✓、首页无百度下拉 ✓、任务页 LazyColumn+删除按钮 ✓、删除全链实测(待处理 1057→1056,二次确认弹窗文案正确,vivo「继续安装」弹窗按记忆处置);无障碍绑定装机后完好;仪器测试(deleteTask 2 用例)待下轮随批执行 |
|
||||||
|
|||||||
Reference in New Issue
Block a user