|
|
| 第174行: |
第174行: |
| }) | | }) |
| } | | } |
| const encodedUrl = `https://rizwiki.cn/api.php?action=query%26titles=${encodeURIComponent(song.title)}%26prop=revisions%7Cpageimages%26rvprop=content%26pithumbsize=300%26format=json`
| |
| const decodedUrl = decodeURIComponent(encodedUrl)
| |
|
| |
| fetch(decodedUrl)
| |
| .then(r => r.json())
| |
| .then(data => {
| |
| try {
| |
| const pages = data.query.pages
| |
| const pageId = Object.keys(pages)[0]
| |
| const pageData = pages[pageId]
| |
|
| |
| if (!pageData.revisions) {
| |
| throw new Error('页面不存在')
| |
| }
| |
|
| |
| const wikitext = pageData.revisions[0]['*']
| |
| const styles = parseStylesFromWikitext(wikitext)
| |
|
| |
| let imageUrl = null
| |
| if (pageData.thumbnail) {
| |
| if (pageData.thumbnail.source) {
| |
| imageUrl = pageData.thumbnail.source;
| |
| console.log('获取到的缩略图URL:', imageUrl);
| |
| }
| |
| }
| |
|
| |
|
| function parseImageFromWikitext(wikitext) { | | function parseImageFromWikitext(wikitext) { |
2025年10月20日 (一) 00:24的版本