打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

用户:RedDragon/Test2:修订间差异

来自Rizline中文维基
第39行: 第39行:
             .then(r => r.text())
             .then(r => r.text())
             .then(text => {
             .then(text => {
                 if (text.trim().startsWith('{')) {
                 console.log('原始响应:', text.substring(0, 500))
                     return JSON.parse(text)
                const jsonMatch = text.match(/\{"batchcomplete".*\}/s)
                if (jsonMatch) {
                     try {
                        const data = JSON.parse(jsonMatch[0])
                        const pages = data.query.pages
                        const pageId = Object.keys(pages)[0]
                        const wikitext = pages[pageId].revisions[0]['*']
                        const songs = parseSongsFromWikitext(wikitext)
 
                        songs.length > 0
                            ? loadSongColors(songs[Math.floor(Math.random() * songs.length)])
                            : useMockData()
                    } catch (e) {
                        console.error('JSON解析失败:', e)
                        useMockData()
                    }
                 } else {
                 } else {
                     const match = text.match(/{.*}/s)
                     console.error('未找到JSON数据')
                    if (match) {
                     useMockData()
                        return JSON.parse(match[0])
                    } else {
                        throw new Error('无法解析API响应')
                     }
                }
            })
            .then(data => {
                if (data.error) {
                    throw new Error(data.error.info || 'API错误')
                 }
                 }
                const pages = data.query.pages
                const pageId = Object.keys(pages)[0]
                const wikitext = pages[pageId].revisions[0]['*']
                const songs = parseSongsFromWikitext(wikitext)
                songs.length > 0
                    ? loadSongColors(songs[Math.floor(Math.random() * songs.length)])
                    : useMockData()
             })
             })
             .catch(e => {
             .catch(e => {
第97行: 第95行:
             .then(r => r.text())
             .then(r => r.text())
             .then(text => {
             .then(text => {
                 let data
                 const jsonMatch = text.match(/\{"batchcomplete".*\}/s)
                 if (text.trim().startsWith('{')) {
                 if (jsonMatch) {
                     data = JSON.parse(text)
                    try {
                        const data = JSON.parse(jsonMatch[0])
                        const pages = data.query.pages
                        const pageId = Object.keys(pages)[0]
                        if (!pages[pageId].revisions) {
                            throw new Error('页面不存在')
                        }
                        const wikitext = pages[pageId].revisions[0]['*']
                        const styles = parseStylesFromWikitext(wikitext)
 
                        updateSongInfo(song, {
                            titleStyle: styles.title || '#94E1FF',
                            headerStyle: styles.header || '#A3E5FF',
                            labelStyle: styles.label || '#B2E9FE',
                            imageUrl: `https://rizwiki.cn/images/thumb/${song.image.substring(0, 1)}/${song.image.substring(0, 2)}/${song.image}/300px-${song.image}`,
                            pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}`
                        })
                     } catch (e) {
                        console.error('解析曲目数据失败:', e)
                        throw e
                    }
                 } else {
                 } else {
                    const match = text.match(/{.*}/s)
                     throw new Error('未找到JSON数据')
                    data = match ? JSON.parse(match[0]) : {}
                }
 
                if (data.error) throw new Error(data.error.info || 'API错误')
 
                const pages = data.query.pages
                const pageId = Object.keys(pages)[0]
                if (!pages[pageId].revisions) {
                     throw new Error('页面不存在')
                 }
                 }
                const wikitext = pages[pageId].revisions[0]['*']
                const styles = parseStylesFromWikitext(wikitext)
                updateSongInfo(song, {
                    titleStyle: styles.title || '#94E1FF',
                    headerStyle: styles.header || '#A3E5FF',
                    labelStyle: styles.label || '#B2E9FE',
                    imageUrl: `https://rizwiki.cn/images/thumb/${song.image.substring(0, 1)}/${song.image.substring(0, 2)}/${song.image}/300px-${song.image}`,
                    pageUrl: `https://rizwiki.cn/wiki/${encodeURIComponent(song.title)}`
                })
             })
             })
             .catch(e => {
             .catch(e => {

2025年10月19日 (日) 22:10的版本

曲目
限制
难度 a
流速 b
MOD c
其他 d

神秘的随机挑战!


曲目
限制
难度 a
流速 b
MOD c
其他 d

User:RedDragon/Test User:RedDragon/Test1 User:RedDragon/Test2