From f0edcbeeead0e6eb401ff90f3bd2f5dc13fea595 Mon Sep 17 00:00:00 2001 From: Kenta420 Date: Mon, 15 Jan 2024 11:02:37 +0700 Subject: [PATCH 1/2] update environment project for web & electron --- client-electron/README.md | 12 ++++++++++-- recipe_manager.code-workspace | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/client-electron/README.md b/client-electron/README.md index 06696d3..3804fe2 100644 --- a/client-electron/README.md +++ b/client-electron/README.md @@ -30,11 +30,19 @@ We have some environment variables to control app behavior. The environment vari > note: All the environment variables can access through `import.meta.env.{VARIABLE_NAME}`. -> note: In development mode, you can create a `.env.development.local` file in the root directory of the project to set environment variables. +> note: In development, you can create a `.env.local` file in the root directory of the project to set environment variables. + +## Environment Mode + +In this Client project, we have two environment modes: `electron` and `web`. Business logic will be different in these two modes. you wrap the code in `if (import.meta.env.MODE === 'electron')` to run the code in electron mode. You can also use `if (import.meta.env.MODE === 'web')` to run the code in web mode. + +The reason why we have two environment modes is that in electron we have to use native modules for example `deeplink` to handle login callback. But in web, we have to use `window.location.href` to handle login callback. + +> In Development, the default if to run cmd `npm run dev` is will run in both electron and web mode. If you want to run in electron or web mode, you can run `npm run dev:electron` or `npm run dev:web`. ## Environment Variables List -In this section, we will list all the environment variables. That app will use the default value if you don't set the environment variables. +In this section, we will list all the environment variables. That app will use in both environment mode the default value if you don't set the environment variables. > dev: if you add new environment variables, please add it to this section. diff --git a/recipe_manager.code-workspace b/recipe_manager.code-workspace index 8bbc475..f610594 100644 --- a/recipe_manager.code-workspace +++ b/recipe_manager.code-workspace @@ -19,6 +19,9 @@ "database": "${workspaceFolder:server}/data/database.db" } ], - "sqltools.useNodeRuntime": true + "sqltools.useNodeRuntime": true, + "cSpell.words": [ + "TAOBIN" + ] } -} +} \ No newline at end of file From 3ee7efcda915b82475c7c73a8cb23553ad3d6d9f Mon Sep 17 00:00:00 2001 From: Kenta420 Date: Mon, 15 Jan 2024 11:07:56 +0700 Subject: [PATCH 2/2] auto open default browser --- client-electron/package.json | 4 ++-- client-electron/tsconfig.json | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/client-electron/package.json b/client-electron/package.json index ef0c09d..f41c577 100644 --- a/client-electron/package.json +++ b/client-electron/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "concurrently \"npm run dev:electron\" \"npm run dev:web\"", "dev:electron": "vite -c vite.config.electron.ts", - "dev:web": "vite -c vite.config.web.ts", + "dev:web": "vite -c vite.config.web.ts --open", "build": "concurrently \"npm run build:electron\" \"npm run build:web\"", "build:electron": "tsc && vite build -c vite.config.electron.ts --mode=production && electron-builder", "build:web": "tsc && vite build -c vite.config.web.ts --mode=production", @@ -42,4 +42,4 @@ "vite-plugin-electron-renderer": "^0.14.5" }, "main": "dist-electron/main.js" -} +} \ No newline at end of file diff --git a/client-electron/tsconfig.json b/client-electron/tsconfig.json index d8f5fca..379bd2a 100644 --- a/client-electron/tsconfig.json +++ b/client-electron/tsconfig.json @@ -2,10 +2,13 @@ "compilerOptions": { "target": "ES2020", "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], + "lib": [ + "ES2020", + "DOM", + "DOM.Iterable" + ], "module": "ESNext", "skipLibCheck": true, - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, @@ -13,13 +16,19 @@ "isolatedModules": true, "noEmit": true, "jsx": "react-jsx", - /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, - "include": ["src", "electron"], - "references": [{ "path": "./tsconfig.node.json" }] -} + "include": [ + "src", + "electron" + ], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] +} \ No newline at end of file