Skip to content

Commit 7609a2f

Browse files
committed
refactor: 更新Python版本并移除flet-audio依赖
FUCK
1 parent 96dc4db commit 7609a2f

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

.github/workflows/desktop-and-mobile-builds.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ env:
1919
# # https://flet.dev/docs/publish#versioning
2020
# BUILD_NUMBER: 1
2121
# BUILD_VERSION: 1.0.0
22-
PYTHON_VERSION: 3.12
22+
PYTHON_VERSION: 3.13
2323
FLUTTER_VERSION: 3.24.0
2424
KEYSTORE_FILE: /home/runner/work/PhiStore/PhiStore/html5syt.jks
2525
KEYSTORE_ALIAS: html5syt

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description = "PhiStore"
66
# requires-python = ">=3.8"
77
dependencies = [
88
"flet",
9-
"flet-audio"
9+
# "flet-audio"
1010
]
1111

1212

src/PhiControls.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ def chance_prize(prize_list):
119119

120120
def storage(
121121
page: ft.Page,
122-
key: str | None,
122+
key="",
123123
value=None,
124124
type="s",
125+
# TODO: 增加持久化存储
125126
mode="r",
126127
prefix="phistore_",
127128
):
128-
"""存储数据,默认使用 client_storage 存储,模式为读取,前缀为 phistore_
129+
"""存储数据,默认使用 session 存储,模式为读取,前缀为 phistore_
129130
Args:
130131
key (str): 键
131132
value (_type_): 值
@@ -134,9 +135,11 @@ def storage(
134135
prefix (str, optional): 前缀.
135136
"""
136137

137-
async def _storage(key, mode, value=None):
138+
async def _storage(key, mode, value=None) -> float:
138139
if mode == "w":
139140
await page.client_storage.set_async(key, value)
141+
elif mode == "r":
142+
return await page.client_storage.get_async(key)
140143
elif mode == "s":
141144
return await page.client_storage.contains_key_async(key)
142145

@@ -157,14 +160,15 @@ async def _storage(key, mode, value=None):
157160
print(f"[Log]{key}值为: {page.session.get(key)}")
158161
# elif type == "c":
159162
# if mode == "r":
160-
# if _storage(key, "s"):
161-
# return page.client_storage.get(key)
163+
# if page.client_storage.contains_key_async(key):
164+
# temp=await page.client_storage.get_async(key)
165+
# return temp
162166
# else:
163167
# raise LookupError("Key not found in client storage")
164168
# elif mode == "w":
165-
# _storage(key, "w", value)
169+
# page.client_storage.set_async(key, value)
166170
# elif mode == "d":
167-
# if _storage(key, "s"):
171+
# if page.client_storage.contains_key_async(key):
168172
# page.client_storage.remove(key)
169173
# else:
170174
# raise LookupError("Key not found in client storage")

src/main.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
import random
33
import flet as ft
4-
import flet_audio as ft_a
4+
# import flet_audio as ft_a
55
import PhiControls as Phi
66
import assets.default_json as default_json
77

@@ -52,8 +52,8 @@ def on_keyboard(e: ft.KeyboardEvent):
5252
page.theme = ft.Theme(font_family="Exo") # 默认应用字体
5353

5454
# 背景音乐
55-
audio1 = ft_a.Audio(
56-
src="Shop0.wav", autoplay=True, release_mode=ft_a.audio.ReleaseMode.LOOP
55+
audio1 = ft.Audio(
56+
src="Shop0.wav", autoplay=True, release_mode=ft.audio.ReleaseMode.LOOP
5757
)
5858
page.overlay.append(audio1)
5959

@@ -75,7 +75,8 @@ def on_keyboard(e: ft.KeyboardEvent):
7575
),
7676
actions=[
7777
ft.Button(
78-
"清空session和client_storage(危险!仅供调试)", on_click=lambda e: DEL
78+
"清空session和client_storage(危险!仅供调试)",
79+
on_click=lambda e: DEL(e, page),
7980
),
8081
ft.Button("确定"),
8182
],
@@ -179,9 +180,10 @@ def setting_on_submit(e, datashow, page=ft.Page):
179180
)
180181
page.close(setting)
181182

182-
def DEL(e):
183-
nonlocal page
183+
def DEL(e, page=ft.Page):
184+
nonlocal setting
184185
Phi.storage(page=page, type="DEL")
186+
page.close(setting)
185187

186188
# 页面组件树
187189
page.add(
@@ -271,6 +273,7 @@ def DEL(e):
271273
expand=True,
272274
)
273275
)
276+
# print("[Log]",Phi.storage(page=page, key="data"))
274277
Phi.PhiData.on_data_change(
275278
datashow, Phi.hum_convert(Phi.storage(page=page, key="data")), page=page
276279
)

0 commit comments

Comments
 (0)