Skip to content

Commit

Permalink
fix: 🐛 createSqlite error
Browse files Browse the repository at this point in the history
  • Loading branch information
meetqy committed Jul 5, 2023
1 parent a713130 commit aac6983
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 8 additions & 0 deletions apps/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { join } from "path";
import { appRouter } from "@acme/api";
import { createAssetsServer } from "@acme/assets-server";
import curd from "@acme/curd";
import { createSqlite } from "@acme/db";

import globalApp from "./global";
import { restoreOrCreateWindow } from "./mainWindow";
Expand All @@ -19,6 +20,13 @@ import createMenu from "./src/menu";
import createTray from "./src/tray";
import { getAndUpdateConfig } from "./src/utils/config";

if (app.isPackaged) {
/**
* Init db.sqlite
*/
createSqlite(join(process.resourcesPath, "./packages/db/prisma/db.sqlite"));
}

/**
* Create all ipcHander in 'src/ipc/xxx.ts'
*/
Expand Down
7 changes: 1 addition & 6 deletions apps/electron/main/src/createWebServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import cp from "child_process";
import { join } from "path";
import { app } from "electron";

import { createSqlite } from "@acme/db";

import { getAndUpdateConfig } from "./utils/config";

/**
* 创建 Web/Assets 服务
* 创建 Web 服务
*/
export const createWebServer = async (preNextChild?: cp.ChildProcess) => {
let nextjsChild: cp.ChildProcess;
Expand All @@ -17,9 +15,6 @@ export const createWebServer = async (preNextChild?: cp.ChildProcess) => {
await getAndUpdateConfig();

if (isPackaged) {
// Create sqlite database file
createSqlite(join(process.resourcesPath, "./packages/db/prisma/db.sqlite"));

// Start nextjs server
nextjsChild = cp.fork(join(process.resourcesPath, "apps/nextjs/server.js"), {
env: {
Expand Down

0 comments on commit aac6983

Please sign in to comment.