8f7f082c3d
- 重构项目目录结构,将功能模块移至 modules/ 目录 - 创建平台同步基础架构,包括发布器基类和 GitHub 发布器 - 新增 UI 状态管理模块 (modules/ui/state.py) 统一管理会话状态 - 更新依赖配置,添加平台同步所需依赖 (httpx, pyperclip) - 整理文档结构,将所有文档分类移至 docs/ 目录 - 添加 .cursorrules 文件定义项目开发规范 - 清理根目录重复文件,保持项目结构整洁
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
"""
|
|
平台发布器基类
|
|
"""
|
|
from abc import ABC, abstractmethod
|
|
from typing import Dict, Any, Optional
|
|
|
|
|
|
class BasePublisher(ABC):
|
|
"""发布器基类"""
|
|
|
|
def __init__(self, platform: str, account_config: Dict[str, Any]):
|
|
self.platform = platform
|
|
self.account_config = account_config
|
|
|
|
@abstractmethod
|
|
def publish(self, content: str, title: str, **kwargs) -> Dict[str, Any]:
|
|
"""
|
|
发布内容
|
|
|
|
Args:
|
|
content: 文章内容
|
|
title: 文章标题
|
|
**kwargs: 其他参数(标签、图片等)
|
|
|
|
Returns:
|
|
{
|
|
'success': bool,
|
|
'publish_url': str,
|
|
'publish_id': str,
|
|
'error': str
|
|
}
|
|
"""
|
|
pass
|
|
|
|
@abstractmethod
|
|
def validate_account(self) -> bool:
|
|
"""验证账号是否有效"""
|
|
pass
|
|
|
|
def upload_image(self, image_path: str) -> Optional[str]:
|
|
"""上传图片,返回图片URL(可选实现)"""
|
|
return None
|
|
|
|
def refresh_token_if_needed(self) -> bool:
|
|
"""刷新token(如果需要,可选实现)"""
|
|
return True
|