12 changed files with 94 additions and 120 deletions
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,12 @@ |
|||||
|
|
||||
|
export function getFileUrl(route: string, isSPA: boolean = true) { |
||||
|
if (isSPA) { |
||||
|
const winURL = |
||||
|
process.env.NODE_ENV === "development" |
||||
|
? `http://localhost:${process.env.PORT}/#/${route}` |
||||
|
: `file://${__dirname}/index.html#/${route}` |
||||
|
return winURL |
||||
|
} else { |
||||
|
return "" |
||||
|
} |
||||
|
} |
@ -1,57 +1,18 @@ |
|||||
|
const { say } = require("cfonts") |
||||
// // http://localhost:3344
|
|
||||
// get("http://baidu.com",res=>{
|
|
||||
// console.log(res.statusCode);
|
|
||||
// })
|
|
||||
// import { spawn, ChildProcess } from 'child_process'
|
|
||||
// spawn(
|
|
||||
// electronForge,
|
|
||||
// [
|
|
||||
// "start",
|
|
||||
// "--inspect-electron",
|
|
||||
// "--app-path",
|
|
||||
// join(__dirname, "dist/electron/entry.js"),//join(__dirname, `../${main}`),
|
|
||||
// ] ,
|
|
||||
// {
|
|
||||
// stdio: 'inherit',
|
|
||||
// env: Object.assign(process.env, { NODE_ENV: "development" }),
|
|
||||
// })
|
|
||||
const chalk = require("chalk") |
const chalk = require("chalk") |
||||
const electron = require("electron") |
|
||||
const { spawn } = require("child_process") |
|
||||
const { join } = require("path") |
|
||||
console.log(electron); |
|
||||
|
|
||||
// let child = spawn(
|
|
||||
// electron,
|
|
||||
// [join(__dirname, `dist/electron/entry.js`)]
|
|
||||
// )
|
|
||||
|
|
||||
// if(child){
|
|
||||
// setTimeout(() => {
|
|
||||
// child.kill()
|
|
||||
// }, 5000);
|
|
||||
// }
|
|
||||
|
|
||||
function runVite () { |
|
||||
return new Promise((resolve, reject) => { |
|
||||
let viteProcess = spawn('node', [`D:/1XYX/pro/vite-electron/node_modules/vite/bin/vite.js`]) |
|
||||
let isReady = false; |
|
||||
viteProcess.stdout.on('data', (data) => { |
|
||||
console.log(`${data}`); |
|
||||
if (!isReady && data.indexOf("ready") != -1) { |
|
||||
resolve() |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
viteProcess.stderr.on('data', (data) => { |
function electronLog(data, color) { |
||||
console.error(`[vite err]: ${data}`); |
let log = "" |
||||
reject() |
data = data.toString().split(/\r?\n/) |
||||
}); |
data.forEach(line => { |
||||
|
log += ` ${line}\n` |
||||
viteProcess.on('close', (code) => { |
|
||||
console.log(`[vite close]: exited with code ${code}`); |
|
||||
reject() |
|
||||
}); |
|
||||
}) |
}) |
||||
} |
if (/[0-9A-z]+/.test(log)) { |
||||
|
console.log( |
||||
|
chalk[color].bold("┏ Electron -------------------") + "\n\n" + log + chalk[color].bold("┗ ----------------------------") + "\n" |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
electronLog("dfssssssssssssssssssssssssssssssssssssssssssssssss","red") |
Loading…
Reference in new issue