yangyin
2024-07-18 73a914bb2aabd63533e0954eaaad7b00c743ac4b
Merge branch 'master' of http://47.103.154.90:83/r/WI/Web.V1.0
已修改7个文件
101 ■■■■■ 文件已修改
src/api/ai/chat.ts 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/ai/user.ts 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chat/Chat.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/component/header/Header.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.ts 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/ch/home/Home.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/ch/home/component/waterRight/top.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/ai/chat.ts
@@ -1,5 +1,8 @@
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 ======================
@@ -108,7 +111,7 @@
 */
export const getSectionList = async (req: any = request) => {
    return req({
        url: '/section/get_section_a_list',
        url: GET_SECTION_A_LIST_API,
        method: 'POST',
    });
};
@@ -183,7 +186,7 @@
// 获取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: {
@@ -269,9 +272,9 @@
/**
 * 查询问题进度
 * @param params
 * @param req
 * @returns
 * @param params
 * @param req
 * @returns
 */
export const getQuestionProcess = async (params, req: any = request) => {
    return req({
@@ -294,4 +297,3 @@
        },
    });
};
src/api/ai/user.ts
@@ -1,31 +1,26 @@
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',
    });
};
src/components/chat/Chat.vue
@@ -50,7 +50,7 @@
                            </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">
src/layout/component/header/Header.vue
@@ -70,10 +70,10 @@
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 = () => {
src/utils/request.ts
@@ -5,6 +5,8 @@
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 ======================
@@ -18,28 +20,41 @@
}
//#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) => {
@@ -73,7 +88,7 @@
            if (!serveData.json_ok) {
                switch (serveData?.err_code) {
                    case ErrorCode.Auth:
                        if (res.config.url !== loginUrl) {
                        if (res.config.url !== LOGIN_URL) {
                            handleNoAuth();
                            throw '权限验证失败';
                        }
@@ -87,6 +102,10 @@
            return res.data;
        },
        (error) => {
            if (typeof error === 'string') {
                // ElMessage.error(error);
                return Promise.reject(error);
            }
            // 处理响应错误
            if (error.response) {
                if (error.response.status === 401) {
src/views/project/ch/home/Home.vue
@@ -8,13 +8,8 @@
                            <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>
@@ -31,13 +26,9 @@
</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 {
src/views/project/ch/home/component/waterRight/top.vue
@@ -28,6 +28,7 @@
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('你是谁?');
@@ -37,6 +38,9 @@
        ElMessage.warning('请选择应用场景');
        return;
    }
    if (!handleNormalAuth()) {
        return;
    }
    const res = await setHistoryGroupTitle({
        history_group_id: activeChatRoom.value.id,