diff --git a/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/App.tsx index 1b1780995a7ab766aa832b3056f653f17fbbb637..b4b61884e3d5d0655348f5ff34b4dd3ce7c5493c 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/Control/index.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Control/index.tsx index 07061dbcf1ac41866c805854a5d451ca3e098019..6daebd9755ac461247aa7d1b5ad141aebb42ca2a 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 08d7ec5855d5e7a204da16ee00b3cd51b06282d5..d8266baaebd0d8559c788dc5c7fa192d271cbd45 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/ModelStructure/Properties/Edge/index.tsx b/plugins/mindstudio-insight-plugins/ModelVis/app/src/ModelStructure/Properties/Edge/index.tsx index eb296112a250772b666d8767f02c95595601a9d5..cd9edde4150c92617a66efe356e8bb8cb0a7da93 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 8ac4ae6950245e96afbd27982e44cb6aa5be29fb..2d45eeb06d9ba1da9e5e53e469be6f90ee504f30 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 0d0260cda6a0d620a04a6fb06c9e13b6f43e5553..0a8d98705edd37b2a5eee30338259d4374c8b93c 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 21cf04aa0fb2241030db1a17791e318713187363..464585055a849ef8019ada88dd69cd848f772273 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 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 9a0ed70e165057060857093716bdfdaf86479bc6..bafca8f9037e90e8a1ca7ee3620a426d6b97ee4a 100644 --- a/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useNewPathForLayout.ts +++ b/plugins/mindstudio-insight-plugins/ModelVis/app/src/hooks/useNewPathForLayout.ts @@ -14,6 +14,7 @@ // limitations under the License. import { invoke } from "@tauri-apps/api/core" +import { useI18n, useMessage } from "hooks" import { useAtom, useSetAtom } from "jotai" import { toast } from "sonner" import { @@ -40,6 +41,8 @@ export const useNewPathForLayout = (): LayoutNewPath => { const [zoom, , resetZoom] = useZoom() const setLoading = useSetAtom(loadingAtom) const { recentProjCacheAdd } = useRecentProjectStorage() + const t = useI18n() + const { error } = useMessage() return async (path: string | null) => { if (!path || path === modelPath) return @@ -49,10 +52,16 @@ export const useNewPathForLayout = (): LayoutNewPath => { const start = performance.now() setLoading(true) - const res = await invoke("layout_bin", {path}) - setLoading(false) - - toast.success(`parse + transfer cost ${Math.round(performance.now() - start)}ms`, { + 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 41cb2c5f49d044ae7cd494b1542f67a5ef892b1a..dbe0df9df3250b1774e78a60e897e836b6dff335 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,13 +18,16 @@ }, "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", + "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 0728fc3abc520421d52bbb3d69dafa6bfdca99eb..6300c8d1835b3372fb3e71360940119c78f26f0e 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,13 +18,16 @@ }, "panel": { "node": "节点信息", - "type": "算子", + "operator": "算子", "name": "名称", "attrs": "额外属性", "inputs": "输入", - "outputs": "输出" + "outputs": "输出", + "source": "来源", + "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 d06e4a9f6348e3cba270d1745140a650299cb125..d9ff22d5a7cae2a25292a81009f8b63f58b6f8b4 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, + + } +}