From f72e4f47f477de320dbb75fd7df2ff9ba57965da Mon Sep 17 00:00:00 2001 From: hhhero Date: Mon, 8 Jul 2024 00:41:20 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E]=E5=AE=8C=E5=96=84AI?= =?UTF-8?q?=E5=86=99=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ai/writer/index.ts | 15 ++++- src/views/ai/writer/components/Left.vue | 38 ++++++++--- src/views/ai/writer/components/Right.vue | 85 ++++++++++++++++++++---- src/views/ai/writer/data.json | 11 +++ src/views/ai/writer/index.vue | 55 +++++++++++++-- 5 files changed, 174 insertions(+), 30 deletions(-) create mode 100644 src/views/ai/writer/data.json diff --git a/src/api/ai/writer/index.ts b/src/api/ai/writer/index.ts index 4ce4e2d0..01664b3d 100644 --- a/src/api/ai/writer/index.ts +++ b/src/api/ai/writer/index.ts @@ -1,4 +1,3 @@ -import request from '@/config/axios' import { fetchEventSource } from '@microsoft/fetch-event-source' import { getAccessToken } from '@/utils/auth' @@ -34,7 +33,19 @@ export interface WriteParams { */ language: number } -export const writeStream = (data: WriteParams, onMessage, onError, onClose, ctrl) => { +export const writeStream = ({ + data, + onClose, + onMessage, + onError, + ctrl +}: { + data: WriteParams + onMessage?: (res: any) => void + onError?: (...args: any[]) => void + onClose?: (...args: any[]) => void + ctrl: AbortController +}) => { // return request.post({ url: '/ai/write/generate-stream', data }) const token = getAccessToken() return fetchEventSource(`${config.base_url}/ai/write/generate-stream`, { diff --git a/src/views/ai/writer/components/Left.vue b/src/views/ai/writer/components/Left.vue index 9c3031ae..af808b15 100644 --- a/src/views/ai/writer/components/Left.vue +++ b/src/views/ai/writer/components/Left.vue @@ -13,7 +13,11 @@

{{ label }} - + {{ hint }} @@ -43,7 +47,7 @@ >