旧版本中:dev-server.js 这段去掉
apiRoutes =
apiRoutes.get('/getDiscList', url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg''https://c.y.qq.com/''c.y.qq.com'=>((e) =>
apiRoutes.get('/lyric',res) {
url = 'https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg'axios.get(url,params: req.query
}).then((response) =><span style="color: #000000"> {
<span style="color: #0000ff">var ret =<span style="color: #000000"> response.data
<span style="color: #0000ff">if (<span style="color: #0000ff">typeof ret === 'string'<span style="color: #000000">) {
<span style="color: #0000ff">var reg = /^\w+(({[^()]+}))$/
<span style="color: #0000ff">var matches =<span style="color: #000000"> ret.match(reg)
<span style="color: #0000ff">if<span style="color: #000000"> (matches) {
ret = JSON.parse(matches[1<span style="color: #000000">])
}
}
res.json(ret)
}).<span style="color: #0000ff">catch((e) =><span style="color: #000000"> {
console.log(e)
})
})
<span style="color: #008000">//<span style="color: #008000">use
app.use('/api',apiRoutes)
}).then((response) =><span style="color: #000000"> {
<span style="color: #0000ff">var ret =<span style="color: #000000"> response.data
<span style="color: #0000ff">if (<span style="color: #0000ff">typeof ret === 'string'<span style="color: #000000">) {
<span style="color: #0000ff">var reg = /^\w+(({[^()]+}))$/
<span style="color: #0000ff">var matches =<span style="color: #000000"> ret.match(reg)
<span style="color: #0000ff">if<span style="color: #000000"> (matches) {
ret = JSON.parse(matches[1<span style="color: #000000">])
}
}
res.json(ret)
}).<span style="color: #0000ff">catch((e) =><span style="color: #000000"> {
console.log(e)
})
})
<span style="color: #008000">//<span style="color: #008000">use
app.use('/api',apiRoutes)
在 新的 webpack.dev.config.js 中 添加
const express = require('express'= require('axios'= apiRoutes ='/api'
const devWebpackConfig =
'warning'/.*/,to: path.posix.join(config.dev.assetsPublicPath,'index.html'
app.get('/api/getDiscList', url = 'https://c.y.qq.com/splcloud/fcgi-bin/fcg_get_diss_by_tag.fcg''https://c.y.qq.com/''c.y.qq.com'=>((e) =>
hot: ,
compress: ||||? { warnings: ,errors: } : ,
'process.env': require('../config/dev.env' webpack.NamedModulesPlugin(),
'index.html''index.html'
'../static''.*'