1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| import flet as ft from check import GetKey from webChick import webChick
def main(page: ft.Page): page.title = 'Points++' page.fonts = {"msyh": "C:/Windows/Fonts/msyh.ttc"} page.theme = ft.Theme(font_family="msyh") page.horizontal_alignment = ft.CrossAxisAlignment.CENTER page.scroll = ft.ScrollMode.ADAPTIVE
def close_dlg(e): dlg_modal.open = False page.update() def submit_dlg(e): '''关闭弹窗,更新输出框,准备处理网页''' dlg_modal.open = False lv.controls.append(ft.Text(f"准备处理,待处理数量为:"+str(max_num),text_align=ft.TextAlign.CENTER,color='#696969')) lv.controls.append(ft.Divider()) page.update() chick_pages()
def chick_pages(): '''创建webChick_robot,进行登录相关操作,同时输出日志至窗体''' webChick_robot = webChick() homePage_msg = webChick_robot.homePage() lv.controls.append(ft.Text(value=homePage_msg,text_align=ft.TextAlign.CENTER,color='#696969')) page.update() login_msg = webChick_robot.login() lv.controls.append(ft.Text(value=login_msg,text_align=ft.TextAlign.CENTER,color='#696969')) page.update() mainPage_msg = webChick_robot.mainPage() lv.controls.append(ft.Text(value=mainPage_msg,text_align=ft.TextAlign.CENTER,color='#696969')) lv.controls.append(ft.Divider()) page.update() '''逐篇处理文章''' for num in range(1,max_num+1): click_msg = webChick_robot.auto_click(num=num) lv.controls.append(ft.Text(value=click_msg,text_align=ft.TextAlign.CENTER,color='#696969')) if num < max_num: lv.controls.append(ft.Text(value='------------------------------',text_align=ft.TextAlign.CENTER,color='#90EE90')) page.update() lv.controls.append(ft.Divider()) lv.controls.append(ft.Text('处理完毕,此次共处理' + str(max_num) + '篇文章',text_align=ft.TextAlign.CENTER,color='#696969')) page.update() webChick_robot.close_web()
dlg_modal = ft.AlertDialog( modal=True, title=ft.Text("请注意:"), content=ft.Text("该软件运行时请勿操作鼠标和键盘,否则将影响软件运行。"), actions=[ ft.TextButton("确定", on_click=submit_dlg, key='yes'), ft.TextButton("取消", on_click=close_dlg, key='no'), ], actions_alignment=ft.MainAxisAlignment.END, )
def but_click(e): global max_num if key_code.value == GetKey.full_key: try: max_num = int(auto_num.value) page.dialog = dlg_modal dlg_modal.open = True page.update() except: lv.controls.append(ft.Text(f"数量输入错误,请输入整数。建议整数区间为:[1-300]",text_align=ft.TextAlign.CENTER,color='#A52A2A')) auto_num.value = '' page.update() else: lv.controls.append(ft.Text(f"密钥输入错误,请输入正确的密钥!",text_align=ft.TextAlign.CENTER,color='#A52A2A')) key_code.value = '' page.update() def help_close(e): help_modal.open = False page.update()
help_modal = ft.AlertDialog( modal=True, title=ft.Text("使用说明:"), content=ft.Text(" 1. 本软件依赖Edge浏览器,默认加载路径为:C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe \n 2. 填写密钥(密钥每月自动更新一次,请勿扩散使用)。\n 3. 填写数量(建议单次处理数量不要超过300篇)。 \n 4. 系统运行后会自动打开浏览器操作。若从浏览器中找到登录的cookie信息,软件会自动登录;若未从浏览器找到登录信息,你有30秒的时间完成登录(账号密码登录或扫码登录均可),登录成功即可,请勿再进行其他操作。 \n 5. 该软件运行时需使用屏幕界面,运行期间请勿操作鼠标和键盘(理论上可以继续操作浏览器以外的软件,但建议不要操作,可能会因某些关联影响导致软件不能预期工作)。\n\n -- 软件运行时,记得休息一下 (‾◡◝) --"), actions=[ ft.TextButton("确定", on_click=help_close), ], actions_alignment=ft.MainAxisAlignment.END, )
def help_click(e): page.dialog = help_modal help_modal.open = True page.update() key_code = ft.TextField(height=40,width=150,label='密钥', hint_text='请输入密钥', autofocus=True, text_size=13,label_style=ft.TextStyle(size=13),content_padding=7) auto_num = ft.TextField(height=40,width=80,label='数量', hint_text='整数',text_size=13,label_style=ft.TextStyle(size=13),content_padding=7) submit = ft.IconButton(icon = ft.icons.CHECK_CIRCLE, on_click=but_click,icon_color='#33a3dc') page.appbar = ft.AppBar( leading = ft.IconButton(icon = ft.icons.HELP_OUTLINED, on_click=help_click,icon_color='#33a3dc'), leading_width = 60, title = ft.Text("async def have_a_rest():",text_align=ft.TextAlign.CENTER,color='#228fbd',size=18), center_title = False, bgcolor = ft.colors.SECONDARY_CONTAINER, actions = [ ft.Container(content=key_code,margin=10), ft.Container(content=auto_num,margin=10), ft.Container(content=submit,margin=10) ], )
lv = ft.ListView( expand=True, spacing=2,padding=10,auto_scroll=True) page.add(ft.Container(content=lv,height=600))
if __name__ == '__main__': ft.app(target=main)
|