support search file desc
This commit is contained in:
1 parent
6d00be9d3b
commit
b693855012
13 files changed
+154
-40
No files matched your search
@@ -131,6 +131,8 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
onEditingTree: useWorkspace((state) => state.onEditingTree),
|
||||
open: useWorkspace((state) => state.open),
|
||||
workdir: useWorkspace((state) => state.workdir),
|
||||
relative: useWorkspace((state) => state.relative),
|
||||
updateFileMeta: useWorkspace((state) => state.updateFileMeta),
|
||||
};
|
||||
|
||||
const searchInputRef = useRef<InputRef>(null);
|
||||
@@ -605,8 +607,8 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
desc: editor.desc,
|
||||
} as TreeModel;
|
||||
fs.writeFileSync(path, JSON.stringify(treeModel, null, 2));
|
||||
workspace.updateFileMeta(editor);
|
||||
editor.unsave = false;
|
||||
|
||||
editor.data = b3util.createTreeData(root);
|
||||
editor.autoId = b3util.refreshTreeDataId(editor.data);
|
||||
editor.graph.changeData(editor.data);
|
||||
@@ -664,7 +666,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
desc: data.desc,
|
||||
} as TreeModel;
|
||||
fs.writeFileSync(subpath, JSON.stringify(subtreeModel, null, 2));
|
||||
data.path = Path.relative(workspace.workdir, subpath).replaceAll(Path.sep, "/");
|
||||
data.path = workspace.relative(subpath);
|
||||
reload();
|
||||
pushHistory();
|
||||
onChange();
|
||||
@@ -858,7 +860,7 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
|
||||
{
|
||||
id: editor.autoId++,
|
||||
name: "unknow",
|
||||
path: Path.relative(workspace.workdir, exploreFile).replaceAll(Path.sep, "/"),
|
||||
path: workspace.relative(exploreFile),
|
||||
},
|
||||
dstData.id
|
||||
);
|
||||
|
||||
@@ -551,7 +551,7 @@ export const Explorer: FC = () => {
|
||||
break;
|
||||
}
|
||||
case "revealFile":
|
||||
shell.showItemInFolder(node.path.replaceAll("/", Path.sep));
|
||||
ipcRenderer.invoke("showItemInFolder", node.path);
|
||||
break;
|
||||
case "rename": {
|
||||
node.editing = true;
|
||||
|
||||
@@ -9,7 +9,9 @@ import { FC, useEffect, useMemo } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Markdown from "react-markdown";
|
||||
|
||||
interface OptionType extends DefaultOptionType {}
|
||||
interface OptionType extends DefaultOptionType {
|
||||
value: string;
|
||||
}
|
||||
|
||||
const TreeInspector: FC = () => {
|
||||
const workspace = {
|
||||
@@ -70,6 +72,7 @@ const NodeInspector: FC = () => {
|
||||
onEditingNode: useWorkspace((state) => state.onEditingNode),
|
||||
allFiles: useWorkspace((state) => state.allFiles),
|
||||
fileTree: useWorkspace((state) => state.fileTree),
|
||||
relative: useWorkspace((state) => state.relative),
|
||||
};
|
||||
const { t } = useTranslation();
|
||||
const [form] = Form.useForm();
|
||||
@@ -133,14 +136,15 @@ const NodeInspector: FC = () => {
|
||||
// auto complete for subtree
|
||||
const subtreeOptions = useMemo(() => {
|
||||
const options: OptionType[] = [];
|
||||
workspace.allFiles.forEach((path) => {
|
||||
const value = Path.relative(workspace.fileTree!.path, path).replaceAll(Path.sep, "/");
|
||||
workspace.allFiles.forEach((file) => {
|
||||
const value = workspace.relative(file.path);
|
||||
const desc = ""; //fileNode.desc ? `(${fileNode.desc})` : "";
|
||||
options.push({
|
||||
label: `${value}${desc}`,
|
||||
value: value,
|
||||
});
|
||||
});
|
||||
options.sort((a, b) => a.value.localeCompare(b.value));
|
||||
return options;
|
||||
}, [workspace.allFiles, workspace.fileTree]);
|
||||
|
||||
@@ -328,9 +332,7 @@ const NodeInspector: FC = () => {
|
||||
)}
|
||||
{type === "float" && <InputNumber disabled={disabled} onBlur={form.submit} />}
|
||||
{type === "boolean" && <Switch disabled={disabled} onChange={form.submit} />}
|
||||
{type === "code" && (
|
||||
<Input onBlur={form.submit} placeholder={t("node.codePlaceholder")} />
|
||||
)}
|
||||
{type === "code" && <Input disabled={disabled} onBlur={form.submit} />}
|
||||
{type === "enum" && (
|
||||
<Select disabled={disabled} onBlur={form.submit} onChange={form.submit}>
|
||||
{v.options?.map((value) => {
|
||||
@@ -475,7 +477,6 @@ const NodeDefInspector: FC = () => {
|
||||
</Divider>
|
||||
{data.args.map((v, i) => {
|
||||
const required = v.type.indexOf("?") == -1;
|
||||
const type = v.type.replace("?", "") as NodeArgType;
|
||||
return (
|
||||
<Form.Item
|
||||
name={`args.${i}.type`}
|
||||
|
||||
@@ -41,12 +41,10 @@ export const Menu: FC<LayoutProps> = () => {
|
||||
const { t } = useTranslation();
|
||||
const [trigger, setTrigger] = useState<DropDownProps["trigger"]>(["click"]);
|
||||
const workspace = {
|
||||
allFiles: useWorkspace((state) => state.allFiles),
|
||||
batchProject: useWorkspace((state) => state.batchProject),
|
||||
buildProject: useWorkspace((state) => state.buildProject),
|
||||
createProject: useWorkspace((state) => state.createProject),
|
||||
editing: useWorkspace((state) => state.editing),
|
||||
editors: useWorkspace((state) => state.editors),
|
||||
init: useWorkspace((state) => state.init),
|
||||
open: useWorkspace((state) => state.open),
|
||||
openProject: useWorkspace((state) => state.openProject),
|
||||
|
||||
@@ -20,23 +20,28 @@ export const TitleBar: FC<LayoutProps> = () => {
|
||||
onShowingSearch: useWorkspace((state) => state.onShowingSearch),
|
||||
open: useWorkspace((state) => state.open),
|
||||
name: useWorkspace((state) => state.path),
|
||||
relative: useWorkspace((state) => state.relative),
|
||||
};
|
||||
const searchOptions = useMemo(() => {
|
||||
const options: OptionType[] = [];
|
||||
workspace.allFiles.forEach((path) => {
|
||||
const value = Path.relative(workspace.fileTree!.path, path).replaceAll(Path.sep, "/");
|
||||
workspace.allFiles.forEach((file) => {
|
||||
const value = workspace.relative(file.path);
|
||||
const desc = file.desc ?? "";
|
||||
options.push({
|
||||
label: (
|
||||
<div>
|
||||
{Path.basename(value)}
|
||||
<span> </span>
|
||||
<span style={{ color: "gray", fontSize: "12px" }}>{Path.dirname(value)}</span>
|
||||
<span style={{ color: "gray", fontSize: "12px" }}>
|
||||
{Path.dirname(value)} {desc}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
value: value,
|
||||
path: path,
|
||||
value: `${value.toLocaleLowerCase()} ${desc.toLocaleLowerCase()}`,
|
||||
path: file.path,
|
||||
});
|
||||
});
|
||||
options.sort((a, b) => a.path.localeCompare(b.path));
|
||||
return options;
|
||||
}, [workspace.allFiles, workspace.fileTree]);
|
||||
return (
|
||||
@@ -101,7 +106,9 @@ export const TitleBar: FC<LayoutProps> = () => {
|
||||
workspace.open(option.path);
|
||||
}
|
||||
}}
|
||||
filterOption={(input, option) => (option?.value ?? "").includes(input)}
|
||||
filterOption={(input, option) =>
|
||||
(option?.value ?? "").includes(input.toLocaleLowerCase())
|
||||
}
|
||||
filterSort={(optionA, optionB) =>
|
||||
(optionA?.value ?? "")
|
||||
.toLowerCase()
|
||||
|
||||
Reference in new issue
Block a user