Merge branch 'master' of http://47.103.154.90:83/r/WI/Web.V1.0
| | |
| | | import request from '/@/utils/request'; |
| | | import { toFormData } from '/@/utils/util'; |
| | | const GET_SECTION_SAMPLE_API = '/section/get_section_sample'; |
| | | const GET_SECTION_A_LIST_API = '/section/get_section_a_list'; |
| | | export const NO_AUTH_API_LIST = [GET_SECTION_SAMPLE_API, GET_SECTION_A_LIST_API]; |
| | | |
| | | //#region ====================== knowledge ====================== |
| | | |
| | |
| | | */ |
| | | export const getSectionList = async (req: any = request) => { |
| | | return req({ |
| | | url: '/section/get_section_a_list', |
| | | url: GET_SECTION_A_LIST_API, |
| | | method: 'POST', |
| | | }); |
| | | }; |
| | |
| | | // 获取AI对话测试例子列表 |
| | | export const getSelectSample = async (params, req: any = request) => { |
| | | return req({ |
| | | url: '/section/get_section_sample', |
| | | url: GET_SECTION_SAMPLE_API, |
| | | method: 'POST', |
| | | data: params, |
| | | headers: { |
| | |
| | | |
| | | /** |
| | | * 查询问题进度 |
| | | * @param params |
| | | * @param req |
| | | * @returns |
| | | * @param params |
| | | * @param req |
| | | * @returns |
| | | */ |
| | | export const getQuestionProcess = async (params, req: any = request) => { |
| | | return req({ |
| | |
| | | }, |
| | | }); |
| | | }; |
| | | |
| | |
| | | import request from '/@/utils/request'; |
| | | import { toFormData } from '/@/utils/util'; |
| | | |
| | | export const LOGIN_URL = '/login'; |
| | | /** |
| | | * @summary description |
| | | */ |
| | | export const PostLogin = async (params, req: any = request) => { |
| | | return req({ |
| | | url: '/login', |
| | | url: LOGIN_URL, |
| | | method: 'POST', |
| | | data: params, |
| | | headers: { |
| | | headers: { |
| | | 'Content-Type': 'application/x-www-form-urlencoded', |
| | | }, |
| | | }); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * @summary description |
| | | */ |
| | | export const PostLogout = async ( req:any = request) => { |
| | | return req({ |
| | | url: "/logout", |
| | | method: "POST", |
| | | }); |
| | | export const PostLogout = async (req: any = request) => { |
| | | return req({ |
| | | url: '/logout', |
| | | method: 'POST', |
| | | }); |
| | | }; |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <Loding v-else class="w-12" :process="process" /> |
| | | <Loding v-else class="w-fit" :process="process" /> |
| | | </div> |
| | | </div> |
| | | <div v-if="showAskMore" class="ml-4 mt-5 text-sm"> |
| | |
| | | |
| | | const getSystemNotify = async () => { |
| | | const res = await systemNotifyList(); |
| | | res.messages.forEach((element) => { |
| | | res.messages?.forEach((element) => { |
| | | element.notify_time = element.notify_time.slice(0, 10); |
| | | }); |
| | | state.announcementList = res.messages.sort(sortData).slice(0, 5); |
| | | state.announcementList = res.messages?.sort(sortData).slice(0, 5) ??[]; |
| | | }; |
| | | const routerMeta = computed(() => router.currentRoute.value.meta); |
| | | const handleAnnouncementClick = () => { |
| | |
| | | import { debounce } from './util'; |
| | | import { AUTH_URL, MAIN_URL, SECONDARY_URL } from '/@/constants'; |
| | | import { Local, LoginInfo, Session } from '/@/utils/storage'; |
| | | import { LOGIN_URL } from '../api/ai/user'; |
| | | import { NO_AUTH_API_LIST } from '../api/ai/chat'; |
| | | // import JSONbig from 'json-bigint'; |
| | | |
| | | //#region ====================== 后端 res.err_code ====================== |
| | |
| | | } |
| | | //#endregion |
| | | |
| | | const handleNoAuth = debounce(() => { |
| | | const emitNoAuth = () => { |
| | | emitter.emit('logout'); |
| | | emitter.emit('openLoginDlg'); |
| | | }; |
| | | |
| | | export const handleNormalAuth = () => { |
| | | const accessSession = Local.get(accessSessionKey); |
| | | if (!accessSession) { |
| | | emitter.emit('logout'); |
| | | emitter.emit('openLoginDlg'); |
| | | } |
| | | return !!accessSession; |
| | | }; |
| | | |
| | | const handleNoAuth = debounce(() => { |
| | | emitNoAuth(); |
| | | }); |
| | | const loginUrl = '/login'; |
| | | const initRequestInterceptor = (request: AxiosInstance) => { |
| | | // 添加请求拦截器 |
| | | request.interceptors.request.use( |
| | | (config) => { |
| | | // 获取本地的 token |
| | | const accessSession = Local.get(accessSessionKey); |
| | | |
| | | if (accessSession) { |
| | | // 将 token 添加到请求报文头中 |
| | | config.headers['hswatersession'] = accessSession; |
| | | } else { |
| | | if (config.url !== loginUrl) { |
| | | handleNoAuth(config.url); |
| | | |
| | | throw '权限验证失败'; |
| | | if (!NO_AUTH_API_LIST.includes(config.url)) { |
| | | if (accessSession) { |
| | | // 将 token 添加到请求报文头中 |
| | | config.headers['hswatersession'] = accessSession; |
| | | } else { |
| | | if (config.url !== LOGIN_URL) { |
| | | handleNoAuth(config.url); |
| | | throw '权限验证失败'; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return config; |
| | | }, |
| | | (error) => { |
| | |
| | | if (!serveData.json_ok) { |
| | | switch (serveData?.err_code) { |
| | | case ErrorCode.Auth: |
| | | if (res.config.url !== loginUrl) { |
| | | if (res.config.url !== LOGIN_URL) { |
| | | handleNoAuth(); |
| | | throw '权限验证失败'; |
| | | } |
| | |
| | | return res.data; |
| | | }, |
| | | (error) => { |
| | | if (typeof error === 'string') { |
| | | // ElMessage.error(error); |
| | | return Promise.reject(error); |
| | | } |
| | | // 处理响应错误 |
| | | if (error.response) { |
| | | if (error.response.status === 401) { |
| | |
| | | <div class="flex items-center flex-column mt-20"> |
| | | <div class="flex items-center flex-column"> |
| | | <waterTop /> |
| | | <div v-if="isLoginStatus"> |
| | | <waterCenter /> |
| | | <waterBottom /> |
| | | </div> |
| | | <div v-else> |
| | | <el-empty></el-empty> |
| | | </div> |
| | | <waterCenter /> |
| | | <waterBottom /> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { ref } from 'vue'; |
| | | import waterBottom from './component/waterRight/bottom.vue'; |
| | | import waterCenter from './component/waterRight/center.vue'; |
| | | import waterTop from './component/waterRight/top.vue'; |
| | | import { accessSessionKey } from '/@/utils/request'; |
| | | import { Local } from '/@/utils/storage'; |
| | | const isLoginStatus = ref(!!Local.get(accessSessionKey)); |
| | | </script> |
| | | <style scoped lang="scss"> |
| | | .pc-chat_room { |
| | |
| | | import router from '/@/router'; |
| | | import { activeChatRoom, activeLLMId, activeSectionAId } from '/@/stores/chatRoom'; |
| | | import emitter from '/@/utils/mitt'; |
| | | import { handleNormalAuth } from '/@/utils/request'; |
| | | const emits = defineEmits(['sendClick']); |
| | | const inputValue = ref('你是谁?'); |
| | | |
| | |
| | | ElMessage.warning('请选择应用场景'); |
| | | return; |
| | | } |
| | | if (!handleNormalAuth()) { |
| | | return; |
| | | } |
| | | |
| | | const res = await setHistoryGroupTitle({ |
| | | history_group_id: activeChatRoom.value.id, |