Skip to content

Commit

Permalink
feat: change to using Flet (#27)
Browse files Browse the repository at this point in the history
Co-authored-by: n0sense <[email protected]>
  • Loading branch information
Fatpandac and RX-105 authored Nov 24, 2022
1 parent 0395a1e commit 7836e1f
Show file tree
Hide file tree
Showing 21 changed files with 628 additions and 526 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ jobs:
pip3 install -r requirements.txt
- name: build app
run: |
pyinstaller -F -w fuck_cqooc.pyw
pyinstaller src/app.py -F -w --add-data "assets;assets" --icon metadata/WinIcon.png
- name: build package
run: |
cd dist && tar -zcvf fuckcqooc_win.tar.gz fuck_cqooc.exe
cd dist
ren app.exe fuckcqooc.exe
tar -zcvf fuckcqooc_win.tar.gz fuckcqooc.exe
- name: upload
uses: actions/upload-release-asset@v1
env:
Expand Down Expand Up @@ -70,16 +72,18 @@ jobs:
pip3 install -r requirements.txt
- name: build app
run: |
pyinstaller -F -w fuck_cqooc.pyw
pyinstaller src/app.py -F -w --add-data "assets:assets" --icon metadata/MacIcon.png
- name: build package
run: |
cd dist && tar -zcvf fuckcqooc_macos.tar.gz fuck_cqooc.app
cd dist
mv app.app fuckcqooc.app
tar -zcvf fuckcqooc_macos.tar.gz fuckcqooc.app
- name: upload
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GAYHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: dist/fuckcqooc_macos.tar.gz # 发布的压缩包名称
asset_name: fuckcqooc_${{ github.ref }}_macos_x86_64.tar.gz # 发布的压缩包名称
asset_name: fuckcqooc_${{ github.ref }}_macos.tar.gz # 发布的压缩包名称
asset_content_type: application/gzip
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ dmypy.json

# macos
.DS_Store

# Visual Studio Code Run/Debug configuration
.vscode/
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ verify_ssl = true
name = "pypi"

[packages]
ttkbootstrap = "*"
hackcqooc = "*"
flet = "*"
pillow = "*"

[dev-packages]
pre-commit = "*"
Expand Down
271 changes: 171 additions & 100 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<h1 align="center">fuck_cqooc</h1>
<h1 align="center">fuckcqooc</h1>

![GitHub](https://img.shields.io/github/license/Fatpandac/fuck_cqooc) ![GitHub all releases](https://img.shields.io/github/downloads/Fatpandac/fuck_cqooc/total) ![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/Fatpandac/fuck_cqooc?include_prereleases) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Fatpandac/fuck_cqooc/master.svg)](https://results.pre-commit.ci/latest/github/Fatpandac/fuck_cqooc/master)

![fuckcqooc GUI](/metadata/UI.png)

<details>
<summary>这是一个简单的 「cqooc」(http://www.cqooc.com) 刷课工具。</summary>

Expand Down
Binary file added assets/fonts/JetBrainsMono-Regular.ttf
Binary file not shown.
Binary file added assets/fonts/NotoSansSC-Regular.otf
Binary file not shown.
4 changes: 0 additions & 4 deletions fuck_cqooc.pyw

This file was deleted.

Binary file added metadata/MacIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added metadata/UI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added metadata/WinIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 18 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
-i https://pypi.org/simple
certifi==2022.9.24; python_version >= '3.6'
charset-normalizer==2.1.1; python_version >= '3.6'
hackcqooc==0.0.5
idna==3.4; python_version >= '3.5'
js2py==0.71
pillow==9.2.0; python_version >= '3.7'
beartype==0.11.0 ; python_full_version >= '3.7.0'
certifi==2022.9.24 ; python_version >= '3.6'
charset-normalizer==2.1.1 ; python_full_version >= '3.6.0'
flet==0.1.65
hackcqooc==0.0.8
idna==3.4 ; python_version >= '3.5'
js2py==0.74
oauthlib==3.2.2 ; python_version >= '3.6'
pillow==9.3.0
pyjsparser==2.7.1
pytz-deprecation-shim==0.1.0.post0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
requests==2.28.1; python_version >= '3.7' and python_version < '4'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
ttkbootstrap==1.9.0
tzdata==2022.4; python_version >= '3.6'
tzlocal==4.2; python_version >= '3.6'
urllib3==1.26.12; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5' and python_version < '4'
pytz-deprecation-shim==0.1.0.post0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
repath==0.9.0
requests==2.28.1 ; python_version >= '3.7' and python_version < '4'
six==1.16.0 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'
tzdata==2022.6 ; platform_system == 'Windows'
tzlocal==4.2 ; python_version >= '3.6'
urllib3==1.26.13 ; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'
watchdog==2.1.9 ; python_version >= '3.6'
websocket-client==1.4.2 ; python_version >= '3.7'
9 changes: 0 additions & 9 deletions setup.py

This file was deleted.

Empty file removed src/__init__.py
Empty file.
65 changes: 65 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
from loginView import login_view
from skipView import skip_view

import flet as ft
import tempfile
import os
import logging
from logging.handlers import RotatingFileHandler

folder_path = f"{tempfile.gettempdir()+os.sep}fuckcqooc"

if not os.path.exists(folder_path):
os.makedirs(folder_path)
else:
# Empty the folder
for file in os.listdir(folder_path):
os.remove(folder_path + os.sep + file)

log_location = f"{folder_path+os.sep}fuckcqooc.log"
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = RotatingFileHandler(
log_location, "a", maxBytes=1024 * 1024 * 5, backupCount=5
)
logger.addHandler(handler)
logging.info(f"Started logging to file {log_location}.")

font_family = {
"Noto Sans SC": "/fonts/NotoSansSC-Regular.otf",
"JetBrains Mono": "/fonts/JetBrainsMono-Regular.ttf",
}


def main(page: ft.Page):
logging.info("Init main page")

def on_route_change(e):
page.views.clear()
login_view(page)
if e.route == "/course":
skip_view(page)
page.update()

def view_pop():
page.views.pop()
top_view = page.views[-1]
page.go(top_view.route)

page.core = None
page.log_folder_path = folder_path
page.title = "Fuckcqooc"
page.vertical_alignment = "center"
page.horizontal_alignment = "center"
page.fonts = font_family
page.on_route_change = on_route_change
page.on_view_pop = view_pop
page.window_min_width = 800
page.window_width = 800
page.window_height = 600
page.window_min_height = 600
page.go(page.route)


ft.app(target=main, assets_dir="../assets")
12 changes: 12 additions & 0 deletions src/components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
import flet as ft


def show_snack_bar(page, text, color, selectable=False):
return page.show_snack_bar(
ft.SnackBar(
open=True,
content=ft.Text(text, selectable=selectable),
bgcolor=color,
)
)
Loading

0 comments on commit 7836e1f

Please sign in to comment.