Skip to content

Commit

Permalink
Feat: exist
Browse files Browse the repository at this point in the history
  • Loading branch information
moesnow committed Nov 30, 2024
1 parent f17c5e4 commit bcdb717
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
20 changes: 17 additions & 3 deletions app/card/samplecardview1.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, icon, title, action, parent=None):
self.titleLabel.setObjectName('titleLabel')
# self.contentLabel.setObjectName('contentLabel')

def showBottomTeachingTip(self):
def showSuccessTip(self):
if not cfg.get_value(base64.b64decode("YXV0b191cGRhdGU=").decode("utf-8")):
disclaimer(self)
TeachingTip.create(
Expand All @@ -68,16 +68,29 @@ def showBottomTeachingTip(self):
parent=self
)

def showErrorTip(self, e):
TeachingTip.create(
target=self.iconWidget,
icon=InfoBarIcon.ERROR,
title='执行出错',
content=str(e),
isClosable=False,
tailPosition=TeachingTipTailPosition.BOTTOM,
duration=5000,
parent=self
)

def createMenu(self, pos):
menu = RoundMenu(parent=self)

def create_triggered_function(task):
def triggered_function():
self.showBottomTeachingTip()
try:
task()
self.showSuccessTip()
except Exception as e:
log.warning(f"执行失败:{e}")
self.showErrorTip(e)
return triggered_function

for index, (key, value) in enumerate(self.action.items()):
Expand All @@ -90,11 +103,12 @@ def triggered_function():
def mouseReleaseEvent(self, e):
super().mouseReleaseEvent(e)
if callable(self.action):
self.showBottomTeachingTip()
try:
self.action()
self.showSuccessTip()
except Exception as e:
log.warning(f"执行失败:{e}")
self.showErrorTip(e)
elif isinstance(self.action, dict):
self.createMenu(e.globalPos())

Expand Down
1 change: 1 addition & 0 deletions assets/docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- 循环模式每次启动前会重新加载配置文件
- 增加 “在多显示器上进行截屏” 选项(设置—杂项) [#392](https://github.com/moesnow/March7thAssistant/pull/392)
- 支持自动获取通过米哈游启动器安装游戏的路径
- 优化主程序缺失后的报错信息

### 修复
- “日常任务” 会在每次启动时被错误清空
Expand Down
5 changes: 5 additions & 0 deletions tasks/base/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def execute_command_in_new_environment(command, use_windows_terminal=False):
"""
在新的环境中执行给定的命令。
"""
if getattr(sys, 'frozen', False):
if not os.path.exists("./March7th Assistant.exe"):
exception = Exception("未找到可执行文件:March7th Assistant.exe,\n请将`小助手文件夹`加入杀毒软件排除项/信任区后,\n使用 March7th Updater.exe 更新或手动更新一次")
raise exception

executable_path = os.path.abspath("./March7th Assistant.exe") if getattr(sys, 'frozen', False) else sys.executable
main_script = [] if getattr(sys, 'frozen', False) else ["main.py"]

Expand Down

0 comments on commit bcdb717

Please sign in to comment.