旧版本中: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''.*'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。