xiongzhu hace 2 años
padre
commit
023d982c51

+ 2 - 0
.env

@@ -10,3 +10,5 @@ VITE_GLOB_OPEN_LONG_REPLY=false
 VITE_GLOB_APP_PWA=false
 VITE_GLOB_APP_PWA=false
 
 
 VITE_GLOB_APP_PUBLIC_PATH=/ui/
 VITE_GLOB_APP_PUBLIC_PATH=/ui/
+
+VITE_ORG_MODE=false

+ 2 - 0
.env.development

@@ -32,3 +32,5 @@ VITE_GLOB_OPEN_LONG_REPLY=false
 VITE_GLOB_APP_PWA=false
 VITE_GLOB_APP_PWA=false
 
 
 VITE_GLOB_APP_PUBLIC_PATH=/ui/
 VITE_GLOB_APP_PUBLIC_PATH=/ui/
+
+VITE_ORG_MODE=false

+ 14 - 0
.env.org

@@ -0,0 +1,14 @@
+# Glob API URL
+VITE_GLOB_API_URL=/api
+
+VITE_APP_API_BASE_URL=/api
+
+# Whether long replies are supported, which may result in higher API fees
+VITE_GLOB_OPEN_LONG_REPLY=false
+
+# When you want to use PWA
+VITE_GLOB_APP_PWA=false
+
+VITE_GLOB_APP_PUBLIC_PATH=/ui/
+
+VITE_ORG_MODE=false

+ 3 - 1
.env.production

@@ -9,4 +9,6 @@ VITE_GLOB_OPEN_LONG_REPLY=false
 # When you want to use PWA
 # When you want to use PWA
 VITE_GLOB_APP_PWA=false
 VITE_GLOB_APP_PWA=false
 
 
-VITE_GLOB_APP_PUBLIC_PATH=/ui/
+VITE_GLOB_APP_PUBLIC_PATH=/ui/
+
+VITE_ORG_MODE=false

+ 2 - 2
src/App.vue

