Files
ragflow_python/web/src/pages/add-knowledge/components/knowledge-setting/model.ts

55 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-01-17 09:37:01 +08:00
import kbService from '@/services/kbService';
import { message } from 'antd';
import { DvaModel } from 'umi';
2024-01-17 09:37:01 +08:00
export interface KSModelState {
isShowPSwModal: boolean;
isShowTntModal: boolean;
tenantIfo: any;
}
const model: DvaModel<KSModelState> = {
2024-01-17 09:37:01 +08:00
namespace: 'kSModel',
state: {
isShowPSwModal: false,
isShowTntModal: false,
tenantIfo: {},
},
reducers: {
updateState(state, { payload }) {
return {
...state,
...payload,
};
},
2024-01-17 09:37:01 +08:00
},
subscriptions: {
setup({ dispatch, history }) {
history.listen((location) => {});
},
2024-01-17 09:37:01 +08:00
},
effects: {
*createKb({ payload = {} }, { call, put }) {
const { data } = yield call(kbService.createKb, payload);
const { retcode } = data;
2024-01-17 09:37:01 +08:00
if (retcode === 0) {
message.success('创建知识库成功!');
}
return retcode;
2024-01-17 09:37:01 +08:00
},
*updateKb({ payload = {} }, { call, put }) {
const { data } = yield call(kbService.updateKb, payload);
const { retcode, data: res, retmsg } = data;
2024-01-17 09:37:01 +08:00
if (retcode === 0) {
message.success('更新知识库成功!');
}
},
*getKbDetail({ payload = {} }, { call, put }) {
const { data } = yield call(kbService.get_kb_detail, payload);
return data;
2024-01-17 09:37:01 +08:00
},
},
};
export default model;