From b308f037bb6f1365c51b367ed4db5f8372febc90 Mon Sep 17 00:00:00 2001
From: liudong <liudong>
Date: 星期五, 26 七月 2024 19:09:42 +0800
Subject: [PATCH] 知识库页面接口调用开发
---
.env.development | 2
src/api/kbList.ts | 49 ++++++++++++++++
config/vite.config.dev.ts | 5 +
src/api/interceptor.ts | 2
src/router/guard/userLoginInfo.ts | 63 ++++++++++----------
src/views/dmx/knowledgeLib/index.vue | 53 +++++++++++++----
6 files changed, 127 insertions(+), 47 deletions(-)
diff --git a/.env.development b/.env.development
index e3d81eb..4e6eb7f 100644
--- a/.env.development
+++ b/.env.development
@@ -1,2 +1,2 @@
VUE_APP_BASE_API=/api
-VITE_API_BASE_URL= 'http://192.168.20.116:1080'
\ No newline at end of file
+VITE_API_BASE_URL= 'http://aiotlink.com:8189'
\ No newline at end of file
diff --git a/config/vite.config.dev.ts b/config/vite.config.dev.ts
index 6032b64..8c7a59d 100644
--- a/config/vite.config.dev.ts
+++ b/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`), ''),
diff --git a/src/api/interceptor.ts b/src/api/interceptor.ts
index 416e246..000000d 100644
--- a/src/api/interceptor.ts
+++ b/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) => {
diff --git a/src/api/kbList.ts b/src/api/kbList.ts
new file mode 100644
index 0000000..7e5fbe1
--- /dev/null
+++ b/src/api/kbList.ts
@@ -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
+ });
+}
\ No newline at end of file
diff --git a/src/router/guard/userLoginInfo.ts b/src/router/guard/userLoginInfo.ts
index 7a06895..876976d 100644
--- a/src/router/guard/userLoginInfo.ts
+++ b/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,
- });
- }
+ next();
+ // 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,
+ // });
+ // }
});
}
diff --git a/src/views/dmx/knowledgeLib/index.vue b/src/views/dmx/knowledgeLib/index.vue
index 7531a6f..e079595 100644
--- a/src/views/dmx/knowledgeLib/index.vue
+++ b/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">
--
Gitblit v1.8.0