mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-29 04:14:20 +08:00
Merge branch 'tencentmusic:master' into master
This commit is contained in:
@@ -31,7 +31,7 @@ public class ChatConfigBase {
|
|||||||
/**
|
/**
|
||||||
* information about dictionary about the domain
|
* information about dictionary about the domain
|
||||||
*/
|
*/
|
||||||
private List<KnowledgeInfo> dictionaryInfos;
|
private List<KnowledgeInfo> knowledgeInfos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* available status
|
* available status
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class ChatConfigInfo {
|
|||||||
/**
|
/**
|
||||||
* information about dictionary about the domain
|
* information about dictionary about the domain
|
||||||
*/
|
*/
|
||||||
private List<KnowledgeInfo> dictionaryInfos;
|
private List<KnowledgeInfo> knowledgeInfos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* available status
|
* available status
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class ChatConfigRichInfo {
|
|||||||
/**
|
/**
|
||||||
* information about dictionary about the domain
|
* information about dictionary about the domain
|
||||||
*/
|
*/
|
||||||
private List<KnowledgeInfo> dictionaryInfos;
|
private List<KnowledgeInfo> knowledgeInfos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* available status
|
* available status
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class ChatConfigUtils {
|
|||||||
JsonUtil.toList(chaConfigDO.getDefaultMetrics(), DefaultMetricInfo.class));
|
JsonUtil.toList(chaConfigDO.getDefaultMetrics(), DefaultMetricInfo.class));
|
||||||
chaConfigDescriptor.setVisibility(JsonUtil.toObject(chaConfigDO.getVisibility(), ItemVisibility.class));
|
chaConfigDescriptor.setVisibility(JsonUtil.toObject(chaConfigDO.getVisibility(), ItemVisibility.class));
|
||||||
chaConfigDescriptor.setEntity(JsonUtil.toObject(chaConfigDO.getEntity(), Entity.class));
|
chaConfigDescriptor.setEntity(JsonUtil.toObject(chaConfigDO.getEntity(), Entity.class));
|
||||||
chaConfigDescriptor.setDictionaryInfos(JsonUtil.toList(chaConfigDO.getKnowledgeInfo(), KnowledgeInfo.class));
|
chaConfigDescriptor.setKnowledgeInfos(JsonUtil.toList(chaConfigDO.getKnowledgeInfo(), KnowledgeInfo.class));
|
||||||
chaConfigDescriptor.setStatusEnum(StatusEnum.of(chaConfigDO.getStatus()));
|
chaConfigDescriptor.setStatusEnum(StatusEnum.of(chaConfigDO.getStatus()));
|
||||||
|
|
||||||
chaConfigDescriptor.setCreatedBy(chaConfigDO.getCreatedBy());
|
chaConfigDescriptor.setCreatedBy(chaConfigDO.getCreatedBy());
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.tencent.supersonic.chat.domain.pojo.config.ItemVisibilityInfo;
|
|||||||
import com.tencent.supersonic.chat.domain.pojo.config.KnowledgeInfo;
|
import com.tencent.supersonic.chat.domain.pojo.config.KnowledgeInfo;
|
||||||
import com.tencent.supersonic.knowledge.domain.pojo.DictUpdateMode;
|
import com.tencent.supersonic.knowledge.domain.pojo.DictUpdateMode;
|
||||||
import com.tencent.supersonic.knowledge.domain.pojo.DimValue2DictCommand;
|
import com.tencent.supersonic.knowledge.domain.pojo.DimValue2DictCommand;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -22,6 +23,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -37,7 +39,7 @@ public class DictMetaUtils {
|
|||||||
private final DefaultSemanticInternalUtils defaultSemanticUtils;
|
private final DefaultSemanticInternalUtils defaultSemanticUtils;
|
||||||
|
|
||||||
public DictMetaUtils(SemanticLayer semanticLayer,
|
public DictMetaUtils(SemanticLayer semanticLayer,
|
||||||
DefaultSemanticInternalUtils defaultSemanticUtils) {
|
DefaultSemanticInternalUtils defaultSemanticUtils) {
|
||||||
this.semanticLayer = semanticLayer;
|
this.semanticLayer = semanticLayer;
|
||||||
this.defaultSemanticUtils = defaultSemanticUtils;
|
this.defaultSemanticUtils = defaultSemanticUtils;
|
||||||
}
|
}
|
||||||
@@ -129,21 +131,21 @@ public class DictMetaUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void fillDimValueDOList(List<DimValueDO> dimValueDOList, Long domainId,
|
private void fillDimValueDOList(List<DimValueDO> dimValueDOList, Long domainId,
|
||||||
Map<Long, DimSchemaResp> dimIdAndDescPair) {
|
Map<Long, DimSchemaResp> dimIdAndDescPair) {
|
||||||
ChatConfigRichInfo chaConfigRichDesc = defaultSemanticUtils.getChatConfigRichInfo(domainId);
|
ChatConfigRichInfo chaConfigRichDesc = defaultSemanticUtils.getChatConfigRichInfo(domainId);
|
||||||
if (Objects.nonNull(chaConfigRichDesc)) {
|
if (Objects.nonNull(chaConfigRichDesc)) {
|
||||||
|
|
||||||
List<DefaultMetric> defaultMetricDescList = chaConfigRichDesc.getDefaultMetrics();
|
List<DefaultMetric> defaultMetricDescList = chaConfigRichDesc.getDefaultMetrics();
|
||||||
|
|
||||||
List<KnowledgeInfo> dictionaryInfos = chaConfigRichDesc.getDictionaryInfos();
|
List<KnowledgeInfo> knowledgeInfos = chaConfigRichDesc.getKnowledgeInfos();
|
||||||
if (!CollectionUtils.isEmpty(dictionaryInfos)) {
|
if (!CollectionUtils.isEmpty(knowledgeInfos)) {
|
||||||
List<Dim4Dict> dimensions = new ArrayList<>();
|
List<Dim4Dict> dimensions = new ArrayList<>();
|
||||||
dictionaryInfos.stream()
|
knowledgeInfos.stream()
|
||||||
.filter(dictionaryInfo -> dictionaryInfo.getIsDictInfo()
|
.filter(knowledgeInfo -> knowledgeInfo.getIsDictInfo()
|
||||||
&& isVisibleDim(dictionaryInfo, chaConfigRichDesc.getVisibility()))
|
&& isVisibleDim(knowledgeInfo, chaConfigRichDesc.getVisibility()))
|
||||||
.forEach(dictionaryInfo -> {
|
.forEach(knowledgeInfo -> {
|
||||||
if (dimIdAndDescPair.containsKey(dictionaryInfo.getItemId())) {
|
if (dimIdAndDescPair.containsKey(knowledgeInfo.getItemId())) {
|
||||||
DimSchemaResp dimensionDesc = dimIdAndDescPair.get(dictionaryInfo.getItemId());
|
DimSchemaResp dimensionDesc = dimIdAndDescPair.get(knowledgeInfo.getItemId());
|
||||||
|
|
||||||
//default cnt
|
//default cnt
|
||||||
if (CollectionUtils.isEmpty(defaultMetricDescList)) {
|
if (CollectionUtils.isEmpty(defaultMetricDescList)) {
|
||||||
@@ -156,9 +158,9 @@ public class DictMetaUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String bizName = dimensionDesc.getBizName();
|
String bizName = dimensionDesc.getBizName();
|
||||||
dimensions.add(new Dim4Dict(dictionaryInfo.getItemId(), bizName,
|
dimensions.add(new Dim4Dict(knowledgeInfo.getItemId(), bizName,
|
||||||
dictionaryInfo.getBlackList(), dictionaryInfo.getWhiteList(),
|
knowledgeInfo.getBlackList(), knowledgeInfo.getWhiteList(),
|
||||||
dictionaryInfo.getRuleList()));
|
knowledgeInfo.getRuleList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -173,10 +175,10 @@ public class DictMetaUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVisibleDim(KnowledgeInfo dictionaryInfo, ItemVisibilityInfo itemVisibilityDesc) {
|
private boolean isVisibleDim(KnowledgeInfo knowledgeInfo, ItemVisibilityInfo itemVisibilityDesc) {
|
||||||
if (Objects.isNull(itemVisibilityDesc) || CollectionUtils.isEmpty(itemVisibilityDesc.getBlackDimIdList())) {
|
if (Objects.isNull(itemVisibilityDesc) || CollectionUtils.isEmpty(itemVisibilityDesc.getBlackDimIdList())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return !itemVisibilityDesc.getBlackDimIdList().contains(dictionaryInfo.getItemId());
|
return !itemVisibilityDesc.getBlackDimIdList().contains(knowledgeInfo.getItemId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ insert into s2_user (id, `name`, password, display_name, email) values (2, 'jack
|
|||||||
insert into s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com');
|
insert into s2_user (id, `name`, password, display_name, email) values (3, 'tom','123456','tom','tom@xx.com');
|
||||||
insert into s2_user (id, `name`, password, display_name, email) values (4, 'lucy','123456','lucy','lucy@xx.com');
|
insert into s2_user (id, `name`, password, display_name, email) values (4, 'lucy','123456','lucy','lucy@xx.com');
|
||||||
|
|
||||||
insert into s2_chat_config (`id` ,`domain_id` ,`default_metrics`,`visibility`,`entity_info` ,`dictionary_info`,`created_at`,`updated_at`,`created_by`,`updated_by`,`status` ) values (1,1,'[{"metricId":1,"unit":7,"period":"DAY"}]','{"blackDimIdList":[],"blackMetricIdList":[]}','{"entityIds":[2],"names":["用户","用户姓名"],"detailData":{"dimensionIds":[1,2],"metricIds":[2]}}','[{"itemId":1,"type":"DIMENSION","blackList":[],"isDictInfo":true},{"itemId":2,"type":"DIMENSION","blackList":[],"isDictInfo":true},{"itemId":3,"type":"DIMENSION","blackList":[],"isDictInfo":true}]','2023-05-24 18:00:00','2023-05-25 11:00:00','admin','admin',1);
|
|
||||||
insert into s2_chat_config (id, domain_id, default_metrics, visibility, entity_info, dictionary_info, created_at, updated_at, created_by, updated_by, status) values (2, 1, '[{"metricId":1,"unit":7,"period":"DAY"}]','{"blackDimIdList":[],"blackMetricIdList":[]}','{"entityIds":[2],"names":["用户","用户姓名"],"detailData":{"dimensionIds":[1,2],"metricIds":[2]}}','[{"itemId":1,"type":"DIMENSION","blackList":[],"isDictInfo":true},{"itemId":2,"type":"DIMENSION","blackList":[],"isDictInfo":true},{"itemId":3,"type":"DIMENSION","blackList":[],"isDictInfo":true}]','2023-05-24 18:00:00', '2023-05-25 11:00:00', 'admin', 'admin', 1 );
|
insert into s2_chat_config (id, domain_id, default_metrics, visibility, entity_info, dictionary_info, created_at, updated_at, created_by, updated_by, status) values (2, 1, '[{"metricId":1,"unit":7,"period":"DAY"}]','{"blackDimIdList":[],"blackMetricIdList":[]}','{"entityIds":[2],"names":["用户","用户姓名"],"detailData":{"dimensionIds":[1,2],"metricIds":[2]}}','[{"itemId":1,"type":"DIMENSION","blackList":[],"isDictInfo":true},{"itemId":2,"type":"DIMENSION","blackList":[],"isDictInfo":true},{"itemId":3,"type":"DIMENSION","blackList":[],"isDictInfo":true}]','2023-05-24 18:00:00', '2023-05-25 11:00:00', 'admin', 'admin', 1 );
|
||||||
|
|
||||||
insert into s2_chat (chat_id, `chat_name`, create_time, last_time, creator,last_question,is_delete,is_top) values (1, '超音数访问统计','2023-06-10 10:00:52.495','2023-06-10 10:00:52','admin','您好,欢迎使用内容智能小Q','0','0');
|
insert into s2_chat (chat_id, `chat_name`, create_time, last_time, creator,last_question,is_delete,is_top) values (1, '超音数访问统计','2023-06-10 10:00:52.495','2023-06-10 10:00:52','admin','您好,欢迎使用内容智能小Q','0','0');
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ant-design/charts": "^1.3.3",
|
"@ant-design/charts": "^1.3.3",
|
||||||
|
"@ant-design/cssinjs": "^1.10.1",
|
||||||
"@ant-design/icons": "^4.7.0",
|
"@ant-design/icons": "^4.7.0",
|
||||||
"@ant-design/pro-card": "^1.11.13",
|
"@ant-design/pro-card": "^1.11.13",
|
||||||
"@ant-design/pro-components": "^2.4.4",
|
"@ant-design/pro-components": "^2.4.4",
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ const getToken = async () => {
|
|||||||
try {
|
try {
|
||||||
const fromUrl = localStorage.getItem(FROM_URL_KEY);
|
const fromUrl = localStorage.getItem(FROM_URL_KEY);
|
||||||
const res = await queryToken(data.code as string);
|
const res = await queryToken(data.code as string);
|
||||||
localStorage.setItem(TOKEN_KEY, res.data.authToken);
|
localStorage.setItem(TOKEN_KEY, res.payload);
|
||||||
const newUrl = deleteUrlQuery(window.location.href, 'code');
|
const newUrl = deleteUrlQuery(window.location.href, 'code');
|
||||||
window.location.href = fromUrl || newUrl;
|
window.location.href = fromUrl || newUrl;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// 登陆 token key
|
// 登陆 token key
|
||||||
export const AUTH_TOKEN_KEY = 'SUPERSONIC_TOKEN';
|
export const AUTH_TOKEN_KEY = process.env.APP_TARGET === 'inner' ? 'TME_TOKEN' : 'SUPERSONIC_TOKEN';
|
||||||
|
|
||||||
// 记录上次访问页面
|
// 记录上次访问页面
|
||||||
export const FROM_URL_KEY = 'FROM_URL';
|
export const FROM_URL_KEY = 'FROM_URL';
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,12 @@ const SelectTMEPerson: FC<Props> = ({ placeholder, value, isMultiple = true, onC
|
|||||||
{
|
{
|
||||||
fetcher: async () => {
|
fetcher: async () => {
|
||||||
const res = await getAllUser();
|
const res = await getAllUser();
|
||||||
if (res.code !== 200) {
|
if (res.code == 200 || Number(res.code) == 0) {
|
||||||
|
return res.data || [];
|
||||||
|
} else {
|
||||||
message.error(res.msg);
|
message.error(res.msg);
|
||||||
throw new Error(res.msg);
|
throw new Error(res.msg);
|
||||||
}
|
}
|
||||||
return res.data || [];
|
|
||||||
},
|
},
|
||||||
updater: (list) => {
|
updater: (list) => {
|
||||||
const users = list.map((item: UserItem) => {
|
const users = list.map((item: UserItem) => {
|
||||||
|
|||||||
@@ -17,15 +17,17 @@ const Context: React.FC<Props> = ({ chatContext }) => {
|
|||||||
<span className={styles.fieldName}>主题域:</span>
|
<span className={styles.fieldName}>主题域:</span>
|
||||||
<span className={styles.fieldValue}>{domainName}</span>
|
<span className={styles.fieldValue}>{domainName}</span>
|
||||||
</div>
|
</div>
|
||||||
{dateInfo && (
|
{
|
||||||
<div className={styles.field}>
|
dateInfo && (
|
||||||
<span className={styles.fieldName}>时间范围:</span>
|
<div className={styles.field}>
|
||||||
<span className={styles.fieldValue}>
|
<span className={styles.fieldName}>时间范围:</span>
|
||||||
{dateInfo.text ||
|
<span className={styles.fieldValue}>
|
||||||
`近${moment(dateInfo.endDate).diff(moment(dateInfo.startDate), 'days') + 1}天`}
|
{dateInfo.text ||
|
||||||
</span>
|
`近${moment(dateInfo.endDate).diff(moment(dateInfo.startDate), 'days') + 1}天`}
|
||||||
</div>
|
</span>
|
||||||
)}
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
{metrics && metrics.length > 0 && (
|
{metrics && metrics.length > 0 && (
|
||||||
<div className={styles.field}>
|
<div className={styles.field}>
|
||||||
<span className={styles.fieldName}>指标:</span>
|
<span className={styles.fieldName}>指标:</span>
|
||||||
|
|||||||
@@ -11,9 +11,14 @@ import RightSection from './RightSection';
|
|||||||
import ChatFooter from './ChatFooter';
|
import ChatFooter from './ChatFooter';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { AUTH_TOKEN_KEY, DEFAULT_CONVERSATION_NAME, WEB_TITLE } from '@/common/constants';
|
import { AUTH_TOKEN_KEY, DEFAULT_CONVERSATION_NAME, WEB_TITLE } from '@/common/constants';
|
||||||
import { HistoryMsgItemType, MsgDataType, getHistoryMsg, queryContext } from 'supersonic-chat-sdk';
|
import {
|
||||||
|
HistoryMsgItemType,
|
||||||
|
MsgDataType,
|
||||||
|
getHistoryMsg,
|
||||||
|
queryContext,
|
||||||
|
setToken as setChatSdkToken,
|
||||||
|
} from 'supersonic-chat-sdk';
|
||||||
import { getConversationContext } from './utils';
|
import { getConversationContext } from './utils';
|
||||||
import { setToken as setChatSdkToken } from 'supersonic-chat-sdk';
|
|
||||||
import 'supersonic-chat-sdk/dist/index.css';
|
import 'supersonic-chat-sdk/dist/index.css';
|
||||||
|
|
||||||
const Chat = () => {
|
const Chat = () => {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type Props = {
|
|||||||
const DEFAULT_LEFT_SIZE = '300px';
|
const DEFAULT_LEFT_SIZE = '300px';
|
||||||
|
|
||||||
const DomainManger: React.FC<Props> = ({ domainManger, dispatch }) => {
|
const DomainManger: React.FC<Props> = ({ domainManger, dispatch }) => {
|
||||||
|
window.RUNNING_ENV = 'semantic';
|
||||||
const [collapsed, setCollapsed] = useState(false);
|
const [collapsed, setCollapsed] = useState(false);
|
||||||
const [leftSize, setLeftSize] = useState('');
|
const [leftSize, setLeftSize] = useState('');
|
||||||
const { selectDomainId, selectDomainName } = domainManger;
|
const { selectDomainId, selectDomainName } = domainManger;
|
||||||
|
|||||||
@@ -196,7 +196,6 @@ const DomainManger: React.FC<Props> = ({ domainManger, domainId }) => {
|
|||||||
};
|
};
|
||||||
// const [visible, setVisible] = useState(false);
|
// const [visible, setVisible] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(domainId, graphData, 'domainId');
|
|
||||||
if (!(Array.isArray(graphData.children) && graphData.children.length > 0)) {
|
if (!(Array.isArray(graphData.children) && graphData.children.length > 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -356,7 +355,6 @@ const DomainManger: React.FC<Props> = ({ domainManger, domainId }) => {
|
|||||||
labelCfg: { style: { fill: '#3c3c3c' } },
|
labelCfg: { style: { fill: '#3c3c3c' } },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
console.log(graphData, 'graphData');
|
|
||||||
// graph.data(graphData);
|
// graph.data(graphData);
|
||||||
graph.changeData(graphData);
|
graph.changeData(graphData);
|
||||||
graph.render();
|
graph.render();
|
||||||
@@ -386,7 +384,6 @@ const DomainManger: React.FC<Props> = ({ domainManger, domainId }) => {
|
|||||||
value={graphShowType}
|
value={graphShowType}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const { value } = e.target;
|
const { value } = e.target;
|
||||||
console.log(value, 'value');
|
|
||||||
setGraphShowType(value);
|
setGraphShowType(value);
|
||||||
changeGraphData(dataSourceListData, value);
|
changeGraphData(dataSourceListData, value);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ const DimensionSearchVisibleModal: React.FC<Props> = ({
|
|||||||
const [dictRules, setDictRules] = useState<string>('');
|
const [dictRules, setDictRules] = useState<string>('');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const dictionaryInfos = themeData?.dictionaryInfos;
|
const knowledgeInfos = themeData?.knowledgeInfos;
|
||||||
if (Array.isArray(dictionaryInfos)) {
|
if (Array.isArray(knowledgeInfos)) {
|
||||||
const target = dictionaryInfos[0];
|
const target = knowledgeInfos[0];
|
||||||
if (Array.isArray(target?.ruleList)) {
|
if (Array.isArray(target?.ruleList)) {
|
||||||
setDictRules(target.ruleList[0]);
|
setDictRules(target.ruleList[0]);
|
||||||
}
|
}
|
||||||
const selectKeys = dictionaryInfos.map((item: any) => {
|
const selectKeys = knowledgeInfos.map((item: any) => {
|
||||||
return item.itemId;
|
return item.itemId;
|
||||||
});
|
});
|
||||||
setSelectedKeyList(selectKeys);
|
setSelectedKeyList(selectKeys);
|
||||||
@@ -48,7 +48,7 @@ const DimensionSearchVisibleModal: React.FC<Props> = ({
|
|||||||
}, [settingSourceList]);
|
}, [settingSourceList]);
|
||||||
|
|
||||||
const saveDictBatch = async () => {
|
const saveDictBatch = async () => {
|
||||||
const dictionaryInfos = selectedKeyList.map((key: string) => {
|
const knowledgeInfos = selectedKeyList.map((key: string) => {
|
||||||
return {
|
return {
|
||||||
itemId: key,
|
itemId: key,
|
||||||
type: 'DIMENSION',
|
type: 'DIMENSION',
|
||||||
@@ -62,7 +62,7 @@ const DimensionSearchVisibleModal: React.FC<Props> = ({
|
|||||||
saveDomainExtendQuery = editDomainExtend;
|
saveDomainExtendQuery = editDomainExtend;
|
||||||
}
|
}
|
||||||
const { code, msg } = await saveDomainExtendQuery({
|
const { code, msg } = await saveDomainExtendQuery({
|
||||||
dictionaryInfos,
|
knowledgeInfos,
|
||||||
domainId,
|
domainId,
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ const PermissionTable: React.FC<Props> = ({ domainManger }) => {
|
|||||||
|
|
||||||
const queryDepartmentData = async () => {
|
const queryDepartmentData = async () => {
|
||||||
const { code, data } = await getDepartmentTree();
|
const { code, data } = await getDepartmentTree();
|
||||||
if (code === 200) {
|
if (code === 200 || code === '0') {
|
||||||
setDepartmentTreeData(data);
|
setDepartmentTreeData(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryTmePersonData = async () => {
|
const queryTmePersonData = async () => {
|
||||||
const { code, data } = await getAllUser();
|
const { code, data } = await getAllUser();
|
||||||
if (code === 200) {
|
if (code === 200 || Number(code) === 0) {
|
||||||
setTmePerson(data);
|
setTmePerson(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export type LoginParamsType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function queryToken(code: string) {
|
export async function queryToken(code: string) {
|
||||||
return request(`${process.env.API_BASE_URL}user/ioaLoginCallback`, {
|
return request(`/davinciapi/login/tmeloginCallback`, {
|
||||||
params: { code },
|
params: { code },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
|
|||||||
|
|
||||||
const token = query[TOKEN_KEY] || localStorage.getItem(TOKEN_KEY);
|
const token = query[TOKEN_KEY] || localStorage.getItem(TOKEN_KEY);
|
||||||
if (token) {
|
if (token) {
|
||||||
|
headers.Authorization = `Bearer ${token}`;
|
||||||
headers.auth = `Bearer ${token}`;
|
headers.auth = `Bearer ${token}`;
|
||||||
localStorage.setItem(TOKEN_KEY, token);
|
localStorage.setItem(TOKEN_KEY, token);
|
||||||
}
|
}
|
||||||
@@ -31,25 +32,19 @@ const authHeaderInterceptor = (url: string, options: RequestOptionsInit) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const responseInterceptor = async (response: Response) => {
|
const responseInterceptor = async (response: Response) => {
|
||||||
const data: Result<any> = await response?.clone()?.json?.();
|
|
||||||
if (Number(data.code) === 403) {
|
|
||||||
history.push('/login');
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
const redirect = response.headers.get('redirect'); // 若HEADER中含有REDIRECT说明后端想重定向
|
const redirect = response.headers.get('redirect'); // 若HEADER中含有REDIRECT说明后端想重定向
|
||||||
if (redirect === 'REDIRECT') {
|
if (redirect === 'REDIRECT') {
|
||||||
localStorage.removeItem(TOKEN_KEY);
|
localStorage.removeItem(TOKEN_KEY);
|
||||||
let win: any = window;
|
const win: any = window;
|
||||||
while (win !== win.top) {
|
|
||||||
win = win.top;
|
|
||||||
}
|
|
||||||
if (!/fromExternal=true/.test(win.location.search)) {
|
|
||||||
localStorage.setItem(FROM_URL_KEY, win.location.href);
|
|
||||||
}
|
|
||||||
// 将后端重定向的地址取出来,使用win.location.href去实现重定向的要求
|
// 将后端重定向的地址取出来,使用win.location.href去实现重定向的要求
|
||||||
const contextpath = response.headers.get('contextpath');
|
const contextpath = response.headers.get('contextpath');
|
||||||
win.location.href = contextpath;
|
win.location.href = contextpath;
|
||||||
|
} else {
|
||||||
|
const data: Result<any> = await response?.clone()?.json?.();
|
||||||
|
if (Number(data.code) === 403) {
|
||||||
|
history.push('/login');
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|||||||
Reference in New Issue
Block a user