构建electron项目

1. 使用electron-vite构建工具

官网链接
安装构建工具

typescript 复制代码
pnpm i electron-vite -g

创建electron-vite项目

typescript 复制代码
pnpm create @quick-start/electron

安装所有依赖

typescript 复制代码
pnpm i

其他

typescript 复制代码
pnpm -D add sass scss

1. 启动项目

2. 配置

  • package.json
typescript 复制代码
"dev": "electron-vite dev --watch",

2. 使用tailwind

tailwind官网

安装

typescript 复制代码
pnpm add -D tailwindcss postcss autoprefixer  

初始化tailwindcss

  • 创建两个配置文件
typescript 复制代码
npx tailwindcss init -p
// Created Tailwind CSS config file: tailwind.config.js
// Created PostCSS config file: postcss.config.js

修改tailwind.config.js

  • 官网上缺少vue的配置
typescript 复制代码
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
  theme: {
    extend: {}
  },
  plugins: []
}

在renderer/src目录创建index.css文件

typescript 复制代码
@tailwind base;
@tailwind components;
@tailwind utilities;

在main.ts文件中引入index.css

  • 脚手架自动创建了别名:@renderer': resolve('src/renderer/src')
typescript 复制代码
import { createApp } from 'vue'
import App from './App.vue'
import '@renderer/index.css'

createApp(App).mount('#app')

安装插件Tailwind CSS IntelliSense

  • 插件的作用:写tailwind代码就有提示了

App.vue

  • 测试tailwind是否可以使用
typescript 复制代码
<div class="bg-red-600">tailwind测试</div>

打包

electron-vite 打包makensis.exe报错解决记录

相关推荐
北城笑笑2 天前
Vue 109 ,从零搭建 Vue3 + Electron 工程:生态、安全桥接与打包选型( Vue + Electron )
前端·javascript·vue.js·安全·electron·vue
RobinDevNotes3 天前
从 Electron 到 GPUI,9 个跨平台桌面方案该怎么选
前端·javascript·rust·electron·openresty·前端开发工具
theMuseCatcher5 天前
Vue3导航菜单(Menu)
typescript·vue3·less
theMuseCatcher6 天前
Vue3评论(Comment)
typescript·vue3
不可能片场6 天前
内容运营自动化 配图折行别把词切两半
前端·electron
黄连木笛7 天前
不改一行 Postman 源码,把它汉化了:Electron preload 注入 + fetch 拦截实战
javascript·electron
RuoyiOffice7 天前
Vue3+Gantt:把任务排期、依赖关系和里程碑放进项目管理
项目管理·vue3·springboot·dhtmlx-gantt·wbs·gantt·ruoyi office
不可能片场7 天前
Electron 发布 正文写入的三条通道与读回口径
前端·electron
不可能片场8 天前
AI视频成片 帧间差分把拼接缝照出来
前端·electron
Noir热爱生活8 天前
deepseek harness,关于桌面版无法打开vscode修复方案
electron·deepseek