构建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报错解决记录

相关推荐
一拳不是超人1 天前
Electron主窗口弹框被WebContentView遮挡?独立WebContentView弹框方案详解!
前端·javascript·electron
柯南95275 天前
Electron 无边框窗口拖拽实现
vue.js·electron
卸任5 天前
Windows判断是笔记本还是台式
前端·react.js·electron
一拳不是超人5 天前
Electron 实战全解析:基于 WebContentView 的多视图管理系统
前端·javascript·electron
之歆6 天前
Vue3 + Vite2.0 全栈开发实践:从零到一构建通用后台管理系统-上
vue3·vite2.0
之歆7 天前
Vue3 + Vite2.0 全栈开发实践:从零到一构建通用后台管理系统-下
javascript·vue.js·vue3
麦麦大数据8 天前
M004_基于Langchain+RAG的银行智能客服系统设计与开发
typescript·langchain·flask·vue3·faiss·rag
lpfasd12310 天前
Tauri vs Electron:高质量Word/PDF导出效果深度对比
electron·pdf·word
哆啦A梦158810 天前
Vue3魔法手册 作者 张天禹 012_路由_(一)
前端·typescript·vue3
卸任10 天前
Electron判断是内置摄像头还是接摄像头
前端·react.js·electron