@@ -38,8 +38,8 @@ const company = computed(() => {
 watch(
 watch(
     company,
     company,
     () => {
     () => {
-        if (company.value.companyName) {
-            document.title = company.value.companyName
+        if (company.value.assistantName) {
+            document.title = company.value.assistantName
         }
         }
         if (company.value.logo) {
         if (company.value.logo) {
             let link = document.createElement('link')
             let link = document.createElement('link')

+ 1 - 37
src/api/index.ts

@@ -24,7 +24,6 @@ export function fetchChatAPIProcess<T = any>(params: {
     prompt: string
     prompt: string
     options?: { conversationId?: string; parentMessageId?: string }
     options?: { conversationId?: string; parentMessageId?: string }
     signal?: GenericAbortSignal
     signal?: GenericAbortSignal
-    company?: any | undefined
     onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
     onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
 }) {
 }) {
     const settingStore = useSettingStore()
     const settingStore = useSettingStore()
@@ -46,14 +45,6 @@ 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>({
     return post<T>({
         url: '/chat/chat-process1',
         url: '/chat/chat-process1',
         data,
         data,
@@ -62,33 +53,6 @@ export function fetchChatAPIProcess<T = any>(params: {
     })
     })
 }
 }
 
 
-export function fetchChatPDF<T = any>(params: {
-    prompt: string
-    options?: { conversationId?: string; parentMessageId?: string }
-    signal?: GenericAbortSignal
-    onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void
-    name?: string
-}) {
-    const settingStore = useSettingStore()
-    const authStore = useAuthStore()
-
-    let data: Record<string, any> = {
-        prompt: params.prompt,
-        options: params.options
-    }
-    data = {
-        q: params.prompt,
-        name: params.name
-    }
-
-    return post<T>({
-        url: '/chat-pdf/ask',
-        data,
-        signal: params.signal,
-        onDownloadProgress: params.onDownloadProgress
-    })
-}
-
 export function fetchSession<T>() {
 export function fetchSession<T>() {
     return post<T>({
     return post<T>({
         url: '/chat/session'
         url: '/chat/session'
@@ -243,6 +207,6 @@ export function fetchGetChatRole<T>(id: any) {
 
 
 export function fetchGetCompany<T>(id: any) {
 export function fetchGetCompany<T>(id: any) {
     return get<T>({
     return get<T>({
-        url: '/apiUser/get/' + id
+        url: '/org/' + id
     })
     })
 }
 }

+ 0 - 4
src/components/common/LoginForm.vue

@@ -296,10 +296,6 @@ onMounted(() => {
     if (window.sessionStorage.getItem('invitor')) {
     if (window.sessionStorage.getItem('invitor')) {
         form.value.invitor = String(window.sessionStorage.getItem('invitor'))
         form.value.invitor = String(window.sessionStorage.getItem('invitor'))
     }
     }
-
-    if (company.value.id !== 0 && company.value.userId && company.value.type !== 2) {
-        form.value.invitor = String(company.value.userId)
-    }
 })
 })
 
 
 const showRule = ref(false)
 const showRule = ref(false)

+ 4 - 4
src/components/common/ShareModal.vue

@@ -9,17 +9,17 @@
                 </div> -->
                 </div> -->
                 <div class="text1">
                 <div class="text1">
                     <div>邀请好友</div>
                     <div>邀请好友</div>
-                    <div>加入{{ company.companyName }}</div>
+                    <div>加入{{ company.name }}</div>
                 </div>
                 </div>
-                <div class="text2">带领一小部分人先驾驭{{ company.companyName }}!</div>
+                <div class="text2">带领一小部分人先驾驭{{ company.name }}!</div>
                 <div class="text3">
                 <div class="text3">
                     <div class="logo flex items-center">
                     <div class="logo flex items-center">
                         <img v-if="company.logo" :src="company.logo" alt="" />
                         <img v-if="company.logo" :src="company.logo" alt="" />
                         <img v-else src="@/assets/share-logo1.png" alt="" />
                         <img v-else src="@/assets/share-logo1.png" alt="" />
-                        <span class="ml-[5px]">{{ company.companyName }}</span>
+                        <span class="ml-[5px]">{{ company.name }}</span>
                     </div>
                     </div>
                     <div class="info">
                     <div class="info">
-                        {{ company.companyName }}不会淘汰你,但能驾驭{{ company.companyName }}的人会淘汰你!
+                        {{ company.name }}不会淘汰你,但能驾驭{{ company.name }}的人会淘汰你!
                     </div>
                     </div>
                 </div>
                 </div>
                 <div class="qrcode flex items-center justify-center">
                 <div class="qrcode flex items-center justify-center">

+ 0 - 18
src/store/modules/auth/index.ts

@@ -53,24 +53,6 @@ export const useAuthStore = defineStore('auth-store', {
         async phoneLogin(phone: string | number, code: string | number, invitor?: string | number) {
         async phoneLogin(phone: string | number, code: string | number, invitor?: string | number) {
             const data = await fetchPhoneLogin<any>(phone, code, invitor)
             const data = await fetchPhoneLogin<any>(phone, code, invitor)
             this.setToken(data.access_token)
             this.setToken(data.access_token)
-            const userStore = useUserStore()
-            await userStore.fetch()
-            const companyStore = useCompanyStore()
-            if (userStore.userInfo.roles?.includes('api')) {
-                this.removeToken()
-                companyStore.getCompanyInfo(userStore.userInfo.apiUserId)
-                this.setToken(data.access_token)
-            } 
-            else if(companyStore.company.type===2) {
-                this.removeToken()
-                companyStore.getCompanyInfo(0)
-                this.setToken(data.access_token)
-            }
-        },
-
-        changeToken(name: string) {
-            changeLoalName(name)
-            this.token = getToken()
         }
         }
     }
     }
 })
 })

+ 3 - 17
src/store/modules/company/helper.ts

@@ -1,15 +1,9 @@
-import { ss } from '@/utils/storage/session'
-
-const LOCAL_NAME = 'companyStorage'
-
 export interface CompanyInfo {
 export interface CompanyInfo {
     id?: string | number | undefined
     id?: string | number | undefined
     name?: string
     name?: string
-    code?: string
     logo?: string
     logo?: string
-    companyName?: string
-    desc?: string
-    userId?: string | number
+    assistantName?: string
+    description?: string
     type?:string | number
     type?:string | number
 }
 }
 
 
@@ -22,17 +16,9 @@ export function defaultSetting(): CompanyState {
         company: {
         company: {
             id: 0,
             id: 0,
             name: '走马AI',
             name: '走马AI',
-            companyName: '走马AI助手'
+            assistantName: '走马AI助手'
             // logo: 'https://nebuai.oss-cn-hangzhou.aliyuncs.com/image/logo/logo-text.png'
             // 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)
-    return { ...defaultSetting(), ...localSetting }
-}
-
-export function setLocalState(setting: CompanyState): void {
-    ss.set(LOCAL_NAME, setting)
-}

+ 12 - 16
src/store/modules/company/index.ts

@@ -1,44 +1,40 @@
 import { defineStore } from 'pinia'
 import { defineStore } from 'pinia'
 import { store } from '@/store'
 import { store } from '@/store'
 import type { CompanyInfo, CompanyState } from './helper'
 import type { CompanyInfo, CompanyState } from './helper'
-import { defaultSetting, getLocalState, setLocalState } from './helper'
 import { fetchGetCompany } from '@/api'
 import { fetchGetCompany } from '@/api'
-import { Response } from '@/utils/request'
-import { useAuthStore } from '../auth'
-import { useChatStore } from '../chat'
 
 
 export const useCompanyStore = defineStore('company-store', {
 export const useCompanyStore = defineStore('company-store', {
-    state: (): CompanyState => getLocalState(),
+    state: (): CompanyState => {
+        return {
+            company: {
+                id: 0,
+                name: '走马AI',
+                assistantName: '走马AI助手'
+                // logo: 'https://nebuai.oss-cn-hangzhou.aliyuncs.com/image/logo/logo-text.png'
+            }
+        }
+    },
 
 
     getters: {},
     getters: {},
 
 
     actions: {
     actions: {
         setCompanyInfo(company: Partial<CompanyInfo>) {
         setCompanyInfo(company: Partial<CompanyInfo>) {
             this.company = { ...this.company, ...company }
             this.company = { ...this.company, ...company }
-            this.recordState()
-        },
-        recordState() {
-            setLocalState(this.$state)
         },
         },
         async getCompanyInfo(companyId: number | undefined | string) {
         async getCompanyInfo(companyId: number | undefined | string) {
             if (companyId === 0) {
             if (companyId === 0) {
                 this.setCompanyInfo({
                 this.setCompanyInfo({
                     id: 0,
                     id: 0,
                     name: '走马AI',
                     name: '走马AI',
-                    code: undefined,
-                    companyName: '走马AI助手'
+                    assistantName: '走马AI助手'
                 })
                 })
-                useAuthStore().changeToken(`SECRET_TOKEN`)
-                useChatStore().changeChatLocal('chatStorage')
             } else {
             } else {
                 await fetchGetCompany(companyId).then((res: any) => {
                 await fetchGetCompany(companyId).then((res: any) => {
                     this.setCompanyInfo({
                     this.setCompanyInfo({
                         ...res,
                         ...res,
-                        companyName: res.company ? res.company : res.name + '助手',
+                        assistantName: res.company ? res.company : res.name + '助手',
                         code: res.code || undefined
                         code: res.code || undefined
                     })
                     })
-                    useAuthStore().changeToken(`SECRET_TOKEN${res.id === 0 ? '' : res.id}`)
-                    // useChatStore().changeChatLocal(`chatStorage${res.id}`)
                 })
                 })
             }
             }
         }
         }

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

@@ -5,4 +5,4 @@ export * from './prompt'
 export * from './settings'
 export * from './settings'
 export * from './auth'
 export * from './auth'
 export * from './memberShip'
 export * from './memberShip'
-export * from './company'
+export * from './company'

+ 0 - 1
src/store/modules/user/helper.ts

@@ -8,7 +8,6 @@ export interface UserInfo {
     name: string
     name: string
     description: string
     description: string
     roles?: Array<string>
     roles?: Array<string>
-    apiUserId?: number
 }
 }
 
 
 export interface UserState {
 export interface UserState {

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

@@ -25,23 +25,8 @@ export const useUserStore = defineStore('user-store', {
         },
         },
 
 
         async fetch() {
         async fetch() {
-            const companyStore = useCompanyStore()
-            if (companyStore.company.id !== 0) {
-                useAuthStore().changeToken(`SECRET_TOKEN${companyStore.company.id}`)
-            }
             const data = await fetchMy<UserInfo>()
             const data = await fetchMy<UserInfo>()
             this.setUserInfo(data)
             this.setUserInfo(data)
-            if (data.id && companyStore.company.id !== 0 && !companyStore.company.code) {
-                companyStore.getCompanyInfo(companyStore.company.id)
-            }
-
-            if (companyStore.company.id !== 0) {
-                useChatStore().changeChatLocal(`chatStorage${companyStore.company.id}_${data.id}`)
-            }
-            else{
-                useChatStore().changeChatLocal(`chatStorage_${data.id}`)
-            }
-
             await useUserMemberStore().fetchMember()
             await useUserMemberStore().fetchMember()
         },
         },
 
 

+ 0 - 68
src/utils/storage/session.ts

@@ -1,68 +0,0 @@
-import { deCrypto, enCrypto } from '../crypto'
-
-interface StorageData<T = any> {
-    data: T
-    expire: number | null
-}
-
-export function createsessionStorage(options?: { expire?: number | null; crypto?: boolean }) {
-    const DEFAULT_CACHE_TIME = 60 * 60 * 24 * 7
-
-    const { expire, crypto } = Object.assign(
-        {
-            expire: DEFAULT_CACHE_TIME,
-            crypto: true
-        },
-        options
-    )
-
-    function set<T = any>(key: string, data: T) {
-        const storageData: StorageData<T> = {
-            data,
-            expire: expire !== null ? new Date().getTime() + expire * 1000 : null
-        }
-
-        const json = crypto ? enCrypto(storageData) : JSON.stringify(storageData)
-        window.sessionStorage.setItem(key, json)
-    }
-
-    function get(key: string) {
-        const json = window.sessionStorage.getItem(key)
-        if (json) {
-            let storageData: StorageData | null = null
-
-            try {
-                storageData = crypto ? deCrypto(json) : JSON.parse(json)
-            } catch {
-                // Prevent failure
-            }
-
-            if (storageData) {
-                const { data, expire } = storageData
-                if (expire === null || expire >= Date.now()) return data
-            }
-
-            remove(key)
-            return null
-        }
-    }
-
-    function remove(key: string) {
-        window.sessionStorage.removeItem(key)
-    }
-
-    function clear() {
-        window.sessionStorage.clear()
-    }
-
-    return {
-        set,
-        get,
-        remove,
-        clear
-    }
-}
-
-export const ls = createsessionStorage()
-
-export const ss = createsessionStorage({ expire: null, crypto: false })

+ 1 - 3
src/views/chat/Chat.vue

@@ -14,7 +14,7 @@ import HeaderComponent from './components/Header/index.vue'
 import { HoverButton, SvgIcon, MinePannel, VipPannel, MaskPannel, Share } from '@/components/common'
 import { HoverButton, SvgIcon, MinePannel, VipPannel, MaskPannel, Share } from '@/components/common'
 import { useBasicLayout } from '@/hooks/useBasicLayout'
 import { useBasicLayout } from '@/hooks/useBasicLayout'
 import { useChatStore, useAppStore, usePromptStore, useAuthStore, useUserMemberStore, useCompanyStore } from '@/store'
 import { useChatStore, useAppStore, usePromptStore, useAuthStore, useUserMemberStore, useCompanyStore } from '@/store'
-import { fetchChatAPIProcess, fetchChatPDF } from '@/api'
+import { fetchChatAPIProcess } from '@/api'
 import { t } from '@/locales'
 import { t } from '@/locales'
 import { useTheme } from '@/hooks/useTheme'
 import { useTheme } from '@/hooks/useTheme'
 import { emitter } from '@/plugins'
 import { emitter } from '@/plugins'
@@ -134,7 +134,6 @@ async function onConversation() {
                 prompt: message,
                 prompt: message,
                 options,
                 options,
                 signal: controller.signal,
                 signal: controller.signal,
-                company: company.value,
                 onDownloadProgress: ({ event }) => {
                 onDownloadProgress: ({ event }) => {
                     const xhr = event.target
                     const xhr = event.target
                     const { responseText } = xhr
                     const { responseText } = xhr
@@ -240,7 +239,6 @@ async function onRegenerate(index: number) {
                 prompt: message,
                 prompt: message,
                 options,
                 options,
                 signal: controller.signal,
                 signal: controller.signal,
-                company: company.value,
                 onDownloadProgress: ({ event }) => {
                 onDownloadProgress: ({ event }) => {
                     const xhr = event.target
                     const xhr = event.target
                     const { responseText } = xhr
                     const { responseText } = xhr

+ 5 - 7
src/views/page/HomeView.vue

@@ -19,9 +19,7 @@
                         <!-- <n-avatar :size="isMobile ? 'small' : 'medium'" :src="logo"></n-avatar> -->
                         <!-- <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> -->
                         <!-- <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="" />
                         <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.companyName
-                        }}</span>
+                        <span class="miSans text-lg text-white ml-1 md:text-[26px] md:ml-2">{{ company.name }}</span>
                     </div>
                     </div>
                 </template>
                 </template>
                 <template #extra>
                 <template #extra>
@@ -63,14 +61,15 @@
             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"
             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="" /> -->
             <!-- <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.companyName }}</div>
+            <div class="miSans text-[40px] text-white md:text-[90px]">{{ company.name }}</div>
 
 
             <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]"
                 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.companyName
-                }}是人工智能技术驱动的自然语言处理工具,它能够通过理解和学习人类的语言来进行对话,还能根据聊天的上下文进行互动,真正像人类一样来聊天交流,并能完成撰写邮件、视频脚本、文案、翻译、代码,写论文等任务。后续更新:向量数据库应用,AI助手角色赋予,AI助手私有化,FileChat等。
+                    company.description ||
+                    `${company.assistantName}是人工智能技术驱动的自然语言处理工具,它能够通过理解和学习人类的语言来进行对话,还能根据聊天的上下文进行互动,真正像人类一样来聊天交流,并能完成撰写邮件、视频脚本、文案、翻译、代码,写论文等任务。后续更新:向量数据库应用,AI助手角色赋予,AI助手私有化,FileChat等。`
+                }}
             </div>
             </div>
 
 
             <NConfigProvider
             <NConfigProvider
@@ -379,7 +378,6 @@ const pageType = computed(() => {
     }
     }
     return 'default'
     return 'default'
 })
 })
-
 </script>
 </script>
 
 
 <style lang="less" scoped>
 <style lang="less" scoped>

+ 1 - 1
src/views/page/LoginView.vue

@@ -5,7 +5,7 @@
                 <ChevronLeft />
                 <ChevronLeft />
             </n-icon>
             </n-icon>
         </n-el>
         </n-el>
-        <n-el class="text-2xl font-bold text-gray-900 dark:text-white">登录{{company.companyName}}</n-el>
+        <n-el class="text-2xl font-bold text-gray-900 dark:text-white">登录{{company.name}}</n-el>
         <n-el class="text-xs mt-2 text-gray-400 dark:text-gray-500">未注册手机验证后自动注册登录</n-el>
         <n-el class="text-xs mt-2 text-gray-400 dark:text-gray-500">未注册手机验证后自动注册登录</n-el>
 
 
         <div class="py-9">
         <div class="py-9">