⏳ vue3 + electron + ts + vite = mini template

Overview

v3-electron

🥳 Electron16 + Vue3 + Vite2

运行项目

# enter the project directory
cd v3-electron

# install dependency
yarn

# develop
yarn dev

# build exe
yarn build

# build dir
yarn build:dir

目录结构

一旦启动或打包脚本执行过,会在根目录产生 dist 文件夹,里面的文件夹同 src 一模一样;在使用一些路径计算时,尤其是相对路径计算;distsrc 里面保持相同的目录结构能避开好多问题

├
├── .electron-vue
├   ├── build.mjs                    项目构建脚本,对应 yarn build
├   ├── dev-runner.mjs               项目开发脚本,对应 yarn dev
├   ├── vite-main.config.ts          主进程配置文件,编译 src/main
├   ├── vite-preload.config.ts       预加载脚本配置文件,编译 src/preload
├   ├── vite-renderer.config.ts      渲染进程配置文件,编译 src/renderer
├
├── dist                             构建后,根据 src 目录生成
├   ├── main
├   ├── preload
├   ├── renderer
├
├── src
├   ├── main                         主进程源码
├   ├── preload                      预加载脚本源码
├   ├── renderer                     渲染进程源码
├
├── static                           静态资源
├   ├── icons                        系统图标
├

渲染进程使用 NodeJs API

🚧 因为安全的原因 Electron 默认不支持在 渲染进程 中使用 NodeJs API

推荐所有的 NodeJs、Electron API 通过 preload-script 注入到 渲染进程中,例如:

  • src/preload/index.ts

    import FS from 'fs'
    import LOGGER from 'electron-log'
    import remote from '@electron/remote'
    import { contextBridge, ipcRenderer } from 'electron'
    
    // --------- Expose some API to Renderer process. ---------
    contextBridge.exposeInMainWorld('FS', FS)
    contextBridge.exposeInMainWorld('LOGGER', LOGGER)
    contextBridge.exposeInMainWorld('remote', withPrototype(remote))
    contextBridge.exposeInMainWorld('ipcRenderer', withPrototype(ipcRenderer))
  • src/renderer/main.ts

    console.log('window', window)
You might also like...

使用 vue3 来实现俄罗斯方块

使用 vue3 来实现俄罗斯方块

Tetris-vue3 使用 vue3 实现俄罗斯方块 单机版本实现 联机版本实现 实现原理 采用了 Functional Core, Imperative Shell 模式来实现 提高了可测试性 业务核心逻辑和视图逻辑拆分 可以移植到任意 UI 库 todo 游戏重来 收获 应用程序从 0 到 1

Mar 25, 2022

vite2.7 + vue3.2 + ts + eslint + prettier

