Skip to content

Commit c56b93d

Browse files
chore: updated version to 0.3.0
1 parent 6eb9e78 commit c56b93d

4 files changed

Lines changed: 60 additions & 31 deletions

File tree

ClassWidgets/SDK/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
from typing import TYPE_CHECKING
66

7-
__version__ = '0.2.0'
7+
__version__ = '0.3.0'
88
__author__ = 'Class Widgets Official'
99

1010

ClassWidgets/SDK/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ You should debug and run plugins in Class Widgets 2.
88
from .plugin_base import CW2Plugin
99
from .config import ConfigBaseModel
1010
from .api import PluginAPI
11-
from .notification import NotificationProvider, NotificationLevel, NotificationData
11+
from .notification import NotificationProvider, NotificationLevel, NotificationData, NotificationProviderConfig
1212

1313
__version__: str
1414
__author__: str

ClassWidgets/SDK/notification.pyi

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from typing import Optional, Union, Any
1+
from typing import Optional, Union, Any, TYPE_CHECKING
22
from pathlib import Path
33
from enum import IntEnum
44
from pydantic import BaseModel
55

6-
from .api import QObject
7-
6+
# 为非检查时提供的抽象基类
7+
class QObject: ...
88

99
class NotificationLevel(IntEnum):
1010
"""
@@ -31,6 +31,15 @@ class NotificationData(BaseModel):
3131
use_system: bool = False
3232

3333

34+
class NotificationProviderConfig(BaseModel):
35+
"""
36+
通知提供者配置模型
37+
"""
38+
enabled: bool = True
39+
use_system_notify: bool = False
40+
use_app_notify: bool = True
41+
42+
3443
class NotificationProvider(QObject):
3544
"""
3645
通知提供者类
@@ -42,19 +51,21 @@ class NotificationProvider(QObject):
4251
name: str
4352
icon: Optional[str]
4453
use_system_notify: bool
45-
manager: Any
46-
54+
55+
# 初始化方法
4756
def __init__(
4857
self,
4958
id: str,
5059
name: str,
51-
icon: Optional[Union[str, Path]] = ...,
52-
use_system_notify: bool = ...,
53-
manager: Any = ...
60+
icon: Optional[Union[str, Path]] = None,
61+
use_system_notify: bool = False,
62+
manager: Any = None
5463
) -> None: ...
5564

56-
def get_config(self) -> Any: ...
65+
# 配置相关方法
66+
def get_config(self) -> NotificationProviderConfig: ...
5767

68+
# 推送通知方法
5869
def push(
5970
self,
6071
level: int,
@@ -67,6 +78,7 @@ class NotificationProvider(QObject):
6778

6879
__all__ = [
6980
'NotificationLevel',
70-
'NotificationData',
81+
'NotificationData',
82+
'NotificationProviderConfig',
7183
'NotificationProvider'
7284
]

ClassWidgets/SDK/plugin_base.pyi

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,69 @@
11
from typing import Dict, Any, Optional
22
from pathlib import Path
3-
3+
from enum import IntEnum
44
from pydantic import BaseModel
55

6-
from .api import PluginAPI, NotificationAPI, QObject
7-
from .notification import NotificationProvider
6+
# 为非检查时提供的抽象基类
7+
class QObject: ...
8+
9+
class Signal:
10+
def emit(self, *args) -> None:
11+
pass
12+
13+
from .api import PluginAPI
814

915

10-
class ConfigBaseModel(BaseModel): ...
16+
class ConfigBaseModel(BaseModel):
17+
"""
18+
插件配置模型的基类
19+
继承自Pydantic的BaseModel,提供配置数据验证和管理功能
20+
"""
21+
...
1122

1223

1324
# CW2Plugin
1425
class CW2Plugin(QObject):
1526
"""
16-
:param api: PluginAPI instance
27+
所有Class Widgets 2插件的基类
28+
29+
提供插件生命周期管理、API访问和插件注册功能
1730
"""
18-
PATH: Path
19-
meta: Dict[str, Any]
20-
pid: Optional[str]
21-
api: PluginAPI
31+
initialized: Signal
32+
33+
# 插件属性
34+
PATH: Path # 插件根目录路径
35+
meta: Dict[str, Any] # 插件元数据
36+
pid: Optional[str] # 插件ID
37+
api: PluginAPI # 插件API实例
2238

23-
def __init__(self, api: Any) -> None:
39+
def __init__(self, api: PluginAPI) -> None:
2440
"""
25-
Initialize the plugin.
26-
27-
:param api: PluginAPI instance for interacting with the host application
41+
初始化插件实例
42+
43+
:param api: PluginAPI实例,用于与主应用程序交互
2844
"""
2945
...
3046

3147
def _load_plugin_libs(self) -> None:
3248
"""
33-
Automatically adds the plugin's 'lib' subdirectory to sys.path.
34-
This is an internal method.
49+
自动将插件的'lib'子目录添加到sys.path
50+
这是一个内部方法
3551
"""
3652
...
3753

3854
def on_load(self) -> None:
3955
"""
40-
Called when the plugin is loaded.
41-
Registers the plugin with the backend bridge if meta.id exists.
56+
当插件被加载时调用
57+
如果存在meta.id,则向后端桥注册插件
4258
"""
4359
...
4460

4561
def on_unload(self) -> None:
4662
"""
47-
Called when the plugin is unloaded.
63+
当插件被卸载时调用
64+
插件应该在此方法中清理资源
4865
"""
4966
...
5067

5168

52-
__all__ = ['CW2Plugin']
69+
__all__ = ['CW2Plugin', 'ConfigBaseModel']

0 commit comments

Comments
 (0)