mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
refactor: Optimize front-end request processing for bigintege fields (#559)
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
"github-markdown-css": "^5.8.1",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
"json-bigint": "^1.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
"markdown-it": "^14.1.0",
|
||||
@@ -47,6 +48,7 @@
|
||||
"@eslint/migrate-config": "^1.5.0",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"@types/element-resize-detector": "^1.1.6",
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@types/node": "^22.14.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useCache } from '@/utils/useCache'
|
||||
import { getLocale } from './utils'
|
||||
import { useAssistantStore } from '@/stores/assistant'
|
||||
import { useRouter } from 'vue-router'
|
||||
import JSONBig from 'json-bigint'
|
||||
// import { i18n } from '@/i18n'
|
||||
// const t = i18n.global.t
|
||||
const assistantStore = useAssistantStore()
|
||||
@@ -61,6 +62,22 @@ class HttpService {
|
||||
'Content-Type': 'application/json',
|
||||
...config?.headers,
|
||||
},
|
||||
// add transformResponse to bigint
|
||||
transformResponse: [
|
||||
function (data) {
|
||||
try {
|
||||
return JSONBig.parse(data) // use JSON-bigint
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (e) {
|
||||
try {
|
||||
return JSON.parse(data)
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (parseError) {
|
||||
return data
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
...config,
|
||||
})
|
||||
|
||||
@@ -442,7 +459,7 @@ class HttpService {
|
||||
export const request = new HttpService({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||
})
|
||||
/*
|
||||
/*
|
||||
const showLicenseKeyError = (msg?: string) => {
|
||||
ElMessageBox.confirm(t('license.error_tips'), {
|
||||
confirmButtonType: 'primary',
|
||||
|
||||
@@ -230,7 +230,6 @@ function onChatRenamed(chat: Chat) {
|
||||
{{ t('qa.new_chat') }}
|
||||
</el-button>
|
||||
<el-input
|
||||
@click.stop
|
||||
v-model="search"
|
||||
:prefix-icon="Search"
|
||||
class="search"
|
||||
@@ -238,6 +237,7 @@ function onChatRenamed(chat: Chat) {
|
||||
autocomplete="off"
|
||||
:placeholder="t('qa.chat_search')"
|
||||
clearable
|
||||
@click.stop
|
||||
/>
|
||||
</el-header>
|
||||
<el-main class="chat-list">
|
||||
|
||||
@@ -3,6 +3,7 @@ import BaseAnswer from './BaseAnswer.vue'
|
||||
import { Chat, chatApi, ChatInfo, type ChatMessage, ChatRecord, questionApi } from '@/api/chat.ts'
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
|
||||
import ChartBlock from '@/views/chat/chat-block/ChartBlock.vue'
|
||||
import JSONBig from 'json-bigint'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -141,7 +142,7 @@ const sendMessage = async () => {
|
||||
for (const str of split) {
|
||||
let data
|
||||
try {
|
||||
data = JSON.parse(str.replace('data:{', '{'))
|
||||
data = JSONBig.parse(str.replace('data:{', '{'))
|
||||
} catch (err) {
|
||||
console.error('JSON string:', str)
|
||||
throw err
|
||||
@@ -198,7 +199,6 @@ const sendMessage = async () => {
|
||||
if (!_currentChat.value.datasource) {
|
||||
_currentChat.value.datasource = data.id
|
||||
}
|
||||
_currentChat.value.records[index.value].chart = data.content
|
||||
break
|
||||
case 'finish':
|
||||
emits('finish', currentRecord.id)
|
||||
|
||||
Reference in New Issue
Block a user