diff --git a/src/pages/chatgpt/fixSse.js b/src/pages/chatgpt/fixSse.js index 458f5f2ff..e65dc377e 100644 --- a/src/pages/chatgpt/fixSse.js +++ b/src/pages/chatgpt/fixSse.js @@ -2,10 +2,10 @@ import { SSE } from './sse' const initSSE = (apiKey, apiContent) => { // const source = new SSE(`https://api.openai.com/v1/chat/completions`, { - const source = new SSE(`https://api.zhizengzeng.com/v1/chat/completions`, { + const source = new SSE('https://api.zhizengzeng.com/v1/chat/completions', { headers: { 'Content-Type': 'application/json', - Authorization: `Bearer ${apiKey}`, + Authorization: `Bearer ${apiKey}` }, method: 'POST', start: false, @@ -15,10 +15,10 @@ const initSSE = (apiKey, apiContent) => { messages: [ { role: 'assistant', - content: apiContent, - }, - ], - }), + content: apiContent + } + ] + }) }) return source } diff --git a/src/pages/chatgpt/index.jsx b/src/pages/chatgpt/index.jsx index 1b846def1..dda27fd63 100644 --- a/src/pages/chatgpt/index.jsx +++ b/src/pages/chatgpt/index.jsx @@ -50,7 +50,7 @@ const ChatGpt = () => { console.log('NOT DONE') const payload = JSON.parse(e.data) const { - delta: { content }, + delta: { content } } = payload?.choices[0] || { delta: { content: '' } } if (content) { apiResultRef.current += content @@ -142,7 +142,7 @@ const ChatGpt = () => { if (e.data !== '[DONE]') { const payload = JSON.parse(e.data) const { - delta: { content }, + delta: { content } } = payload?.choices[0] || { delta: { content: '' } } if (content) { structureResultRef.current += content @@ -168,36 +168,36 @@ const ChatGpt = () => {
- + - + - @@ -215,15 +215,15 @@ const ChatGpt = () => { items: [ { key: '1', - label: '复制文本', + label: '复制文本' }, { key: '2', - label: '复制Markdown', - }, - ], + label: '复制Markdown' + } + ] }} - placement="bottom" + placement='bottom' arrow > @@ -266,18 +266,18 @@ const ChatGpt = () => { items: [ { key: '1', - label: '导出png格式', + label: '导出png格式' }, { key: '2', - label: '导出svg格式', - }, - ], + label: '导出svg格式' + } + ] }} - placement="bottom" + placement='bottom' arrow > - diff --git a/src/pages/chatgpt/scrollBottom.jsx b/src/pages/chatgpt/scrollBottom.jsx index 0d868b889..9104ed240 100644 --- a/src/pages/chatgpt/scrollBottom.jsx +++ b/src/pages/chatgpt/scrollBottom.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef } from 'react' -function AutoScrollSection({ messages }) { +function AutoScrollSection ({ messages }) { const sectionRef = useRef(null) useEffect(() => { @@ -16,7 +16,7 @@ function AutoScrollSection({ messages }) { height: 200, overflowY: 'auto', border: '1px solid #ccc', - padding: 8, + padding: 8 }} > {messages.map((msg, idx) => ( @@ -27,7 +27,7 @@ function AutoScrollSection({ messages }) { } // 使用示例 -export default function Demo() { +export default function Demo () { const [messages, setMessages] = React.useState(['Hello', 'World']) // 模拟新消息 diff --git a/src/pages/chatgpt/sse.js b/src/pages/chatgpt/sse.js index acc41e323..f585596a9 100644 --- a/src/pages/chatgpt/sse.js +++ b/src/pages/chatgpt/sse.js @@ -24,7 +24,7 @@ * @param {SSEOptions} options * @return {SSE} */ -var SSE = function (url, options) { +const SSE = function (url, options) { if (!(this instanceof SSE)) { return new SSE(url, options) } @@ -284,7 +284,7 @@ var SSE = function (url, options) { // consecutive 'data' is concatenated with newlines if (field === 'data' && e[field] !== null) { - e['data'] += '\n' + value + e.data += '\n' + value } else { e[field] = value } @@ -346,7 +346,7 @@ var SSE = function (url, options) { this.xhr.addEventListener('error', this._onStreamFailure.bind(this)) this.xhr.addEventListener('abort', this._onStreamAbort.bind(this)) this.xhr.open(this.method, this.url) - for (let header in this.headers) { + for (const header in this.headers) { this.xhr.setRequestHeader(header, this.headers[header]) } if (this.useLastEventId && this.lastEventId.length > 0) { diff --git a/src/pages/layout/proSecNav/index.jsx b/src/pages/layout/proSecNav/index.jsx index 26e051384..2a6ae8a7a 100644 --- a/src/pages/layout/proSecNav/index.jsx +++ b/src/pages/layout/proSecNav/index.jsx @@ -10,7 +10,7 @@ import { QuestionCircleOutlined, FireOutlined, GlobalOutlined, - QrcodeOutlined, + QrcodeOutlined } from '@ant-design/icons' import styles from './index.module.less' @@ -19,7 +19,7 @@ const pathSubmenu = { '/home': ['home'], '/coupons/add': ['/sub-act', '/sub-coupons'], '/coupons/edit': ['/sub-act', '/sub-coupons'], - '/product': ['/sub-act', '/sub-coupons'], + '/product': ['/sub-act', '/sub-coupons'] } const ProSecNav = () => { @@ -103,15 +103,15 @@ const ProSecNav = () => { icon: , children: [ { label: 'Vue', key: '/coupons/add' }, - { label: 'Angular', key: '/coupons/edit' }, - ], + { label: 'Angular', key: '/coupons/edit' } + ] }, { label: '后端技术栈', key: '/product', - icon: , - }, - ], + icon: + } + ] }, { label: '构建工具', @@ -119,25 +119,25 @@ const ProSecNav = () => { icon: , children: [ { label: 'Webpack', key: '/coupons/list' }, - { label: 'Vite', key: '/order/list' }, - ], + { label: 'Vite', key: '/order/list' } + ] }, { label: 'Error', key: '/sub-error', icon: , - children: [{ label: 'ErrorBoundary', key: '/error' }], - }, + children: [{ label: 'ErrorBoundary', key: '/error' }] + } ] return ( { export const customizeTimer = { intervalTimer: null, timeoutTimer: null, - setTimeout(cb, interval) { + setTimeout (cb, interval) { const { now } = Date const stime = now() let etime = stime @@ -78,10 +78,10 @@ export const customizeTimer = { this.timeoutTimer = requestAnimationFrame(loop) return this.timeoutTimer }, - clearTimeout() { + clearTimeout () { cancelAnimationFrame(this.timeoutTimer) }, - setInterval(cb, interval) { + setInterval (cb, interval) { const { now } = Date let stime = now() let etime = stime @@ -97,9 +97,9 @@ export const customizeTimer = { this.intervalTimer = requestAnimationFrame(loop) return this.intervalTimer }, - clearInterval() { + clearInterval () { cancelAnimationFrame(this.intervalTimer) - }, + } } export const isDecimal = (value) => { @@ -188,7 +188,7 @@ export const formatRomanNumeral = (num) => { { value: 9, numeral: 'IX' }, { value: 5, numeral: 'V' }, { value: 4, numeral: 'IV' }, - { value: 1, numeral: 'I' }, + { value: 1, numeral: 'I' } ] let result = '' for (const { value, numeral } of romanMap) { @@ -336,13 +336,13 @@ export const oneApiChat = (chatList, token, signal) => signal, headers: { Authorization: token, - 'Content-Type': 'application/json', + 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'gpt-4.1', messages: chatList, - stream: true, - }), + stream: true + }) }) export const getCurrentDate = () => { @@ -370,7 +370,7 @@ export const saveHtmlToPng = async (eleHtml, successFun, errorFun) => { try { const ele = eleHtml ?? document.getElementById('image-wrapper') const canvas = await html2canvas(ele, { - useCORS: true, + useCORS: true }) const imgUrl = canvas.toDataURL('image/png') const tempLink = document.createElement('a')