From e6fc26b5bae356e8e15cbca799e9a8017c4542b5 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Thu, 22 Feb 2024 22:30:00 -0500 Subject: [PATCH] Fix package app path --- src/common/bootstrap.ts | 23 ++++++++++++++++------- src/common/utils.ts | 6 ++---- src/renderer/components/Loader.tsx | 5 +++++ 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/common/bootstrap.ts b/src/common/bootstrap.ts index 9df5862..4b611a3 100644 --- a/src/common/bootstrap.ts +++ b/src/common/bootstrap.ts @@ -148,17 +148,19 @@ export const initStore = () => { defaultsInt, } as any); - console.log("_static", getStaticPath()); + const staticsPath = getStaticPath(); + + console.log("_static", staticsPath); const paths = (await storeInt.get("paths")) || {}; - const envPath = path.join(getStaticPath(), "env"); + const envPath = path.join(staticsPath, "env"); const configPath = await getConfigPath(); - const assetsPath = path.join(getStaticPath(), "assets"); - const themesPath = path.join(getStaticPath(), "themes"); - const bufferPath = path.join(getStaticPath(), "buffer"); - const publicPath = path.join(getStaticPath(), "public"); - const vendorPath = path.join(getStaticPath(), "vendor"); + const assetsPath = path.join(staticsPath, "assets"); + const themesPath = path.join(staticsPath, "themes"); + const bufferPath = path.join(staticsPath, "buffer"); + const publicPath = path.join(staticsPath, "public"); + const vendorPath = path.join(staticsPath, "vendor"); const storeIntPaths = { ...paths, @@ -187,6 +189,13 @@ export const initStore = () => { defaults, }); + /** + * Creating statics dir if it doesn't exist + */ + if (!fs.existsSync(staticsPath)) { + fs.mkdirSync(staticsPath); + } + /** * Creating themes dir if it doesn't exist */ diff --git a/src/common/utils.ts b/src/common/utils.ts index 5092866..9210d21 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -65,11 +65,9 @@ export const getConfigPath = async () => { }; export const getRootPath = () => { - const rootPath = app.isPackaged ? app.getPath('appData') : app.getPath('exe').split("node_modules")[0]; - console.log("rootPath", rootPath); - return rootPath; + return app.isPackaged ? app.getPath('userData') : app.getPath('exe').split("node_modules")[0];; } export const getStaticPath = () => { - return path.join(app.isPackaged ? process.resourcesPath : getRootPath(), 'static'); + return path.join(app.isPackaged && !process.resourcesPath?.includes("WindowsApps") ? process.resourcesPath : getRootPath(), 'static'); }; diff --git a/src/renderer/components/Loader.tsx b/src/renderer/components/Loader.tsx index e4caa63..467b067 100644 --- a/src/renderer/components/Loader.tsx +++ b/src/renderer/components/Loader.tsx @@ -8,6 +8,10 @@ import App from "./App"; import cx from "classnames"; +// const remote = require("@electron/remote"); +// const win = remote.getCurrentWindow(); +// const openDevTools = remote.getGlobal("openDevTools"); + const Loader: FunctionComponent = () => { const [isLoading, setIsLoading] = React.useState(true); const [loadingText, setLoadingText] = React.useState(""); @@ -22,6 +26,7 @@ const Loader: FunctionComponent = () => { }; React.useEffect(() => { + //openDevTools(); const init = async () => { setLoadingText("Initializing Configuration"); await initConfig();