【Electron】使用 Electron + Vue + Antd + Python 构建桌面程序
写在前面 也算是个记录吧,以免以后想写桌面程序又要走一遍弯路。这玩意不难,只是也有些坑,会耗些时间。 前端真没什么好说的,搞框架、搞设计的人很强,但调包这件事,人人都会干。 搭建前端 创建 vue 项目 yarn global add @vue/cli vue create electron-vue 参考:https://cli.vuejs.org/zh/guide/installation.html。 引入 electron 有现成的不用是…… cd electron-vue vue add electron-builder 参考:https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/#installation。 没事儿不要自己瞎折腾,有时候遇上一些奇怪的报错,作为后端开发党,很难解决。 试一试 yarn electron:serve 引入 Antd Vue yarn add ant-design-vue 参考:https://www.antdv.com/docs/vue/getting-started-cn。 这里如果使用 npm 进行安装 npm i --save ant-design-vue,就会报错。——咱也不懂,咱也懒得看。 修改 src/main.js 如下: import { createApp } from 'vue' import App from './App.vue' import Antd from 'ant-design-vue' import 'ant-design-vue/dist/antd.css' createApp(App).use(Antd).mount('#app') 修改 src/components/HelloWorld.vue 如下: <script setup> import {ref} from "vue"; const content = ref('hello electron') function click() { content.value = 'hello vue' } </script> <template> <a-button type="primary" @click="click">click me</a-button> <a-typography-paragraph>{{ content }}</a-typography-paragraph> </template> 搭建后端 后端用什么都行,go、python 都可以。 ...