Skip to content

Commit 32a21a9

Browse files
authored
Merge pull request #11 from LinJHS/dev
2 parents 75d750f + f2e5626 commit 32a21a9

9 files changed

Lines changed: 81 additions & 12 deletions

File tree

.github/workflows/publish.yml

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,25 @@ jobs:
4040
tags: ${{ steps.meta.outputs.tags }}
4141
labels: ${{ steps.meta.outputs.labels }}
4242

43-
publish-pypi:
43+
create-release:
4444
if: startsWith(github.ref, 'refs/tags/')
4545
runs-on: ubuntu-latest
46+
permissions:
47+
contents: write
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: Create GitHub Release
51+
uses: softprops/action-gh-release@v2
52+
with:
53+
generate_release_notes: true
54+
draft: false
55+
prerelease: false
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
59+
publish-pypi:
60+
needs: create-release
61+
runs-on: ubuntu-latest
4662
permissions:
4763
id-token: write
4864
contents: write
@@ -65,13 +81,40 @@ jobs:
6581
- name: Publish to PyPI
6682
uses: pypa/gh-action-pypi-publish@release/v1
6783

68-
- name: Create GitHub Release
84+
- name: Upload PyPI Assets to Release
6985
uses: softprops/action-gh-release@v2
7086
with:
7187
files: dist/*
72-
generate_release_notes: true
73-
draft: false
74-
prerelease: false
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
91+
build-windows-exe:
92+
needs: create-release
93+
runs-on: windows-latest
94+
permissions:
95+
contents: write
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Set up Python
100+
uses: actions/setup-python@v4
101+
with:
102+
python-version: '3.11'
103+
104+
- name: Install dependencies
105+
run: |
106+
python -m pip install --upgrade pip
107+
pip install -r requirements.txt
108+
pip install pyinstaller
109+
110+
- name: Build EXE with PyInstaller
111+
run: |
112+
pyinstaller --noconfirm --onefile --console --name "WinFolderManager" --add-data "manager/templates;manager/templates" --add-data "manager/static;manager/static" --icon "manager/static/favicon.ico" run.py
113+
114+
- name: Upload EXE to Release
115+
uses: softprops/action-gh-release@v2
116+
with:
117+
files: dist/WinFolderManager.exe
75118
env:
76119
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77120

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
recursive-include manager/templates *
2+
recursive-include manager/static *

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Win Folder Manager
2-
31
<div align="center">
42

3+
<img src="imgs/Logo-Text.jpg" width="100%" alt="Win Folder Manager">
4+
5+
<br>
6+
57
[![PyPI version](https://img.shields.io/pypi/v/win-folder-manager.svg?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/win-folder-manager/)
68
[![PyPI Downloads](https://img.shields.io/pypi/dm/win-folder-manager.svg?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/win-folder-manager/)
79
[![Docker Pulls](https://img.shields.io/docker/pulls/linjhs/win-folder-manager.svg?style=flat-square&logo=docker&logoColor=white)](https://hub.docker.com/r/linjhs/win-folder-manager)

README_EN.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Win Folder Manager
2-
31
<div align="center">
42

3+
<img src="imgs/Logo-Text.jpg" width="100%" alt="Win Folder Manager">
4+
5+
<br>
6+
57
[![PyPI version](https://img.shields.io/pypi/v/win-folder-manager.svg?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/win-folder-manager/)
68
[![PyPI Downloads](https://img.shields.io/pypi/dm/win-folder-manager.svg?style=flat-square&logo=pypi&logoColor=white)](https://pypi.org/project/win-folder-manager/)
79
[![Docker Pulls](https://img.shields.io/docker/pulls/linjhs/win-folder-manager.svg?style=flat-square&logo=docker&logoColor=white)](https://hub.docker.com/r/linjhs/win-folder-manager)

imgs/Logo-Text.jpg

336 KB
Loading

manager/app.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from flask import Flask, render_template, jsonify, request
66
from .logic import FolderManager
77

8+
import sys
9+
810
# Use APPDATA for persistent config storage
911
def get_config_dir():
1012
if os.name == 'nt':
@@ -24,10 +26,18 @@ def get_config_dir():
2426

2527
CONFIG_FILE = os.path.join(APPDATA_DIR, 'config.json')
2628

27-
# Templates are now inside the package
28-
TEMPLATE_FOLDER = os.path.join(os.path.dirname(__file__), 'templates')
29+
# Define paths for templates and static files
30+
if getattr(sys, 'frozen', False):
31+
# Running in PyInstaller bundle
32+
BASE_DIR = os.path.join(sys._MEIPASS, 'manager')
33+
else:
34+
# Running in normal Python environment
35+
BASE_DIR = os.path.dirname(__file__)
36+
37+
TEMPLATE_FOLDER = os.path.join(BASE_DIR, 'templates')
38+
STATIC_FOLDER = os.path.join(BASE_DIR, 'static')
2939

30-
app = Flask(__name__, template_folder=TEMPLATE_FOLDER)
40+
app = Flask(__name__, template_folder=TEMPLATE_FOLDER, static_folder=STATIC_FOLDER)
3141

3242
# 初始化逻辑类
3343
folder_logic = FolderManager(CONFIG_FILE)
@@ -74,6 +84,12 @@ def select_folder_dialog():
7484
# Create a hidden root window
7585
root = tk.Tk()
7686
root.withdraw() # Hide the main window
87+
88+
# Set custom icon if exists
89+
icon_path = os.path.join(STATIC_FOLDER, 'favicon.ico')
90+
if os.path.exists(icon_path):
91+
root.iconbitmap(icon_path)
92+
7793
root.attributes('-topmost', True) # Make it appear on top
7894

7995
# Open directory picker

manager/static/favicon.ico

60 KB
Binary file not shown.

manager/templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Win Folder Manager</title>
7+
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
78
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
89
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
910
<style>

run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from manager.app import main
2+
3+
if __name__ == '__main__':
4+
main()

0 commit comments

Comments
 (0)