介绍
Pywebview是使用flask作为后端、webview作为前端的客户端软件开发工具,前端可按实际情况选择html或者vue、react一类的开发语言。 前端和后端的数据交互提供了两种方式,分别为api接口和js bridge。
前端资源
将前端打包的资源,index.html文件放于 templates 目录下,其余文件放在 static 目录下。 客户端打开后首页直接渲染index.html
配置static目录的静态文件伺服:
app = Flask(__name__, static_url_path='/static', static_folder='static', template_folder='./templates')
前端打包时配置文件的路由前缀为static,以vue3+vite为例:
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
// 路由前缀
base: "/static"
})