.env.development | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
config/vite.config.dev.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/api/interceptor.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/api/kbList.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/router/guard/userLoginInfo.ts | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/dmx/knowledgeLib/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
.env.development
@@ -1,2 +1,2 @@ VUE_APP_BASE_API=/api VITE_API_BASE_URL= 'http://192.168.20.116:1080' VITE_API_BASE_URL= 'http://aiotlink.com:8189' config/vite.config.dev.ts
@@ -20,8 +20,9 @@ // only https // secure: false }, '/v1': { target: 'http://192.168.20.116:1080/', '/api/v1': { // target: 'http://192.168.20.116:1080/', target: 'http://aiotlink.com:8189', changeOrigin: true, ws: true, // rewrite: (path) => path.replace(new RegExp(`^/upload`), ''), src/api/interceptor.ts
@@ -38,6 +38,8 @@ config.headers.Authorization = authorization; config.headers.token = getToken(); } config.headers.Authorization = 'Ijg3NmFjZjJlNGIzMzExZWY4NzI0MDI0MmFjMTIwMDA2Ig.ZqNvxw.Kgp8PcT4n2cxpzxFrYHttO4i2Eo'; return config; }, (error) => { src/api/kbList.ts
New file @@ -0,0 +1,49 @@ import axios from 'axios'; import qs from 'query-string'; import type { DescData } from '@arco-design/web-vue/es/descriptions/interface'; export interface PolicyRecord { id: string; number: number; name: string; contentType: 'img' | 'horizontalVideo' | 'verticalVideo'; filterType: 'artificial' | 'rules'; count: number; status: 'online' | 'offline'; createdTime: string; } export interface PolicyParams extends Partial<PolicyRecord> { current: number; pageSize: number; } export interface PolicyListRes { list: PolicyRecord[]; total: number; } export function queryKbList(params) { return axios.get('/api/v1/kb/list', { params }); } export function queryKbdetail(params) { return axios.get('/api/v1/kb/detail', { params }); } export function queryKbtenantInfo(params) { return axios.get('/api/v1/user/tenant_info', { params }); } export function queryKbDocumentList(params) { return axios.get('/api/v1/document/list', { params }); } src/router/guard/userLoginInfo.ts
@@ -8,36 +8,37 @@ router.beforeEach(async (to, from, next) => { NProgress.start(); const userStore = useUserStore(); if (isLogin()) { if (userStore.role) { next(); } else { try { await userStore.info(); next(); } catch (error) { await userStore.logout(); next({ name: 'login', query: { redirect: to.name, ...to.query, } as LocationQueryRaw, }); } } } else { if (to.name === 'login') { next(); return; } next({ name: 'login', query: { redirect: to.name, ...to.query, } as LocationQueryRaw, }); } // if (isLogin()) { // if (userStore.role) { // next(); // } else { // try { // await userStore.info(); // next(); // } catch (error) { // await userStore.logout(); // next({ // name: 'login', // query: { // redirect: to.name, // ...to.query, // } as LocationQueryRaw, // }); // } // } // } else { // if (to.name === 'login') { // next(); // return; // } // next({ // name: 'login', // query: { // redirect: to.name, // ...to.query, // } as LocationQueryRaw, // }); // } }); } src/views/dmx/knowledgeLib/index.vue
@@ -16,10 +16,10 @@ class="tab" v-for="(tab, index) in tabs" :key="index" @click="selectTab(index)" @click="selectTab(index,tab)" :class="{ 'active': selectedTab === index }" > {{ tab }} {{ tab.name }} </div> </div> </div> @@ -271,10 +271,10 @@ </template> <script lang="ts" setup> import { computed, ref, reactive, watch, nextTick } from 'vue'; import { computed, ref, reactive, watch, nextTick, onBeforeMount } from "vue"; import { useI18n } from 'vue-i18n'; import useLoading from '@/hooks/loading'; import { queryPolicyList, PolicyRecord, PolicyParams } from '@/api/list'; import { queryKbList, PolicyRecord, PolicyParams } from '@/api/kbList'; import { Pagination } from '@/types/global'; import type { SelectOptionData } from '@arco-design/web-vue/es/select/interface'; import type { TableColumnData } from '@arco-design/web-vue/es/table/interface'; @@ -312,10 +312,11 @@ let visible = ref(false) let detailsShow = ref(false) let selectedTab = ref(0) let tabs = reactive(['法律知识库', '政务知识库', '医学知识库', '其他知识库']) let tabs = ref([]) const selectTab = (index) => { const selectTab = (index,item) => { selectedTab.value= index; console.log(item.id); } const basePagination: Pagination = { @@ -418,15 +419,16 @@ }, ]); const fetchData = async ( params: PolicyParams = { current: 1, pageSize: 20 } params = { page: 1, page_size: 20 } ) => { setLoading(true); try { const { data } = await queryPolicyList(params); renderData.value = data.list; console.log(renderData, 'renderData'); pagination.current = params.current; pagination.total = data.total; const { data } = await queryKbList(params); console.log(data, 'data'); // renderData.value = data.list; // console.log(renderData, 'renderData'); // pagination.current = params.current; // pagination.total = data.total; } catch (err) { // you can report use errorHandler or other } finally { @@ -449,7 +451,27 @@ fetchData({ ...basePagination, current }); }; fetchData(); const knowledgeData = async ( params = { page: 1, page_size: 20 } ) => { setLoading(true); try { const { data } = await queryKbList(params); console.log(data, 'data'); tabs.value = data; console.log(tabs.value, 'tabs'); // fetchData() // renderData.value = data.list; // console.log(renderData, 'renderData'); // pagination.current = params.current; // pagination.total = data.total; } catch (err) { // you can report use errorHandler or other } finally { setLoading(false); } }; const reset = () => { formModel.value = generateFormModel(); }; @@ -540,6 +562,11 @@ }, { deep: true, immediate: true } ); onBeforeMount(()=>{ knowledgeData() }) </script> <script lang="ts">