mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 03:32:33 +08:00
feat: 添加 windows 下针对选择模式的提示
This commit is contained in:
parent
61e2af4a14
commit
05527cfc01
21
pkg/core/notes/n002_selection_mode_on_windows.py
Normal file
21
pkg/core/notes/n002_selection_mode_on_windows.py
Normal 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
|
|
@ -1,7 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
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")
|
||||
|
@ -11,12 +11,18 @@ class ShowNotesStage(stage.BootingStage):
|
|||
|
||||
async def run(self, ap: app.Application):
|
||||
|
||||
# 排序
|
||||
note.preregistered_notes.sort(key=lambda x: x.number)
|
||||
|
||||
for note_cls in note.preregistered_notes:
|
||||
note_inst = note_cls(ap)
|
||||
if await note_inst.need_show():
|
||||
async for ret in note_inst.yield_note():
|
||||
if not ret:
|
||||
continue
|
||||
msg, level = ret
|
||||
if msg:
|
||||
ap.logger.log(level, msg)
|
||||
try:
|
||||
note_inst = note_cls(ap)
|
||||
if await note_inst.need_show():
|
||||
async for ret in note_inst.yield_note():
|
||||
if not ret:
|
||||
continue
|
||||
msg, level = ret
|
||||
if msg:
|
||||
ap.logger.log(level, msg)
|
||||
except Exception as e:
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue
Block a user