vite-vue-template 一个vue3项目模板 主要依赖 vite 2.7.2 vue 3.2.25 typescript eslint prettier 准备 Windows系统下将编辑器 行尾(eol) 设置为 LF('\n') vscode配置: { "files.eol":

Sep 13, 2022

A text replacer component for vue3.

A text replacer component for Vue 3. Requires Vue 3 as peer-dependency. Installation Install it from npm. npm install vue3-replacer pnpm add vue3-rep

Feb 19, 2022

A API documentation generator for Vue3 single file component.

doc-vue A API documentation generator for Vue3 single file component. Table of Contents Installation Write API Description Command Line Usage Programm

Oct 20, 2022

Vite template with TypeScript, Chakra UI, Eslint Airbnb, Prettier

Vite + Typescript + ChakraUI = ❤️ This is a vite template that combines several technologies: Vite React TypeScript ChakraUI Eslint with eslint-config

Mar 26, 2022

A template repository / quick start to build Azure Static Web Apps with a Node.js function. It uses Vue.js v3, Vue Router, Vuex, and Vite.js.

A template repository / quick start to build Azure Static Web Apps with a Node.js function. It uses Vue.js v3, Vue Router, Vuex, and Vite.js.

Azure Static Web App Template with Node.js API This is a template repository for creating Azure Static Web Apps that comes pre-configured with: Vue.js

Jun 25, 2022

Experimenting with vite typescript template rewrite for hot.opensauced.pizza

Experimenting with vite typescript template rewrite for hot.opensauced.pizza

🍕 Open Sauced Vite Typescript Template Test 🍕 The path to your next Open Source contribution 📖 Prerequisites In order to run the project we need th

Mar 11, 2022

Veloce: Starter template that uses Vue 3, Vite, TypeScript, SSR, Pinia, Vue Router, Express and Docker

Veloce Lightning-fast cold server start Instant hot module replacement (HMR) and dev SSR True on-demand compilation Tech Stack Vue 3: UI Rendering lib

Oct 7, 2022

🦇 Opinionated Vite Starter Template

🦇 Opinionated Vite Starter Template

because our first commits never have parents I bet your parents taught you that you mean something, that you're here for a reason. My parents taught m

Dec 22, 2022
Releases(v2.5.1)
Owner
UNPany
UNPany
vue3 + vite + typescript template

Vue 3 + Typescript + Vite This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 <script setu

BrowLi 6 Aug 1, 2022
⚡Vite + :electron: Electron

Vitron | SuperCharged Starter Overview click to show based on vite-react-electron (check the readme!) inspired by Nextron implemented custom-electron-

Yeon Vinzenz Varapragasam 11 Sep 16, 2022
vite+vue3.2+setup+elementPlus+eslint+js+stylelint

前期准备工作,npm包和vscode配置 !!!很重要,关乎整个Vue3开发阶段的代码提示 Volar使用 使用Vue3开发需要禁用vscode插件Vetur 然后安装 Volar(Vue Language Features),这样Vue3代码提示即使是使用js开发也非常友好 如果volar没有任何

null 2 Feb 8, 2022
Vue 3 + Vite + SSR template based on Vite Plugin SSR and inspired by Vitesse

Vite Vue SSR Starter Vue 3 + Vite + SSR template based on Vite Plugin SSR and inspired by Vitesse Features ⚡️ Vue 3, Vite 2, TypeScript ?? Domain-Driv

Oleg Koval 10 Aug 2, 2022
Vue3 SSR prod-ready multi-languages template

vue3-ssr-template About This template is a prod ready starter for your Vue SSR application where you can do what you want at any level, client or serv

null 9 Mar 11, 2022
Integrate Vite and Electron

vite-plugin-electron Integrate Vite and Electron Example ?? vite-plugin-electron-quick-start Usage vite.config.ts import electron from 'vite-plugin-el

null 217 Jan 2, 2023
⚡️ Vite + SolidJS + Electron boilerplate.

vite-solid-electron Overview Very simple Vite, SolidJS, Electron integration template. Contains only the basic dependencies. The extension is very fle

Christian Hansen 25 Dec 18, 2022
Vite-plugin-web-extension - A vite plugin for generating cross browser platform, ES module based web extensions.

vite-plugin-web-extension A vite plugin for generating cross browser platform, ES module based web extensions. Features Manifest V2 & V3 Support Compl

Ruben Medina 81 Dec 31, 2022
🎉🎉使用Vite + Vue3 + TypeScript + Element-plus + Mock开发的后台管理系统🎉🎉

Vite-Vue-Admin 介绍 Cli 配置 vue3.X vuex@4 vue-router@4 vite@2 typescript mock 内置 element-plus 二开封装 upload-file (文件上传,支持指定文件格式,文件大小) powerful-table (多功能表格

PengXiaoShuai 103 Dec 17, 2022
A simple, customization star rating component for your vue3 projects

vue3-star-ratings A simple, customizable component for star ratings Documentation Features Uses svg for the stars, so it can scale without quality los

Abiodun Olunu 14 Oct 7, 2022