feat(monitor): 粘贴视频链接换出博主主页
运营手上常常只有一条作品的分享链接,可监控任务认的是主页里的 sec_uid。 - 从整段分享文案里抠链接(链接前后都是字,按行切切不开),短链先展开, 再从中取作品 id,最后用详情接口换 author.sec_uid - 一次最多 20 条,串行 + 0.4 秒间隔;单条失败只在那一条上报错,不连累整批 - normalize_aweme 补上 creator_id:哈希拼不出主页地址,顺带让以后入库的 抖音作品也带主页链接 - 监控页左上角「视频转主页」,支持逐条复制和一键复制全部(http 下没有 navigator.clipboard,走 execCommand 兜底)
This commit is contained in:
@@ -20,6 +20,7 @@ import type {
|
||||
SettingsResponse,
|
||||
TaskCreatePayload,
|
||||
UpstreamStatus,
|
||||
VideoLinkResolveResponse,
|
||||
WebhookStatus,
|
||||
} from '@/types/monitor'
|
||||
import type {
|
||||
@@ -308,6 +309,14 @@ export const monitorApi = {
|
||||
api.get<LoginState>('/monitor/login/state', { params: { force } }),
|
||||
|
||||
getWebhook: () => api.get<WebhookStatus>('/monitor/webhook'),
|
||||
/**
|
||||
* 视频链接/分享文案 → 博主主页。
|
||||
*
|
||||
* 后端逐条串行请求详情接口(一次最多 20 条),所以超时给得比默认的 30 秒宽 ——
|
||||
* 按 30 秒算会把一批本来能解析完的链接误报成失败。
|
||||
*/
|
||||
resolveVideoLinks: (text: string) =>
|
||||
api.post<VideoLinkResolveResponse>('/monitor/video-links', { text }, { timeout: 90_000 }),
|
||||
/** 昨天视频情况图:手动发一次(每天早上那条由后端按设置触发)。 */
|
||||
sendDailyDigest: (platform?: string) =>
|
||||
api.post<{ ok: boolean; rows: number; detail: string }>('/monitor/digest/send', null, {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 复制文本。
|
||||
*
|
||||
* **必须留兜底**:这个站点是走 http://192.168.x.x:18051 访问的,不是安全上下文,
|
||||
* 浏览器在这种情况下根本不提供 `navigator.clipboard`(不是拒绝,是 undefined)。
|
||||
* 只写新 API 的话,局域网里点「复制」永远没反应。
|
||||
*/
|
||||
export async function copyText(value: string): Promise<boolean> {
|
||||
if (!value) return false
|
||||
|
||||
if (window.isSecureContext && navigator.clipboard) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value)
|
||||
return true
|
||||
} catch {
|
||||
// 落到下面的兜底
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const area = document.createElement('textarea')
|
||||
area.value = value
|
||||
// 定位到视口外而不是 display:none —— 隐藏元素选不中,复制会失败。
|
||||
area.style.position = 'fixed'
|
||||
area.style.top = '-1000px'
|
||||
area.style.opacity = '0'
|
||||
document.body.appendChild(area)
|
||||
area.select()
|
||||
const ok = document.execCommand('copy')
|
||||
document.body.removeChild(area)
|
||||
return ok
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user