Explorar o código

对接全局人设

王晓东 hai 1 mes
pai
achega
4be1e081ce

+ 10 - 5
src/api/modules/model.ts

@@ -3,15 +3,10 @@ import type { TModel } from '@/types/model'
 
 // 获取大模型列表
 export async function fetchModel(){
-  // return request<{
-  //   total: number,
-  //   content: TModel[]
-  // }>(`/anycall/selectLLMModel`)
   const res = await request<{
     total: number,
     content: TModel[]
   }>(`/anycall/selectLLMModel`)
-  console.log(res.data, 4444444)
   //@ts-ignore
   return res.data
 }
@@ -44,3 +39,13 @@ export async function fetchModelDetail(params: {id: string}){
   return res.data
 }
 
+export async function selectGlobalPrompt(){
+  return await request<string>(`/anycall/admin/selectGlobalPrompt`)
+}
+export async function updateGlobalPrompt(globalPrompt: string){
+  return await request<string>(`/anycall/admin/updateGlobalPrompt`, {}, {
+    params: {'globalPrompt': globalPrompt}
+  })
+
+}
+

+ 4 - 4
src/router/modules/model/tips.ts → src/router/modules/model/globalPrompt.ts

@@ -6,7 +6,7 @@ function Layout() {
 }
 
 const routes: RouteRecordRaw = {
-  path: '/tips',
+  path: '/global-prompt',
   component: Layout,
   name: 'tips',
   meta: {
@@ -17,13 +17,13 @@ const routes: RouteRecordRaw = {
   children: [
     {
       path: '',
-      name: 'tipsList',
-      component: () => import('@/views/model/tips/index.vue'),
+      name: 'globalPrompt',
+      component: () => import('@/views/model/global-prompt/index.vue'),
       meta: {
         title: '提示词列表',
         breadcrumb: false,
         menu: false,
-        activeMenu: '/tips',
+        activeMenu: '/global-prompt',
       },
     },
   ],

+ 2 - 2
src/router/routes.ts

@@ -7,7 +7,7 @@ import RoleManagement from './modules/role'
 import VoiceManagement from './modules/voice'
 import Recomendation from './modules/recomendation'
 import Model from './modules/model/model'
-import Tips from './modules/model/tips'
+import GlobalPrompt from './modules/model/globalPrompt'
 
 
 function Layout() {
@@ -86,7 +86,7 @@ const asyncRoutes: Route.recordMainRaw[] = [
     },
     children: [
       Model,
-      Tips,
+      GlobalPrompt,
     ],
   },
 ]

+ 0 - 0
src/views/model/tips/components/EditForm.vue → src/views/model/global-prompt/components/EditForm.vue


+ 65 - 0
src/views/model/global-prompt/index.vue

@@ -0,0 +1,65 @@
+<script setup lang="ts">
+import { Plus } from '@element-plus/icons-vue'
+import { ElButton, ElDialog, ElEmpty, ElInput, ElMessage, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
+
+import { selectGlobalPrompt, updateGlobalPrompt } from '@/api/modules/model'
+import { toast } from 'vue-sonner'
+
+const loading = ref(false)
+const input = ref<string>('')
+
+
+async function fetchData() {
+  loading.value = true
+  const {code, data} = await selectGlobalPrompt()
+  if(code === 0){
+    input.value = data
+  }
+  loading.value = false
+}
+
+
+async function handleSave () {
+  const {code, data} = await updateGlobalPrompt(input.value)
+  if(code === 0){
+    toast.success('保存成功')
+  }
+}
+
+
+
+onMounted(async () => {
+  await fetchData()
+})
+
+
+</script>
+
+<template>
+  <div class="absolute-container">
+    <FaPageHeader title="全局提示词" />
+    <FaPageMain class="flex-1 overflow-auto" main-class="flex-1 flex flex-col overflow-auto">
+      <el-input
+        v-model="input"
+        style="width: 100%;"
+        :autosize="{ minRows: 2, maxRows: 4 }"
+        type="textarea"
+        placeholder="Please input"
+        class="mb-4"
+      />
+      <ElSpace>
+        <ElButton type="primary" @click="handleSave">保存</ElButton>
+      </ElSpace>
+
+    </FaPageMain>
+  </div>
+</template>
+<style scoped>
+.absolute-container {
+  position: absolute;
+  display: flex;
+  flex-direction: column;
+  width: 100%;
+  height: 100%;
+}
+</style>

+ 0 - 92
src/views/model/tips/index.vue

@@ -1,92 +0,0 @@
-<script setup lang="ts">
-import { Plus } from '@element-plus/icons-vue'
-import { ElButton, ElDialog, ElEmpty, ElInput, ElMessage, ElOption, ElPagination, ElSelect, ElTable, ElTableColumn, ElTag } from 'element-plus'
-
-import { fetchModel } from '@/api/modules/model'
-import EditForm from './components/EditForm.vue'
-type TTipsItem = {
-  text: string,
-  id: string,
-  sort: number,
-}
-
-const tableRef = ref()
-const loading = ref(false)
-const dialogVisible = ref(false)
-const currentText = ref<{id?: string, text: string}|null>()
-
-const dataList = ref<TTipsItem[]>([]);
-const input = ref<string[]>(['tag1', 'tag2', 'tag3'])
-
-
-async function fetchData() {
-  // loading.value = true
-  // const res = await fetchModel()
-  // console.log(res, 'res')
-  // if(res.code === 0){
-  //   dataList.value = res.data.content
-  //   console.log(dataList.value, 'dataList')
-  //   pagination.value.total = res.data.total
-  // }
-  // loading.value = false
-}
-
-
-function handleDelete (row: TModel) {
-  console.log(row, 'delete')
-  ElMessage.info('查看功能待开发')
-}
-
-const  handleCreate = ()=> {
-  dialogVisible.value = true
-}
-
-onMounted(async () => {
-  await fetchData()
-})
-
-
-</script>
-
-<template>
-  <div class="absolute-container">
-    <FaPageHeader title="全局提示词" />
-    <FaPageMain class="flex-1 overflow-auto" main-class="flex-1 flex flex-col overflow-auto">
-      <el-input-tag v-model="input" draggable placeholder="Please input" />
-      <!-- <div class="pb-4">
-        <ElSpace>
-          <ElButton type="primary" :icon="Plus" @click="handleCreate">添加提示词</ElButton>
-        </ElSpace>
-      </div>
-      <ElTable
-        v-loading="loading"
-        ref="tableRef" :data="dataList" stripe highlight-current-row border height="100%"
-      >
-        <ElTableColumn label="sort" prop="sort" width="80" />
-        <ElTableColumn label="id" prop="id" width="140" />
-        <ElTableColumn label="Text" prop="text" min-width="240" />
-        <ElTableColumn fixed="right" label="操作" min-width="200">
-          <template #default="{row}">
-            <ElPopconfirm title="确定删除吗?" @confirm="handleDelete(row)">
-              <template #reference>
-                <ElButton link type="danger" size="small">
-                删除
-                </ElButton>
-              </template>
-            </ElPopconfirm>
-          </template>
-        </ElTableColumn>
-      </ElTable> -->
-    </FaPageMain>
-    <!-- <EditForm v-model:visible="dialogVisible" v-model="currentText" @refresh="()=> {}"  ></EditForm> -->
-  </div>
-</template>
-<style scoped>
-.absolute-container {
-  position: absolute;
-  display: flex;
-  flex-direction: column;
-  width: 100%;
-  height: 100%;
-}
-</style>