提交 7568a5cf 编写于 作者: D DebugIsFalse

fix: 403

上级 f0a6820a
......@@ -191,16 +191,24 @@ function handleFormatSource (source) {
}
})
}
function handleSetNoPermission () {
askingData.value = {}
useRequestError(403)
}
const handleFormFetchData = (fetchData) => {
let message = {}
try {
message = JSON.parse(fetchData)
} catch(error) { }
if (Object.keys(message).length === 0) return
const { meta, choices, error } = message
const { meta, choices, error, code } = message
nextTick(() => {
scrollToView()
})
// 处理403
if (error && code === 403) {
handleSetNoPermission()
}
// 不处理异常数据
if (!meta) {
handleStopGenerate()
......
import { fetchEventSource } from '@microsoft/fetch-event-source'
const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run'
// class PermissionError extends Error { }
export default (url, { onmessage, onerror, controller, params, onopen }) => {
const token = useCookie('token')
fetchEventSource(`${BASE_URL}${url}`, {
......@@ -14,6 +15,10 @@ export default (url, { onmessage, onerror, controller, params, onopen }) => {
const status = response.status
useRequestError(status)
onopen(status)
// todo
// if ([401, 403].includes(status)) {
// throw new PermissionError();
// }
},
onmessage (info) {
onmessage(info)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册