Skip to content

Commit

Permalink
support custom icons
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Apr 17, 2024
1 parent 1c0ac11 commit b81d944
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ if (!app.requestSingleInstanceLock()) {
process.exit(0);
}

app.commandLine.appendArgument("–-allow-file-access-from-files");
app.commandLine.appendArgument("--disable-web-security");

// Remove electron security warnings
// This warning only shows in development mode
// Read more on https://www.electronjs.org/docs/latest/tutorial/security
Expand Down Expand Up @@ -73,6 +76,7 @@ async function createWindow(projectPath?: string) {
// Read more on https://www.electronjs.org/docs/latest/tutorial/context-isolation
nodeIntegration: true,
contextIsolation: false,
webSecurity: false,
},
});

Expand Down
2 changes: 1 addition & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"node.deleteRootNodeDenied": "Unable to delete the root node",
"node.editSubtreeDenied": "Unable to edit the subtree node",
"node.desc": "Node desc",
"node.fileRequired": "{{field}} field is required",
"node.fileRequired": "field '{{field}}' is required",
"node.id": "Node id",
"node.inputVariable": "Input variables",
"node.name": "Node name",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"node.deleteRootNodeDenied": "不能删除根节点",
"node.editSubtreeDenied": "不能编辑子树节点",
"node.desc": "节点说明",
"node.fileRequired": "字段<b>{{field}}</b>必填",
"node.fileRequired": "字段{{field}}必填",
"node.id": "节点标识",
"node.inputVariable": "输入变量",
"node.name": "节点名称",
Expand Down
6 changes: 6 additions & 0 deletions sample/icons/cmp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions sample/node-config.b3-setting
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{
"name": "Cmp",
"type": "Condition",
"icon": "icons/cmp.svg",
"doc": "+ 若值为空,返回失败\n+ 非整数类型可能会报错\n",
"input": [
"值(int)"
Expand Down
4 changes: 2 additions & 2 deletions src/components/inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export const Inspector: FC = () => {
if (node) {
node.input?.forEach((v, i) => {
const desc = node.def.input?.[i] ?? "<unknown>";
if (v && !options.find((option) => option.value !== v)) {
if (v && !options.find((option) => option.value === v)) {
options.push({ label: `${v}(${desc})`, value: v });
}
});
node.output?.forEach((v, i) => {
const desc = node.def.output?.[i] ?? "<unknown>";
if (v && !options.find((option) => option.value !== v)) {
if (v && !options.find((option) => option.value === v)) {
options.push({ label: `${v}(${desc})`, value: v });
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/register-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ G6.registerNode(
});

// icon
const img = `./icons/${classify}.svg`;
const img = nodeDef.icon ? workspace.workdir + "/" + nodeDef.icon : `./icons/${classify}.svg`;
addShape("image", {
attrs: {
x: 5,
Expand Down
1 change: 0 additions & 1 deletion src/contexts/workspace-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ export const useWorkspace = create<WorkspaceStore>((set, get) => ({
const workspace = get();
let hasEvent = false;
fs.watch(workspace.workdir, { recursive: true }, (event, filename) => {
console.log("fileanme", event, filename);
if (event === "rename") {
if (!hasEvent) {
setTimeout(() => {
Expand Down

0 comments on commit b81d944

Please sign in to comment.