准备发布新产品

This commit is contained in:
iniwap
2025-11-24 17:25:54 +08:00
parent a0cc039ebf
commit 33fa3bb338
8 changed files with 84 additions and 51 deletions
+1 -1
View File
@@ -184,7 +184,7 @@ uv pip install -r requirements.txt
```
3. 配置 `config.yaml`、`aiforge.toml`*微信公众号AppID/AppSecret、大模型提供商的API KEY*
4. 运行:
- 有UI界面:`python .\main.py -d` (**推荐**)
- 有UI界面:`python .\main.py` (**推荐**)
- 无UI界面:`python -m src.ai_write_x.crew_main` (**不支持文章、模板、配图管理**)
### 软件模式
+27 -39
View File
@@ -1,71 +1,59 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import platform
import multiprocessing
import sys
import os
import ctypes
# 设置环境变量
os.environ["PYTHONIOENCODING"] = "utf-8"
from aiforge import AIForgeEngine # noqa
def is_admin():
"""检查是否具有管理员权限(跨平台)"""
try:
if platform.system() == "Windows":
return ctypes.windll.shell32.IsUserAnAdmin()
elif platform.system() == "Darwin": # macOS
return True
elif platform.system() == "Linux":
return os.getuid() == 0
else:
return True
except Exception:
return False
# 帮助 PyInstaller 检测依赖 (永远不会执行)
if False:
import fastapi # noqa
import uvicorn # noqa
import webview # noqa
import jinja2 # noqa
import pystray # noqa
import yaml # noqa
import tomlkit # noqa
import peewee # noqa
from playhouse.sqlite_ext import SqliteExtDatabase # noqa
from src.ai_write_x.web import webview_gui # noqa
from src.ai_write_x.web import app # noqa
from src.ai_write_x.config import config # noqa
from src.ai_write_x import crew_main # noqa
import bs4 # noqa
import requests # noqa
from PIL import Image # noqa
import markdown # noqa
from crewai import Agent, Crew, Process, Task # noqa
from crewai.project import CrewBase, agent, crew, task # noqa
import chromadb # noqa
import onnxruntime # noqa
from rich.console import Console # noqa
def run():
"""启动GUI应用程序"""
try:
# 调用授权模块接口
from src.ai_write_x.license import check_license_and_start
check_license_and_start()
except KeyboardInterrupt:
sys.exit(0)
except Exception as e:
print(f"启动失败: {str(e)}")
def admin_run():
"""以管理员权限运行(跨平台)"""
if platform.system() == "Windows":
if is_admin():
run()
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 0)
else:
run()
except Exception:
raise
if __name__ == "__main__":
multiprocessing.freeze_support()
multiprocessing.set_start_method("spawn", force=True)
# 检查是否为AIForge子进程,传递执行环境
if AIForgeEngine.handle_sandbox_subprocess(
globals_dict=globals().copy(), sys_path=sys.path.copy()
):
sys.exit(0)
else:
# 正常启动逻辑
if len(sys.argv) > 1:
if sys.argv[1] == "-d":
run()
else:
admin_run()
run()
+8 -3
View File
@@ -111,16 +111,21 @@ class PathManager:
"""动态获取所有分类文件夹名称"""
template_dir = str(PathManager.get_template_dir())
categories = []
excluded_dirs = {"components", "__pycache__", ".git"}
# 添加默认分类(确保存在)
default_categories = list(default_template_categories.values()) # 使用中文名
# 添加默认分类
default_categories = list(default_template_categories.values())
categories.extend(default_categories)
# 扫描实际存在的文件夹
if os.path.exists(template_dir):
for item in os.listdir(template_dir):
item_path = os.path.join(template_dir, item)
if os.path.isdir(item_path) and item not in categories:
if (
os.path.isdir(item_path)
and item not in categories
and item not in excluded_dirs
):
categories.append(item)
return sorted(categories)
+4 -1
View File
@@ -53,8 +53,11 @@ async def list_categories():
template_dir = PathManager.get_template_dir()
categories = []
# 排除的目录名称
excluded_dirs = {"components", "__pycache__", ".git"}
for item in template_dir.iterdir():
if item.is_dir():
if item.is_dir() and item.name not in excluded_dirs:
template_count = len(list(item.glob("*.html")))
categories.append(
{"name": item.name, "path": str(item), "template_count": template_count}
+7 -1
View File
@@ -16,6 +16,7 @@ import uvicorn
from src.ai_write_x.utils.path_manager import PathManager
from src.ai_write_x.config.config import Config
from src.ai_write_x.utils import utils
# 导入状态管理
from .state import app_state
@@ -71,7 +72,12 @@ app = FastAPI(
)
# 获取Web模块路径
web_path = Path(__file__).parent
# 获取Web模块路径
if utils.get_is_release_ver():
web_path = Path(utils.get_res_path("web"))
else:
web_path = Path(__file__).parent
static_path = web_path / "static"
templates_path = web_path / "templates"
@@ -69,6 +69,34 @@
font-weight: 500;
}
.footer-brand {
font-size: 13px;
font-weight: 500;
color: var(--text-secondary);
display: flex;
align-items: center;
gap: 8px;
}
.version-text {
font-weight: 500;
color: var(--text-secondary);
}
.copyright-text {
font-size: 11px;
opacity: 0.7;
font-weight: 400;
}
.footer-brand-link:hover .version-text {
color: var(--primary-color);
}
.footer-brand-link:hover .copyright-text {
opacity: 1;
}
@keyframes marquee-scroll {
0% {
transform: translateX(var(--start-pos, 100%));
@@ -197,7 +197,7 @@
width: 100%;
min-height: 0;
height: 90px;
padding: 12px 20px;
padding: 12px 16px;
font-size: 18px;
line-height: 1.2;
border: none;
@@ -207,7 +207,7 @@
resize: none;
font-family: inherit;
transition: all 0.2s ease;
}
}
.topic-input:focus {
outline: none;
@@ -754,7 +754,7 @@
.topic-input {
height: 80px;
padding: 12px 20px;
padding: 12px 16px;
font-size: 16px;
}
@@ -787,7 +787,7 @@
.topic-input {
height: 72px;
padding: 8px 16px;
padding: 8px 12px;
font-size: 14px;
}
@@ -2,8 +2,11 @@
<!-- 左侧固定信息 -->
<div class="footer-left">
<a href="https://github.com/iniwap/AIWriteX" target="_blank" class="footer-brand-link">
<span class="footer-brand">当前版本 v2.3.0</span>
</a>
<span class="footer-brand">
<span class="version-text">v2.3.0</span>
<span class="copyright-text">© 2025 墨智工坊</span>
</span>
</a>
</div>
<!-- 右侧走马灯区域 -->