feat: 添加 windows 下针对选择模式的提示

This commit is contained in:
RockChinQ 2024-07-03 17:44:10 +08:00
parent 61e2af4a14
commit 05527cfc01
2 changed files with 36 additions and 9 deletions

View File

@ -0,0 +1,21 @@
from __future__ import annotations
import typing
import os
import sys
import logging
from .. import note, app
@note.note_class("SelectionModeOnWindows", 2)
class SelectionModeOnWindows(note.LaunchNote):
"""Windows 上的选择模式提示信息
"""
async def need_show(self) -> bool:
return os.name == 'nt'
async def yield_note(self) -> typing.AsyncGenerator[typing.Tuple[str, int], None]:
yield """您正在使用 Windows 系统,若窗口左上角显示处于”选择“模式,程序将被暂停运行,此时请右键窗口中空白区域退出选择模式。""", logging.INFO

View File

@ -1,7 +1,7 @@
from __future__ import annotations from __future__ import annotations
from .. import stage, app, note from .. import stage, app, note
from ..notes import n001_classic_msgs from ..notes import n001_classic_msgs, n002_selection_mode_on_windows
@stage.stage_class("ShowNotesStage") @stage.stage_class("ShowNotesStage")
@ -11,12 +11,18 @@ class ShowNotesStage(stage.BootingStage):
async def run(self, ap: app.Application): async def run(self, ap: app.Application):
# 排序
note.preregistered_notes.sort(key=lambda x: x.number)
for note_cls in note.preregistered_notes: for note_cls in note.preregistered_notes:
note_inst = note_cls(ap) try:
if await note_inst.need_show(): note_inst = note_cls(ap)
async for ret in note_inst.yield_note(): if await note_inst.need_show():
if not ret: async for ret in note_inst.yield_note():
continue if not ret:
msg, level = ret continue
if msg: msg, level = ret
ap.logger.log(level, msg) if msg:
ap.logger.log(level, msg)
except Exception as e:
continue