@@ -154,7 +154,7 @@ async def storage(
154
154
page .session .remove (key )
155
155
else :
156
156
raise LookupError ("Key not found in session storage" )
157
- print (f"[log-" , datetime .datetime .now (), " ]{key}值为: {page.session.get(key)}" )
157
+ print (f"[log-{ datetime .datetime .now ()} ]{ key } 值为: { page .session .get (key )} " )
158
158
elif type == "c" :
159
159
if mode == "r" :
160
160
if await page .client_storage .contains_key_async (key ):
@@ -169,15 +169,16 @@ async def storage(
169
169
page .client_storage .remove (key )
170
170
else :
171
171
raise LookupError ("Key not found in client storage" )
172
+ print (f"[log-{ datetime .datetime .now ()} ]{ key } 值为: { page .session .get (key )} " )
172
173
elif type == "DEL" :
173
174
await page .client_storage .clear_async ()
174
175
page .session .clear ()
175
176
176
177
177
- def play_key_sound (page : ft .Page ):
178
+ async def play_key_sound (page : ft .Page ):
178
179
"""播放按键声音"""
179
180
# 背景音乐
180
- if storage (page = page , key = "is_load_finish" ,type = "s" ):
181
+ if await storage (page = page , key = "is_load_finish" ,type = "s" ):
181
182
try :
182
183
import flet_audio as ft_a
183
184
@@ -196,7 +197,7 @@ class PhiBack(ft.Stack):
196
197
ft (_type_): _description_
197
198
"""
198
199
199
- def __init__ (self , on_click = None , n = 1 ):
200
+ def __init__ (self , on_click = None ,on_long_press = None , n = 1 ):
200
201
super ().__init__ ()
201
202
self .controls = [
202
203
ft .Container (
@@ -232,6 +233,7 @@ def __init__(self, on_click=None, n=1):
232
233
),
233
234
padding = 0 ,
234
235
on_click = on_click ,
236
+ on_long_press = on_long_press ,
235
237
),
236
238
ft .Container (
237
239
ft .Image (src = "back.svg" ),
@@ -514,13 +516,13 @@ async def on_click(
514
516
detailText .value += textTemp
515
517
page .update ()
516
518
await asyncio .sleep (0.05 )
517
- if multi :
518
- await asyncio .sleep (0.25 )
519
+ # if multi:
520
+ # await asyncio.sleep(0.25)
519
521
elif await storage (page = page , key = "data" ) < datadelta :
520
522
self .nodata = True
521
523
self .controls [0 ].visible = not self .controls [0 ].visible # ?图
522
524
print ("[log-" , datetime .datetime .now (), "]余额不足" )
523
- # TODO: 前端日志输出失效,待修复
525
+ # 余额不足提示
524
526
page .snack_bar = ft .SnackBar (ft .Text ("余额不足" ))
525
527
page .snack_bar .open = True
526
528
page .update ()
@@ -684,14 +686,14 @@ class PhiStoreNav(ft.Stack):
684
686
"""_summary_: `PhiStore` 导航栏
685
687
686
688
Args:
687
- ft (_type_ ): _description_
689
+ on_click (list, optional ): 导航栏点击事件列表,用字符串包裹事件回调,禁止使用双引号. Defaults to [].
688
690
"""
689
691
690
692
def __init__ (
691
693
self ,
692
694
page : ft .Page ,
693
695
n = 1 ,
694
- on_click = [print (" click" ), print (" click2" ), print (" click3" ), print (" click4" ) ],
696
+ on_click = [" print(' click')" , " print(' click2')" , " print(' click3')" , " print(' click4')" ],
695
697
lock = False ,
696
698
):
697
699
super ().__init__ ()
@@ -816,8 +818,8 @@ def __init__(
816
818
),
817
819
]
818
820
819
- def on_click (self , e ):
820
- if storage (page = self .page , key = "is_load_finish" ):
821
+ async def on_click (self , e ):
822
+ if await storage (page = self .page , key = "is_load_finish" , type = "s " ):
821
823
play_key_sound (self .page )
822
824
self .controls [1 ].controls [0 ].content .controls [0 ].offset = (
823
825
ft .transform .Offset (
@@ -826,7 +828,7 @@ def on_click(self, e):
826
828
)
827
829
self .page .update ()
828
830
if self .on_click_list != [] and self .on_click_list is not None :
829
- for i , action in enumerate ( self .on_click_list ):
831
+ for i in range ( 0 , len ( self .on_click_list ) - 1 ):
830
832
if e .control .data [- 1 ] == str (i + 1 ):
831
833
print (
832
834
"[log-" ,
@@ -835,4 +837,5 @@ def on_click(self, e):
835
837
i + 1 ,
836
838
"个导航栏动作" ,
837
839
)
838
- # action
840
+ print ("[log-" , datetime .datetime .now (), "]" , self .on_click_list )
841
+ exec (self .on_click_list [i ])
0 commit comments