Browse Source

feat: 客户端知识库添加阅读量

master
AaronWu 1 month ago
parent
commit
0e0ce18dc8
  1. 4
      .env.development
  2. 11
      src/api/knowledgeBase/index.ts
  3. 1
      src/api/login/model.d.ts
  4. 13
      src/views/client/knowledgeBase/index.vue
  5. 1
      src/views/login/index.vue
  6. 22
      src/views/question/issue/detail.vue
  7. 2
      src/views/system/user/formSchemas.ts

4
.env.development

@ -9,8 +9,8 @@
# 只在开发模式中被载入 # 只在开发模式中被载入
# 网站前缀 # 网站前缀
# VITE_BASE_API_URL = http://192.168.2.217:8089/server/
VITE_BASE_API_URL = http://43.137.2.78:8085/server/
VITE_BASE_API_URL = http://192.168.2.33:8089/server/
# VITE_BASE_API_URL = http://43.137.2.78:8085/server/
# base api # base api
VITE_BASE_API = '/server/' VITE_BASE_API = '/server/'

11
src/api/knowledgeBase/index.ts

@ -76,6 +76,17 @@ export function findOneById(params: { id: string }) {
}); });
} }
/**
* @description
*/
export function addReadCount(params: { id: string }) {
return request({
url: `knowledge/readAdd`,
method: 'get',
params,
});
}
/** /**
* @description ?id=${data.id} * @description ?id=${data.id}
*/ */

1
src/api/login/model.d.ts

@ -36,6 +36,7 @@ declare namespace API {
username: string; username: string;
password: string; password: string;
account: string; account: string;
sex?: number;
}; };
/** 登录成功结果 */ /** 登录成功结果 */

13
src/views/client/knowledgeBase/index.vue

@ -43,7 +43,9 @@
<div class="meta-info"> <div class="meta-info">
<span class="date">更新时间{{ curRowDetail.createTime }}</span> <span class="date">更新时间{{ curRowDetail.createTime }}</span>
<span class="divider">|</span> <span class="divider">|</span>
<span class="views" v-if="isAdmin === 1">阅读123</span>
<span class="views" v-if="isAdmin === 1"
>阅读{{ curRowDetail.readCount }}</span
>
</div> </div>
</div> </div>
<div class="tags"> <div class="tags">
@ -83,7 +85,7 @@
ExportOutlined, ExportOutlined,
LeftOutlined, LeftOutlined,
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import { fetchKnowledgeBaseList, findOneById } from '@/api/knowledgeBase';
import { fetchKnowledgeBaseList, findOneById, addReadCount } from '@/api/knowledgeBase';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useUserStore } from '@/store/modules/user'; import { useUserStore } from '@/store/modules/user';
@ -105,11 +107,13 @@
tags: string; tags: string;
solution: string; solution: string;
createTime: string; createTime: string;
readCount: any;
}>({ }>({
title: '', title: '',
tags: '', tags: '',
solution: '', solution: '',
createTime: '', createTime: '',
readCount: 0,
}); });
const goBack = () => { const goBack = () => {
@ -122,6 +126,11 @@
try { try {
const res = await findOneById({ id: newVal[0] }); const res = await findOneById({ id: newVal[0] });
curRowDetail.value = res; curRowDetail.value = res;
const count = await addReadCount({ id: newVal[0] });
console.log('count: ', count);
if (count) {
curRowDetail.value.readCount = count;
}
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} finally { } finally {

1
src/views/login/index.vue

@ -145,6 +145,7 @@
await register({ await register({
...state.formInline, ...state.formInline,
account: state.formInline.username, account: state.formInline.username,
sex: 1,
}); });
message.success('注册成功,请联系系统管理员通过审核'); message.success('注册成功,请联系系统管理员通过审核');
setTimeout(() => { setTimeout(() => {

22
src/views/question/issue/detail.vue

@ -83,6 +83,7 @@
import { findOneById } from '@/api/issue'; import { findOneById } from '@/api/issue';
import { SvgIcon } from '@/components/basic/svg-icon'; import { SvgIcon } from '@/components/basic/svg-icon';
import { stateTypeList } from './data'; import { stateTypeList } from './data';
import { fetchVersionPageList } from '@/api/prodVersion';
const props = defineProps({ const props = defineProps({
id: { id: {
@ -160,6 +161,27 @@
}); });
} }
if (res?.productId) {
const { data } = await fetchVersionPageList({
productId: res?.productId,
current: 1,
size: 999,
});
if (data && Array.isArray(data) && data.length) {
formRef?.updateSchema({
field: 'versionId',
componentProps: {
options: data.map((e) => {
return {
label: e.name,
value: e.id,
};
}),
},
});
}
}
current.value = res?.state; current.value = res?.state;
formRef?.setFieldsValue(res); formRef?.setFieldsValue(res);

2
src/views/system/user/formSchemas.ts

@ -64,7 +64,7 @@ export const userSchemas: FormSchema<API.CreateUserParams>[] = [
}, },
rules: [ rules: [
{ {
required: true,
required: false,
message: '请输入正确格式的电话号码', message: '请输入正确格式的电话号码',
pattern: /^1(3[0-9]|4[01456879]|5[0-3,5-9]|6[2567]|7[0-8]|8[0-9]|9[0-3,5-9])\d{8}$/, pattern: /^1(3[0-9]|4[01456879]|5[0-3,5-9]|6[2567]|7[0-8]|8[0-9]|9[0-3,5-9])\d{8}$/,
}, },

Loading…
Cancel
Save