haoxiang-xu / surface-editor

WebCodeEditor+LLMs is a state-of-the-art web-based Code Editor that leverages the power of large language models to assist in coding. By utilizing a vector database, it establishes intricate relationships between files and code segments.
0 stars 0 forks source link

electron refactor #120

Open haoxiang-xu opened 1 month ago

haoxiang-xu commented 1 month ago

Involved files:

receives directory-data at line 516-519

  useEffect(() => {
    window.electron.receive("directory-data", (data) => {
      setDir(data);
    });
  }, []);

access file content by calling readFile() at line 864-875

  const access_file_content_by_path = (path) => {
    if (path in file) {
      return file[path].fileContent;
    } else {
      //AWAIT ELECTRONJS TO LOAD THAT PATH IN SYSTEM
      window.electronAPI.readFile(
        access_file_absolute_path_by_path(path),
        path
      );
      return path;
    }
  };

calls triggerReadDir() at line 474-476

        case "openFolder": {
          window.electronAPI.triggerReadDir();
        }

app window frame control at line 40-48

  const handleClose = () => {
    window.electron.send("window-control", "close");
  };
  const handleMinimize = () => {
    window.electron.send("window-control", "minimize");
  };
  const handleMaximize = () => {
    window.electron.send("window-control", "maximize");
  };