Skip to content

Commit

Permalink
fix: 处理审计树缓存异常引起的崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
youngster-yj committed Aug 14, 2024
1 parent a05d78f commit a2b3bc9
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,23 @@
}
}
}

.additional-params-divider {
margin: 16px 12px;
display: flex;
justify-content: space-between;
align-items: center;
gap: 4px;
.text-style {
color: #b4bbca;
font-size: 12px;
font-weight: 600;
line-height: 16px;
}
.divider-style {
flex: 1;
overflow: hidden;
height: 1px;
border-top: 1px dashed #eaecf3;
}
}
33 changes: 21 additions & 12 deletions app/renderer/src/main/src/pages/YakRunner/AuditCode/AuditCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,12 @@ export const AuditCode: React.FC<AuditCodeProps> = (props) => {

if (itemDetail.ResourceType === "variable" || itemDetail.ResourceType === TopId) {
obj.children = initAuditTree(childArr, depth + 1)
obj.isLeaf = false
// 数量为0时不展开 message除外
if (parseInt(obj.Size + "") === 0 && itemDetail.ResourceType !== TopId) {
obj.isLeaf = true
} else {
obj.isLeaf = false
}
} else {
obj.isLeaf = true
}
Expand Down Expand Up @@ -424,6 +429,8 @@ export const AuditCode: React.FC<AuditCodeProps> = (props) => {
}
// 变量
if (ResourceType === "variable") {
console.log("yyy", Size, parseInt(Size + ""))

const id = `${path}${ResourceName}`
variableIds.push(id)
setMapAuditDetail(id, {
Expand Down Expand Up @@ -760,8 +767,8 @@ export const AuditHistoryTable: React.FC<AuditHistoryTableProps> = memo((props)
try {
await grpcFetchDeleteAudit(path)
getAduitList()
console.log("ooo",path,projectNmae);
console.log("ooo", path, projectNmae)

if (path === `/${projectNmae}`) {
setLoadTreeType && setLoadTreeType("file")
setFileTree && setFileTree([])
Expand All @@ -773,7 +780,7 @@ export const AuditHistoryTable: React.FC<AuditHistoryTableProps> = memo((props)
})

return (
<div className={styles["audit-history-table"]} onKeyDown={(event)=>event.stopPropagation()}>
<div className={styles["audit-history-table"]} onKeyDown={(event) => event.stopPropagation()}>
<div className={styles["header"]}>
<div className={styles["main"]}>
<div className={styles["title"]}>已编译项目</div>
Expand Down Expand Up @@ -854,14 +861,16 @@ export const AuditHistoryTable: React.FC<AuditHistoryTableProps> = memo((props)
<div className={styles["audit-path"]}>{obj.path}</div>
<div className={styles["audit-time"]}>{obj.time}</div>
<div className={styles["audit-opt"]}>
<YakitButton
type='text'
icon={<OutlineArrowcirclerightIcon className={styles["to-icon"]} />}
onClick={() => {
emiter.emit("onOpenAuditTree", item.ResourceName)
onClose()
}}
/>
<Tooltip title={"打开项目"}>
<YakitButton
type='text'
icon={<OutlineArrowcirclerightIcon className={styles["to-icon"]} />}
onClick={() => {
emiter.emit("onOpenAuditTree", item.ResourceName)
onClose()
}}
/>
</Tooltip>
<Divider type={"vertical"} style={{margin: 0}} />
{/* <YakitPopconfirm
title={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
flex-direction: column;
align-items: flex-start;
background: #f8f8f8;
// border-right: 1px solid #eaecf3;
border-right: 1px solid #eaecf3;
}

&-item {
Expand Down Expand Up @@ -60,7 +60,7 @@
background-color: rgba(204, 210, 222, 0.5);
cursor: not-allowed;
}

&-item-active:hover {
background-color: var(--yakit-primary-4);
}
Expand Down Expand Up @@ -90,6 +90,6 @@
}
}

.hidden{
.hidden {
border-right: 1px solid var(--yakit-background-color);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
padding: 8px;
border-radius: 4px;
background: #f0f1f3;
overflow: auto;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ export const FlowChartBox: React.FC<FlowChartBoxProps> = (props) => {
}
})

const onRefreshAuditDetailFun = useMemoizedFn(()=>{
setNodeId(undefined)
})

useEffect(() => {
// 打开编译右侧详情
emiter.on("onRefreshAuditDetail", onRefreshAuditDetailFun)
return () => {
emiter.off("onRefreshAuditDetail", onRefreshAuditDetailFun)
}
}, [])

useEffect(() => {
if (!graph) return
instance().then((viz) => {
Expand Down Expand Up @@ -225,6 +237,7 @@ export const FlowChartBox: React.FC<FlowChartBoxProps> = (props) => {
onMouseDown={handleMouseDown}
onMouseUp={handleMouseUp}
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseUp}
ref={svgBoxRef}
/>
{nodeId && (
Expand Down
15 changes: 11 additions & 4 deletions app/renderer/src/main/src/pages/YakRunner/YakRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,17 @@ export const YakRunner: React.FC<YakRunnerProps> = (props) => {
}
insertFileMap(keys[index])
})
useEffect(() => {
loadIndexRef.current = 0

const clearMap = useMemoizedFn(()=>{
clearMapFileDetail()
clearMapFolderDetail()
clearMapAuditDetail()
clearMapAuditChildDetail()
})

useEffect(() => {
loadIndexRef.current = 0
clearMap()
let id = setInterval(() => {
loadFileMap()
}, 100)
Expand All @@ -229,8 +236,7 @@ export const YakRunner: React.FC<YakRunnerProps> = (props) => {
return
}
loadIndexRef.current = 0
clearMapFileDetail()
clearMapFolderDetail()
clearMap()
// FileTree缓存清除
emiter.emit("onResetFileTree")
})
Expand Down Expand Up @@ -966,6 +972,7 @@ export const YakRunner: React.FC<YakRunnerProps> = (props) => {
const data: AuditEmiterYakUrlProps = JSON.parse(value)
setAuditRightParams(data)
setShowAuditDetail(true)
emiter.emit("onRefreshAuditDetail")
} catch (error) {}
})

Expand Down
2 changes: 2 additions & 0 deletions app/renderer/src/main/src/utils/eventBus/events/yakRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ export type YakRunnerEventProps = {
onOpenAuditTree: string
// 重置审计模式缓存数据
onResetAuditStatus?: string
// 刷新审计详情(关闭节点信息)
onRefreshAuditDetail?: string
}

0 comments on commit a2b3bc9

Please sign in to comment.