From b8b1808ed78784097191554b9790c49d20291581 Mon Sep 17 00:00:00 2001
From: heiheihei <1395202740@qq.com>
Date: Fri, 29 Aug 2025 15:17:46 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=AD=E8=8B=B1=E6=96=87=E7=BF=BB?=
=?UTF-8?q?=E8=AF=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ModelVis/app/src/App.tsx | 33 +++++++++------
.../ModelStructure/Properties/Edge/index.tsx | 42 ++++++++++---------
.../src/ModelStructure/Properties/Header.tsx | 8 ++--
.../Properties/Node/Metadata.tsx | 2 +-
.../src/ModelStructure/Properties/index.tsx | 2 +-
.../app/src/hooks/useNewPathForLayout.ts | 5 ++-
.../ModelVis/app/src/locales/en.json | 8 +++-
.../ModelVis/app/src/locales/zh-CN.json | 8 +++-
8 files changed, 64 insertions(+), 44 deletions(-)
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx
index 1b1780995a..b4b61884e3 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx
@@ -20,23 +20,30 @@ import FileUpload from "./FileUpload"
import ModelStructure from "./ModelStructure"
import { Toolbar } from "./features"
import { Loading } from "./ui"
+import { ConfigProvider } from "antd"
+import enUS from "antd/locale/en_US"
+import zhCN from "antd/locale/zh_CN"
+import { useLanguage } from "hooks"
const App = () => {
const modelPath = useAtomValue(modelPathAtom)
+ const [appLanguage] = useLanguage()
- return
-
-
- {modelPath
- ? <>
-
-
-
-
- >
- :
- }
-
+ return
+
+
+
+ {modelPath
+ ? <>
+
+
+
+
+ >
+ :
+ }
+
+
}
export default App
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Edge/index.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Edge/index.tsx
index eb296112a2..cd9edde415 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Edge/index.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Edge/index.tsx
@@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import { useI18n } from "hooks"
import { joinCls } from "libs"
import { useSelectionHistory } from "stores"
@@ -25,10 +26,11 @@ type Props = {
const EdgeProperty = ({ edge: { source, target } }: Props) => {
const history = useSelectionHistory()
+ const t = useI18n()
const groupCls = joinCls(
- "group flex items-center gap-2 rounded-lg px-3 py-2.5",
- "cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-700/50"
+ "group flex items-center gap-2 rounded-lg px-3 py-2.5",
+ "cursor-pointer hover:bg-slate-100 dark:hover:bg-slate-700/50"
)
const nameLabelCls = "font-medium text-slate-600 text-sm dark:text-slate-400"
@@ -41,35 +43,35 @@ const EdgeProperty = ({ edge: { source, target } }: Props) => {
return <>
- Source:
+ className={nameLabelCls}>
+ {t("panel.source")}:
+ className={
+ valueLabelCls +
+ " group-hover:text-blue-500 dark:group-hover:text-blue-400"
+ }>
{source}
-
- Target:
-
+ className={nameLabelCls}>
+ {t("panel.target")}:
+
+
{target}
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Header.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Header.tsx
index 8ac4ae6950..2d45eeb06d 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Header.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Header.tsx
@@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+import { useI18n } from "hooks"
import { joinCls } from "libs"
import { ArrowLeft, ArrowRight } from "lucide-react"
import { useSelectionHistory } from "stores"
@@ -23,6 +24,7 @@ type Props = {
const Header = ({ isNode }: Props) => {
const { index, history, back, forward } = useSelectionHistory()
+ const t = useI18n()
const backDisabled = index < 1
const forwardDisabled = index >= history.length - 1
@@ -40,7 +42,7 @@ const Header = ({ isNode }: Props) => {
onClick={back}
className={btnCls}
>
-
+
const btnForward =
return {
"justify-self-auto font-medium text-lg",
"text-slate-500 dark:text-slate-400"
)}>
- Properties
+ {t("panel.properties")}
{btnForward}
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Node/Metadata.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Node/Metadata.tsx
index 0d0260cda6..0a8d98705e 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Node/Metadata.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Node/Metadata.tsx
@@ -67,7 +67,7 @@ const Metadata = ({node}: Props) => {
"border border-slate-200/70 dark:border-slate-700/60",
"rounded-xl p-3 backdrop-blur-sm"
)}>
-
+
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/index.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/index.tsx
index 21cf04aa0f..464585055a 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/index.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/index.tsx
@@ -59,7 +59,7 @@ const Properties = () => {
useEffect(() => {
initProperties()
- }, [model, current])
+ }, [model, current, t])
return
{
const [zoom, , resetZoom] = useZoom()
const setLoading = useSetAtom(loadingAtom)
const { recentProjCacheAdd } = useRecentProjectStorage()
+ const t = useI18n()
return async (path: string | null) => {
if (!path || path === modelPath) return
@@ -51,8 +53,7 @@ export const useNewPathForLayout = (): LayoutNewPath => {
setLoading(true)
const res = await invoke
("layout_bin", {path})
setLoading(false)
-
- toast.success(`parse + transfer cost ${Math.round(performance.now() - start)}ms`, {
+ toast.success(t("parseAndTransfer", {time:Math.round(performance.now() - start)}), {
richColors: true,
closeButton: true
})
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json
index 41cb2c5f49..5e62d8dcec 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json
@@ -1,6 +1,7 @@
{
"search": "Search",
"searchNodeEdge": "Search for nodes and edges",
+ "parseAndTransfer": "parse + transfer cost {time}ms",
"control": {
"showMinimap": "ShowMinimap",
"hideMinimap": "HideMinimap",
@@ -17,11 +18,14 @@
},
"panel": {
"node": "Node",
- "type": "Type",
+ "operator": "Operator",
"name": "Name",
"attrs": "Attributes",
"inputs": "Inputs",
- "outputs": "Outputs"
+ "outputs": "Outputs",
+ "source": "Source",
+ "target": "Target",
+ "properties": "Properties"
},
"dynamicNodes": "Dynamic Nodes",
"project": {
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json
index 0728fc3abc..0e1cbbd77e 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json
@@ -1,6 +1,7 @@
{
"search": "搜索",
"searchNodeEdge": "搜索节点和边",
+ "parseAndTransfer": "解析+传输成本 {time}ms",
"control": {
"showMinimap": "显示缩略图",
"hideMinimap": "隐藏缩略图",
@@ -17,11 +18,14 @@
},
"panel": {
"node": "节点信息",
- "type": "算子",
+ "operator": "算子",
"name": "名称",
"attrs": "额外属性",
"inputs": "输入",
- "outputs": "输出"
+ "outputs": "输出",
+ "source": "来源",
+ "target": "目标",
+ "properties": "属性"
},
"dynamicNodes": "动态算子",
"project": {
--
Gitee
From ab06d4d711ac5963e593a81e6fd7fabbff327242 Mon Sep 17 00:00:00 2001
From: heiheihei <1395202740@qq.com>
Date: Mon, 1 Sep 2025 11:26:32 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E5=A4=B1=E8=B4=A5?=
=?UTF-8?q?=E4=B8=AD=E8=8B=B1=E6=96=87=E7=BF=BB=E8=AF=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../app/src/ModelStructure/Control/index.tsx | 3 +-
.../app/src/ModelStructure/Dynamic/index.tsx | 2 +-
.../app/src/ModelStructure/Fsg/FsgTable.tsx | 15 +++------
.../ModelVis/app/src/hooks/index.ts | 1 +
.../ModelVis/app/src/hooks/useMessage.ts | 33 +++++++++++++++++++
.../app/src/hooks/useNewPathForLayout.ts | 16 ++++++---
.../ModelVis/app/src/locales/en.json | 2 +-
.../ModelVis/app/src/locales/zh-CN.json | 2 +-
.../ModelVis/app/src/types/app-config.d.ts | 10 ++++++
9 files changed, 66 insertions(+), 18 deletions(-)
create mode 100644 plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useMessage.ts
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/index.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/index.tsx
index 07061dbcf1..6daebd9755 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/index.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/index.tsx
@@ -29,7 +29,8 @@ const Control = () =>
-
+ {/* 缩略图还未实现,暂时隐藏 */}
+ {/*
*/}
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Dynamic/index.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Dynamic/index.tsx
index 08d7ec5855..d8266baaeb 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Dynamic/index.tsx
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Dynamic/index.tsx
@@ -34,7 +34,7 @@ const DynamicNodesBrowser = () => {
"flex flex-col gap-y-2 overflow-x-hidden rounded-xl",
"bg-neutral-100 px-4 py-2.5 dark:bg-dark-light"
)}>
-
{t("dynamicNodes")}
+
{t("dynamicOperator")}
{nodes?.map(node =>
{
const [selectedRow, setSelectedRow] = useState()
const currentGraph = useAtomValue(currentGraphAtom)
const path = useAtomValue(modelPathAtom)
+ const { error } = useMessage()
const jumpFsg = (record: FsgTableRow) => {
const { fsgIndex, nodes } = record
@@ -202,10 +203,7 @@ export const FsgTable = () => {
setFsgData(fsgs)
fsgDataCach = res
} catch (err) {
- message.error({
- content: typeof err === 'string' ? err : JSON.stringify(err),
- className: 'dark:text-white dark:[&_div]:!bg-dark-light',
- })
+ error(err as RequestError)
}
setLoading(false)
}
@@ -216,10 +214,7 @@ export const FsgTable = () => {
opDuration = res
} catch (err) {
- message.error({
- content: typeof err === 'string' ? err : JSON.stringify(err),
- className: 'dark:text-white dark:[&_div]:!bg-dark-light',
- })
+ error(err as RequestError)
}
const fsgs = dedup(sortedFsgs(fsgDataCach))
setFsgData(fsgs)
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/index.ts b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/index.ts
index 6b851b5362..8d1aabb61b 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/index.ts
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/index.ts
@@ -19,3 +19,4 @@ export * from "./useVisible"
export * from "./useNewPathForLayout"
export * from "./useAnimatedTranslate"
export * from "./useCleanup"
+export * from "./useMessage"
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useMessage.ts b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useMessage.ts
new file mode 100644
index 0000000000..ac43581581
--- /dev/null
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useMessage.ts
@@ -0,0 +1,33 @@
+// Copyright (c) 2025, Huawei Technologies Co., Ltd.
+// All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { message } from 'antd'
+import { useAtomValue } from 'jotai'
+import { langAtom } from "stores"
+
+export const useMessage = () => {
+ const language = useAtomValue(langAtom)
+ const error = (err: RequestError) => {
+ const { File = {}, FSG = {}, Anyhow = {} } = err
+ const { message_en = '', message_cn = '', backtrace = undefined } = { ...File, ...FSG, ...Anyhow }
+ const additionalInfo = backtrace === undefined ? '' : `: ${backtrace}`
+ const content = `${language.code === 'en' ? message_en : message_cn}${additionalInfo}`
+ message.error({
+ content,
+ className: 'dark:text-white dark:[&_div]:!bg-dark-light',
+ })
+ }
+ return { error }
+}
\ No newline at end of file
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useNewPathForLayout.ts b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useNewPathForLayout.ts
index f9dfb35ad8..bafca8f903 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useNewPathForLayout.ts
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useNewPathForLayout.ts
@@ -14,7 +14,7 @@
// limitations under the License.
import { invoke } from "@tauri-apps/api/core"
-import { useI18n } from "hooks"
+import { useI18n, useMessage } from "hooks"
import { useAtom, useSetAtom } from "jotai"
import { toast } from "sonner"
import {
@@ -42,6 +42,7 @@ export const useNewPathForLayout = (): LayoutNewPath => {
const setLoading = useSetAtom(loadingAtom)
const { recentProjCacheAdd } = useRecentProjectStorage()
const t = useI18n()
+ const { error } = useMessage()
return async (path: string | null) => {
if (!path || path === modelPath) return
@@ -51,9 +52,16 @@ export const useNewPathForLayout = (): LayoutNewPath => {
const start = performance.now()
setLoading(true)
- const res = await invoke("layout_bin", {path})
- setLoading(false)
- toast.success(t("parseAndTransfer", {time:Math.round(performance.now() - start)}), {
+ let res
+ try {
+ res = await invoke("layout_bin", { path })
+ } catch (err) {
+ error(err as RequestError)
+ return
+ } finally {
+ setLoading(false)
+ }
+ toast.success(t("parseAndTransfer", { time: Math.round(performance.now() - start) }), {
richColors: true,
closeButton: true
})
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json
index 5e62d8dcec..dbe0df9df3 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/en.json
@@ -27,7 +27,7 @@
"target": "Target",
"properties": "Properties"
},
- "dynamicNodes": "Dynamic Nodes",
+ "dynamicOperator": "Dynamic Operator",
"project": {
"new": "Open New Project",
"close": "Close Project",
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json
index 0e1cbbd77e..6300c8d183 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/locales/zh-CN.json
@@ -27,7 +27,7 @@
"target": "目标",
"properties": "属性"
},
- "dynamicNodes": "动态算子",
+ "dynamicOperator": "动态算子",
"project": {
"new": "打开新项目",
"close": "关闭项目",
diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/types/app-config.d.ts b/plugins/mindstudio-insight-plugins/ModelVis/app/src/types/app-config.d.ts
index d06e4a9f63..d9ff22d5a7 100644
--- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/types/app-config.d.ts
+++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/types/app-config.d.ts
@@ -28,3 +28,13 @@ type AppLanguage = {
code: LangCode
content: LangPart
}
+
+type RequestError = {
+ [key: string]: {
+ code: number,
+ message_en: string,
+ message_cn: string,
+ backtrace?: string,
+
+ }
+}
--
Gitee