commit 36155b5ae98b612641922e897455e0690d436e1d Author: 灵宝仙尊 Date: Wed Nov 4 19:04:11 2026 +0800 Gitea 桌面客户端:pywebview 封装自托管仓库 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33a32ad --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# 打包产物(不进仓库) +build/ +dist/ +*.spec.bak + +# Python 缓存 +__pycache__/ +*.pyc +*.pyo + +# 虚拟环境 +venv/ +.venv/ + +# IDE +.vscode/ +.idea/ diff --git a/Gitea客户端.spec b/Gitea客户端.spec new file mode 100644 index 0000000..e40c80d --- /dev/null +++ b/Gitea客户端.spec @@ -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, +) diff --git a/README.md b/README.md new file mode 100644 index 0000000..22c6112 --- /dev/null +++ b/README.md @@ -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`。 diff --git a/main.py b/main.py new file mode 100644 index 0000000..abece27 --- /dev/null +++ b/main.py @@ -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()