import { contentPath } from '../routing'; import type { Chapter, Config, DramaDetail } from "../api/types"; import { formatCount, recordList, safeUrl } from "../api/protocol"; import { escape, imageAttributes, title } from "./render"; // Original HTML action icons, kept as SVG paths so active colors follow the stylesheet. const actionPaths = { "save": "M857.6 327.68l-104.494545-34.210909a178.036364 178.036364 0 0 1-90.763637-66.56l-64-89.367273a104.96 104.96 0 0 0-23.272727-23.272727 106.123636 106.123636 0 0 0-148.48 23.272727l-64.930909 89.367273a179.665455 179.665455 0 0 1-90.763637 66.792727l-104.494545 33.978182a106.821818 106.821818 0 0 0-53.061818 162.909091l93.090909 128.930909a35.84 35.84 0 0 1 6.981818 21.643636v158.952728a109.381818 109.381818 0 0 0 5.12 33.512727 105.658182 105.658182 0 0 0 133.818182 67.956364l128-39.33091a107.985455 107.985455 0 0 1 64.232727 0l127.534546 39.33091a106.123636 106.123636 0 0 0 139.636363-101.469091v-158.254546a35.84 35.84 0 0 1 6.981818-21.643636l93.09091-128.930909a104.494545 104.494545 0 0 0 15.127272-29.556364 106.821818 106.821818 0 0 0-69.352727-134.050909z m-192 83.549091a34.909091 34.909091 0 0 1-48.174545 10.938182l-46.545455-29.090909a34.909091 34.909091 0 0 1 37.003636-59.112728l46.545455 29.090909a34.909091 34.909091 0 0 1 11.170909 48.174546z", "like": "M855.738182 198.283636A252.043636 252.043636 0 0 0 670.254545 116.363636a225.28 225.28 0 0 0-160.814545 63.069091 248.32 248.32 0 0 0-152.901818-53.294545A251.578182 251.578182 0 0 0 171.287273 209.454545 287.883636 287.883636 0 0 0 162.909091 588.567273l256 275.083636a122.181818 122.181818 0 0 0 90.065454 39.563636 121.716364 121.716364 0 0 0 89.832728-39.563636l256-272.989091 2.792727-3.723636a290.443636 290.443636 0 0 0-1.861818-388.654546z", "share": "M910.661818 117.992727a114.734545 114.734545 0 0 0-113.803636-16.756363L134.050909 363.752727a138.472727 138.472727 0 0 0-15.592727 250.181818l97.978182 54.225455 1.861818 162.909091a87.272727 87.272727 0 0 0 137.309091 69.818182L482.210909 814.545455l180.363636 99.374545a138.472727 138.472727 0 0 0 203.869091-101.236364L954.181818 224.814545a113.803636 113.803636 0 0 0-43.52-106.821818z", "feedback": "M505.949091 38.4a465.454545 465.454545 0 1 0 465.454545 465.454545 465.454545 465.454545 0 0 0-465.454545-465.454545z m0 721.454545a46.545455 46.545455 0 1 1 46.545454-46.545454 46.545455 46.545455 0 0 1-46.545454 46.545454z m43.287273-188.276363a11.636364 11.636364 0 0 0-8.378182 11.170909v25.832727a34.909091 34.909091 0 0 1-69.818182 0V581.818182a81.454545 81.454545 0 0 1 58.88-78.196364 87.04 87.04 0 0 0 60.741818-102.865454A86.807273 86.807273 0 0 0 433.803636 372.363636a90.298182 90.298182 0 0 0-11.403636 24.436364 34.909091 34.909091 0 0 1-67.025455-19.549091 162.909091 162.909091 0 0 1 20.712728-43.985454 156.625455 156.625455 0 1 1 173.149091 238.312727z", "phone": "M756.363636 69.818182h-488.727272A128.232727 128.232727 0 0 0 139.636364 197.818182v628.363636a128.232727 128.232727 0 0 0 128 128h488.727272a128 128 0 0 0 128-128v-628.363636A128 128 0 0 0 756.363636 69.818182z m-139.636363 698.181818h-209.454546a34.909091 34.909091 0 0 1 0-69.818182h209.454546a34.909091 34.909091 0 0 1 0 69.818182z" } as const; export function detailActionIcon(kind: keyof typeof actionPaths): string { return ``; } export function overviewMarkup(drama: DramaDetail, first: Chapter | undefined, actions: string): string { const genres = (Array.isArray(drama.tagNames) ? drama.tagNames : Array.isArray(drama.themeNames) ? drama.themeNames : []).filter(tag => typeof tag === 'string'); const badge = drama.isFeatured ? '爆剧' : drama.isNew ? '新剧' : ''; return `
${escape(title(drama))}封面

${escape(title(drama))}

${formatCount(drama.heatValue)}热度
${badge}${formatCount(drama.countCollect)}收藏${formatCount(drama.countLike)}点赞
${genres.length ? `

${escape(genres.join(' · '))}

` : ''}

${escape(drama.desc || drama.description)}

${first ? `立即播放` : '暂无可用剧集'}
${actions}
`; } export function officialLinks(config: Config): string { const settings = {...config.newAddressInfo,...config.config}; const primary = safeUrl(settings.newUrlAddr) || recordList<{url?:unknown}>(config.navPageList).map(item => safeUrl(item.url)).find(Boolean) || ''; const permanent = safeUrl(settings.foreverUrlAddr); const group = safeUrl(settings.tgGroup); const contact = safeUrl(settings.telegram); const external = (url: string, label = url) => `${escape(label)}`; return `
${primary ? `
官方入口:${external(primary)}
` : ''} ${permanent ? `
永久地址:${external(permanent)}
` : ''} ${group ? `
${external(group,'点击加入91短剧官方 Telegram 群')}
` : ''}
官方客服:${contact ? external(contact,'立即联系') : '立即联系'}
`; } export function bindSeriesDescription(root: HTMLElement, signal: AbortSignal): () => void { const text = root.querySelector('#series-description-text'); const toggle = root.querySelector('.series-description-toggle'); if (!text || !toggle) return () => {}; const update = () => { if (signal.aborted || !text.clientWidth) return; const lineHeight = Number.parseFloat(getComputedStyle(text).lineHeight) || 26.6; const overflow = text.scrollHeight > lineHeight*3 + 1; toggle.hidden = !overflow; if (!overflow) { text.classList.remove('is-expanded'); toggle.setAttribute('aria-expanded','false');toggle.textContent = '展开'; } }; toggle.addEventListener('click',() => { const expanded = toggle.getAttribute('aria-expanded') !== 'true'; text.classList.toggle('is-expanded',expanded); toggle.setAttribute('aria-expanded',String(expanded));toggle.textContent = expanded ? '收起' : '展开'; },{signal}); const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(update); observer?.observe(text); if (!observer) window.addEventListener('resize',update,{signal}); const dispose = () => observer?.disconnect(); signal.addEventListener('abort',dispose,{once:true}); update(); return dispose; }