panhui 2 лет назад
Родитель
Сommit
5e5ae44214

+ 10 - 3
src/api/index.ts

@@ -24,7 +24,7 @@ export function fetchChatAPIProcess<T = any>(params: {
     prompt: string
     options?: { conversationId?: string; parentMessageId?: string }
     signal?: GenericAbortSignal
-    code?: string | undefined
+    company?: any | undefined
     onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
 }) {
     const settingStore = useSettingStore()
@@ -32,8 +32,7 @@ export function fetchChatAPIProcess<T = any>(params: {
 
     let data: Record<string, any> = {
         prompt: params.prompt,
-        options: params.options,
-        code: params.code
+        options: params.options
     }
 
     console.log(authStore.isChatGPTAPI)
@@ -47,6 +46,14 @@ export function fetchChatAPIProcess<T = any>(params: {
     }
     // }
 
+    if (params.company.id !== 0) {
+        data.systemMessage = params.company.desc || ''
+    }
+
+    if (params.company.code) {
+        data.code = params.company.code
+    }
+
     return post<T>({
         url: '/chat/chat-process1',
         data,

+ 71 - 0
src/components/common/InfoForm.vue

@@ -0,0 +1,71 @@
+<template>
+    <div class="p-5">
+        <n-form ref="loginForm" :model="form" :rules="rules">
+            <n-form-item ref="phoneRef" path="phone" label="姓名">
+                <n-input v-model:value="form.phone" placeholder="请输入手机号" :allow-input="onlyAllowNumber">
+                </n-input>
+            </n-form-item>
+            <n-form-item path="code" label="验证码" class="w-100">
+                <div class="flex flex-1">
+                    <n-input
+                        class="flex-1"
+                        v-model:value="form.code"
+                        placeholder="请输入验证码"
+                        :allow-input="onlyAllowNumber"
+                    >
+                    </n-input>
+                </div>
+            </n-form-item>
+            <div class="mt-3">
+                <n-button class="h-10" @click="submit" block type="primary" size="large" :loading="loading" circle>
+                    登录
+                </n-button>
+            </div>
+        </n-form>
+    </div>
+</template>
+
+<script setup lang="ts">
+import { NForm, NFormItem, NInput, NButton } from 'naive-ui'
+import { ref } from 'vue'
+
+const form = ref({
+    phone: '',
+    code: '',
+    invitor: ''
+})
+const rules = {
+    phone: [
+        {
+            validator(rule: any, value: any) {
+                if (!value) {
+                    return new Error('请输入手机号')
+                } else if (!/^1[3-9]\d{9}$/.test(value)) {
+                    return new Error('手机号格式错误')
+                }
+
+                return true
+            },
+            trigger: ['submit']
+        }
+    ],
+    code: [
+        {
+            validator(rule: any, value: any) {
+                if (!value) {
+                    return new Error('请输入验证码')
+                } else if (!/^\d{4}$/.test(value)) {
+                    return new Error('验证码格式错误')
+                }
+
+                return true
+            },
+            trigger: ['submit']
+        }
+    ]
+}
+const onlyAllowNumber = (value: string) => !value || /^\d+$/.test(value)
+
+const loading = ref(false)
+function submit() {}
+</script>

+ 3 - 1
src/components/common/index.ts

@@ -21,6 +21,7 @@ import RuleContent from './RuleContent.vue'
 import MomentInfo from './MomentInfo.vue'
 import CommentInfo from './CommentInfo.vue'
 import LikeBtn from './LikeBtn.vue'
+import InfoForm from './InfoForm.vue'
 
 export {
     HoverButton,
@@ -45,5 +46,6 @@ export {
     AgentPannel,
     MomentInfo,
     CommentInfo,
-    LikeBtn
+    LikeBtn,
+    InfoForm
 }

+ 5 - 0
src/router/index.ts

@@ -124,6 +124,11 @@ const routes: RouteRecordRaw[] = [
                 path: 'agent',
                 name: 'agent',
                 component: () => import('@/views/page/AgentView.vue')
+            },
+            {
+                path: 'info',
+                name: 'info',
+                component: () => import('@/views/page/InfoView.vue')
             }
         ]
     },

+ 2 - 1
src/store/modules/auth/index.ts

@@ -60,7 +60,8 @@ export const useAuthStore = defineStore('auth-store', {
                 this.removeToken()
                 companyStore.getCompanyInfo(userStore.userInfo.apiUserId)
                 this.setToken(data.access_token)
-            } else {
+            } 
+            else {
                 this.removeToken()
                 companyStore.getCompanyInfo(0)
                 this.setToken(data.access_token)

+ 6 - 1
src/store/modules/chat/helper.ts

@@ -1,6 +1,6 @@
 import { ss } from '@/utils/storage'
 
-const LOCAL_NAME = 'chatStorage'
+let LOCAL_NAME = 'chatStorage'
 
 export function defaultState(): Chat.ChatState {
     const uuid = 1002
@@ -20,3 +20,8 @@ export function getLocalState(): Chat.ChatState {
 export function setLocalState(state: Chat.ChatState) {
     ss.set(LOCAL_NAME, state)
 }
+
+
+export function changeLoalName(name: string) {
+    LOCAL_NAME = name
+}

+ 6 - 1
src/store/modules/chat/index.ts

@@ -1,5 +1,5 @@
 import { defineStore } from 'pinia'
-import { getLocalState, setLocalState } from './helper'
+import { getLocalState, setLocalState, changeLoalName } from './helper'
 import { router } from '@/router'
 
 export const useChatStore = defineStore('chat-store', {
@@ -188,6 +188,11 @@ export const useChatStore = defineStore('chat-store', {
 
         recordState() {
             setLocalState(this.$state)
+        },
+
+        changeChatLocal(name: string) {
+            changeLoalName(name)
+            this.$state = getLocalState()
         }
     }
 })

+ 6 - 4
src/store/modules/company/helper.ts

@@ -6,6 +6,9 @@ export interface CompanyInfo {
     id?: string | number | undefined
     name?: string
     code?: string
+    logo?: string
+    companyName?: string
+    desc?: string
 }
 
 export interface CompanyState {
@@ -16,16 +19,15 @@ export function defaultSetting(): CompanyState {
     return {
         company: {
             id: 0,
-            name: '走马AI'
+            name: '走马AI',
+            companyName: '走马AI助手',
+            logo: 'https://nebuai.oss-cn-hangzhou.aliyuncs.com/image/logo/logo-text.png'
         }
     }
 }
 
 export function getLocalState(): CompanyState {
     const localSetting: CompanyInfo | undefined = ss.get(LOCAL_NAME)
-    if (localSetting?.name) {
-        document.title = localSetting.name + '助手'
-    }
     return { ...defaultSetting(), ...localSetting }
 }
 

+ 13 - 3
src/store/modules/company/index.ts

@@ -5,6 +5,7 @@ import { defaultSetting, getLocalState, setLocalState } from './helper'
 import { fetchGetCompany } from '@/api'
 import { Response } from '@/utils/request'
 import { useAuthStore } from '../auth'
+import { useChatStore } from '../chat'
 
 export const useCompanyStore = defineStore('company-store', {
     state: (): CompanyState => getLocalState(),
@@ -25,15 +26,24 @@ export const useCompanyStore = defineStore('company-store', {
                 this.setCompanyInfo({
                     id: 0,
                     name: '走马AI',
-                    code: undefined
+                    code: undefined,
+                    companyName: '走马AI助手',
+                    logo: 'https://nebuai.oss-cn-hangzhou.aliyuncs.com/image/logo/logo-text.png'
                 })
                 useAuthStore().changeToken(`SECRET_TOKEN`)
+                useChatStore().changeChatLocal('chatStorage')
                 document.title = '走马AI助手'
             } else {
                 await fetchGetCompany(companyId).then((res: any) => {
-                    this.setCompanyInfo(res)
+                    this.setCompanyInfo({
+                        ...res,
+                        companyName: res.company ? res.company : res.name + '助手',
+                        logo: res.logo || 'https://nebuai.oss-cn-hangzhou.aliyuncs.com/image/logo/logo-text.png',
+                        code: res.code || undefined
+                    })
                     useAuthStore().changeToken(`SECRET_TOKEN${res.id === 0 ? '' : res.id}`)
-                    document.title = res.name + '助手'
+                    useChatStore().changeChatLocal(`chatStorage${res.id}`)
+                    document.title = res.companyName
                 })
             }
         }

+ 2 - 0
src/store/modules/user/index.ts

@@ -5,6 +5,7 @@ import { fetchMy } from '@/api'
 import { useAuthStore } from '../auth'
 import { useUserMemberStore } from '../memberShip'
 import { useCompanyStore } from '../company'
+import { useChatStore } from '../chat'
 
 export const useUserStore = defineStore('user-store', {
     state: (): UserState => defaultSetting(),
@@ -27,6 +28,7 @@ export const useUserStore = defineStore('user-store', {
             const companyStore = useCompanyStore()
             if (companyStore.company.id !== 0) {
                 useAuthStore().changeToken(`SECRET_TOKEN${companyStore.company.id}`)
+                useChatStore().changeChatLocal(`chatStorage${companyStore.company.id}`)
             }
             const data = await fetchMy<UserInfo>()
             this.setUserInfo(data)

+ 2 - 2
src/styles/global.less

@@ -21,12 +21,12 @@ body {
 
 @font-face {
     font-family: 'AlimamaShuHeiTi';
-    src: url(https://cdn.raex.vip/font/2023-03-24-10-09-25HtghnVXP.ttf);
+    src: url(https://nebuai.oss-cn-hangzhou.aliyuncs.com/fonts/alimamaShuHeiTi.ttf);
 }
 
 @font-face {
     font-family: 'MiSans';
-    src: url(https://zouma-live.oss-cn-hangzhou.aliyuncs.com/fonts/MiSans-Bold.ttf);
+    src: url(https://nebuai.oss-cn-hangzhou.aliyuncs.com/fonts/MiSans-Bold.ttf);
 }
 
 .alimamaShuHeiTi {

+ 2 - 2
src/views/chat/Chat.vue

@@ -134,7 +134,7 @@ async function onConversation() {
                 prompt: message,
                 options,
                 signal: controller.signal,
-                code: company.value.code,
+                company: company.value,
                 onDownloadProgress: ({ event }) => {
                     const xhr = event.target
                     const { responseText } = xhr
@@ -240,7 +240,7 @@ async function onRegenerate(index: number) {
                 prompt: message,
                 options,
                 signal: controller.signal,
-                code: company.value.code,
+                company: company.value,
                 onDownloadProgress: ({ event }) => {
                     const xhr = event.target
                     const { responseText } = xhr

+ 9 - 9
src/views/page/HomeView.vue

@@ -18,10 +18,10 @@
                     >
                         <!-- <n-avatar :size="isMobile ? 'small' : 'medium'" :src="logo"></n-avatar> -->
                         <!-- <span class="ml-[6px] lg:ml-3 text-white text-base lg:text-lg alimamaShuHeiTi">走马AI助手 </span> -->
-                        <img :src="logo" class="h-[28px] md:h-[40px]" alt="" />
-                        <span class="miSans text-lg text-white ml-1 md:text-[26px] md:ml-2"
-                            >{{ company.name }}助手</span
-                        >
+                        <img :src="company.logo" class="h-[28px] md:h-[40px]" alt="" />
+                        <span class="miSans text-lg text-white ml-1 md:text-[26px] md:ml-2">{{
+                            company.companyName
+                        }}</span>
                     </div>
                 </template>
                 <template #extra>
@@ -63,14 +63,14 @@
             class="flex flex-col items-center content-center px-4 md:pl-10 lg:pl-15 2xl:pl-52 md:items-start flex-1 pt-4 pb-24 page-content md:pb-4 md:justify-center"
         >
             <!-- <img :src="brand" class="w-3/4 max-w-[510px] md:translate-x-[-10px]" alt="" /> -->
-            <div class="miSans text-[40px] text-white md:text-[90px]">{{ company.name }}助手</div>
+            <div class="miSans text-[40px] text-white md:text-[90px]">{{ company.companyName }}</div>
 
             <div
                 class="text-xs leading-6 md:text-base text-white opacity-80 text-center md:text-left mt-4 w-[90%] max-w-[705px]"
             >
                 {{
-                    company.name
-                }}助手是人工智能技术驱动的自然语言处理工具,它能够通过理解和学习人类的语言来进行对话,还能根据聊天的上下文进行互动,真正像人类一样来聊天交流,并能完成撰写邮件、视频脚本、文案、翻译、代码,写论文等任务。后续更新:向量数据库应用,AI助手角色赋予,AI助手私有化,FileChat等。
+                    company.companyName
+                }}是人工智能技术驱动的自然语言处理工具,它能够通过理解和学习人类的语言来进行对话,还能根据聊天的上下文进行互动,真正像人类一样来聊天交流,并能完成撰写邮件、视频脚本、文案、翻译、代码,写论文等任务。后续更新:向量数据库应用,AI助手角色赋予,AI助手私有化,FileChat等。
             </div>
 
             <NConfigProvider
@@ -383,8 +383,8 @@ const pageType = computed(() => {
 watch(
     company,
     () => {
-        if (company.value.name) {
-            document.title = company.value.name
+        if (company.value.companyName) {
+            document.title = company.value.companyName
         }
     },
     {

+ 38 - 0
src/views/page/InfoView.vue

@@ -0,0 +1,38 @@
+<template>
+    <div class="page h-full flex flex-col">
+        <n-page-header title="获取信息" @back="handleBack">
+            <template #extra>
+                <div class="w-[22px]"></div>
+            </template>
+        </n-page-header>
+        <info-form></info-form>
+    </div>
+</template>
+
+<script setup lang="ts">
+import {InfoForm} from '@/components/common'
+import { NPageHeader } from 'naive-ui'
+import { useRouter } from 'vue-router'
+
+const router = useRouter()
+function handleBack() {
+    router.back()
+}
+</script>
+
+<style lang="less" scoped>
+.page {
+    color: var(--n-text-color);
+}
+:deep(.n-page-header) {
+    height: 50px;
+    padding: 0 22px;
+    .n-page-header__main {
+        flex-grow: 1;
+        .n-page-header__title {
+            flex-grow: 1;
+            text-align: center;
+        }
+    }
+}
+</style>