Gitea 桌面客户端:pywebview 封装自托管仓库

This commit is contained in:
hanfuit committed 2026-11-04 19:04:11 +08:00
commit 36155b5ae9
4 files changed
+125

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
# 打包产物(不进仓库)
build/
dist/
*.spec.bak
# Python 缓存
__pycache__/
*.pyc
*.pyo
# 虚拟环境
venv/
.venv/
# IDE
.vscode/
.idea/
+45
View File
@@ -0,0 +1,45 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_all
datas = []
binaries = []
hiddenimports = ['clr_loader', 'pythonnet']
tmp_ret = collect_all('webview')
datas += tmp_ret[0]; binaries += tmp_ret[1]; hiddenimports += tmp_ret[2]
a = Analysis(
['main.py'],
pathex=[],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='Gitea客户端',
icon=None,
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
+37
View File
@@ -0,0 +1,37 @@
# Gitea 客户端
把自托管 Gitea(`https://git.hanfuit.com`)封装成 Windows 桌面客户端。
## 功能
- 独立窗口应用(无浏览器地址栏/标签栏)
- 直接加载自托管 Gitea 仓库页面
- 窗口标题「灵宝仙尊代码仓库」,默认 1280×800
## 技术栈
- Python + pywebview(桌面窗口)
- PyInstaller(打包 exe)
## 使用
双击 `dist/Gitea客户端.exe` 即可运行。
## 自定义
修改 `main.py` 顶部的变量:
```python
GITEA_URL = "https://git.hanfuit.com" # 仓库地址
WINDOW_TITLE = "灵宝仙尊代码仓库" # 窗口标题
WIDTH = 1280 # 窗口宽度
HEIGHT = 800 # 窗口高度
```
## 重新打包
```bash
python -m PyInstaller --noconfirm --clean "Gitea客户端.spec"
```
产物在 `dist/Gitea客户端.exe`。
+26
View File
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""Gitea 桌面客户端:把 https://git.hanfuit.com 包成独立窗口应用。"""
import webview
GITEA_URL = "https://git.hanfuit.com"
WINDOW_TITLE = "灵宝仙尊代码仓库"
WIDTH = 1280
HEIGHT = 800
def main():
webview.create_window(
title=WINDOW_TITLE,
url=GITEA_URL,
width=WIDTH,
height=HEIGHT,
min_size=(900, 600),
resizable=True,
fullscreen=False,
)
webview.start()
if __name__ == "__main__":
main()