Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
# Byte-compiled / optimized / DLL files
# 字节码、优化文件和 DLL 文件
__pycache__/
*.py[cod]
*$py.class

# C extensions
# C 扩展
*.so

# Distribution / packaging
# 分发与打包
build/
dist/
eggs/
*.egg-info/
.eggs/

# Installer logs
# 安装程序日志
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# 单元测试与覆盖率报告
.pytest_cache/
coverage/
.coverage
htmlcov/

# Virtual environments
# 虚拟环境
venv/
env/
.venv/
ENV/
env.bak/

# IDE/editor files
# IDE 与编辑器文件
.vscode/
.idea/
*.sublime-workspace
*.sublime-project
.github/prompts/*

# OS files
# 操作系统文件
.DS_Store
Thumbs.db

# Logs and local runtime files
# 日志与本地运行时文件
*.log
*.pid

# PyInstaller
*.manifest
*.spec

# Local settings and secrets
# 本地设置与敏感信息
local_settings.py
secrets.yml
*.pem
*.key

# Data files
# 数据文件
*.sqlite3
*.db
data/plugin_media/
Expand All @@ -64,34 +64,34 @@ data/skill_packages/
# Jupyter
.ipynb_checkpoints

# Node / frontend
# Node 与前端
node_modules/
npm-debug.log
frontend/node_modules/
frontend/dist/

# Frontend build output (generated by `npm run build`)
# 前端构建产物(由 `npm run build` 生成)
src/plugin_market_backend/static/assets/
src/plugin_market_backend/static/font-licenses/
src/plugin_market_backend/static/index.html

# Coverage and reports
# 覆盖率与报告
reports/

# Ignore compiled binaries
# 忽略已编译的二进制文件
*.exe
*.dll
*.so

# Ignore temporary files
# 忽略临时文件
*.tmp
~*

# Ignore build artifacts from poetry/uv if any
# 忽略 poetry/uv 可能生成的构建产物
.venv/
poetry.lock

# Project-specific
# 项目专用规则
/.pytest_cache/
/test/__pycache__/

Expand Down
2 changes: 1 addition & 1 deletion BACKEND_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Authorization: Bearer <token>
{
"error": {
"code": "ERROR_CODE",
"message": "Human readable message",
"message": "可供用户阅读的错误消息",
"details": {}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Stage 1: Build frontend
# 第一阶段:构建前端
FROM node:22-slim AS frontend-build

WORKDIR /frontend
Expand All @@ -9,7 +9,7 @@ RUN npm ci
COPY frontend/ ./
RUN npm run build

# Stage 2: Python backend
# 第二阶段:Python 后端
FROM python:3.12-slim

WORKDIR /app
Expand All @@ -20,7 +20,7 @@ COPY pyproject.toml uv.lock README.md alembic.ini ./
COPY migrations ./migrations
COPY src ./src

# Copy frontend build output into backend static directory
# 将前端构建产物复制到后端静态文件目录
COPY --from=frontend-build /src/plugin_market_backend/static/ ./src/plugin_market_backend/static/

RUN uv sync --frozen --no-dev
Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ docker compose up --build

- `postgres` 仅在 Docker 网络内暴露,不直接开放到公网。
- `api` 仅绑定宿主机 `127.0.0.1:8787`,用于给 Nginx、Caddy 等反向代理转发。
- 反向代理再把公网域名,例如 `https://market.mofox-sama.com`,转发到 `http://127.0.0.1:8787`。
- 反向代理再把公网域名,例如 `https://market.mofox.chat`,转发到 `http://127.0.0.1:8787`。

Skill 存储说明:

Expand All @@ -94,25 +94,25 @@ docker compose logs -f api

如果你要通过域名访问服务,至少需要:

- 将 `market.mofox-sama.com` 的 DNS A 记录指向部署服务器公网 IP。
- 将 `PLUGIN_MARKET_GITHUB_OAUTH_REDIRECT_URI` 改为 `https://market.mofox-sama.com/api/v1/auth/github/callback`。
- 将 `market.mofox.chat` 的 DNS A 记录指向部署服务器公网 IP。
- 将 `PLUGIN_MARKET_GITHUB_OAUTH_REDIRECT_URI` 改为 `https://market.mofox.chat/api/v1/auth/github/callback`。
- 在反向代理中把域名转发到 `127.0.0.1:8787`。

Nginx 反代示例:

```nginx
server {
listen 80;
server_name market.mofox-sama.com;
server_name market.mofox.chat;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl http2;
server_name market.mofox-sama.com;
server_name market.mofox.chat;

ssl_certificate /etc/letsencrypt/live/market.mofox-sama.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/market.mofox-sama.com/privkey.pem;
ssl_certificate /etc/letsencrypt/live/market.mofox.chat/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/market.mofox.chat/privkey.pem;

location / {
proxy_pass http://127.0.0.1:8787;
Expand Down Expand Up @@ -153,13 +153,18 @@ PLUGIN_MARKET_DATABASE_URL=postgresql+asyncpg://plugin_market:plugin_market@post

公共查询接口不需要认证。

浏览器用户只能通过 GitHub OAuth 登录。创建 GitHub OAuth App 时,callback URL 设置为:
浏览器用户只能通过 GitHub OAuth 登录。生产环境创建 GitHub OAuth App 时设置为:

- Homepage URL:`https://market.mofox.chat`
- Authorization callback URL:`https://market.mofox.chat/api/v1/auth/github/callback`

本地开发时可将 `PLUGIN_MARKET_GITHUB_OAUTH_REDIRECT_URI` 改为:

```text
http://127.0.0.1:8787/api/v1/auth/github/callback
```

生产环境应改成你的公网域名,并把管理员 GitHub 登录名写入 `PLUGIN_MARKET_ADMIN_GITHUB_LOGINS`。
并把管理员 GitHub 登录名写入 `PLUGIN_MARKET_ADMIN_GITHUB_LOGINS`。

作者侧接口使用:

Expand Down
12 changes: 7 additions & 5 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
})();
</script>
<style>
html { background: #fafbff; color: #0b1220; }
html[data-theme="dark"] { background: #0a1220; color: #e6edf6; }
html { background: var(--paper, #ffffff); color: var(--ink-900, #0b1220); }
html[data-theme="dark"] { background: var(--paper, #101722); color: var(--ink-900, #e3e9f2); }
#boot-screen {
--paper: #fafbff; --ink: #162c42; --blue: #166997; --line: #a7bacd; --muted: #465970;
--paper: #ffffff; --ink: #162c42; --blue: #166997; --line: #a7bacd; --muted: #465970;
position: fixed; inset: 0; z-index: 10000; isolation: isolate;
display: grid; place-items: center; overflow: auto; overscroll-behavior: contain; padding: clamp(20px, 5vw, 64px);
box-sizing: border-box; background: var(--paper); color: var(--ink);
Expand Down Expand Up @@ -70,7 +70,8 @@
.boot-track::after { display: block; content: ""; width: 36%; height: 100%; background: var(--blue); animation: boot-sweep 1.4s ease-in-out infinite; }
#boot-status { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
#boot-retry { margin: 12px 0 0; padding: 9px 18px; border: 1px solid var(--blue); background: var(--paper); color: var(--blue); font: inherit; cursor: pointer; }
#boot-retry:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
#boot-skip { margin: 10px 0 0; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
#boot-skip:focus-visible, #boot-retry:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
#boot-screen[data-phase="leaving"] { animation: boot-leave .2s ease-in both; }
#boot-screen[data-phase="failed"] *, #boot-screen[data-phase="failed"] ::after { animation: none; }
html[data-reduced-motion="reduce"] #boot-screen,
Expand Down Expand Up @@ -112,11 +113,12 @@
<div aria-hidden="true">
<div class="boot-running"><span>MOFOX STUDIO</span><span>社区插件与技能</span></div>
<div class="boot-emblem"><img class="boot-logo" src="/logo.png" width="96" height="96" alt="" fetchpriority="high"></div>
<div class="boot-masthead" lang="en"><i>The</i> MoFox Gazette</div>
<div class="boot-masthead" lang="zh-CN"><i>MoFox</i> 市场报</div>
<p class="boot-market">MoFox 插件市场</p>
<div class="boot-rule"></div><div class="boot-track"></div>
</div>
<p id="boot-status" role="status" aria-live="polite" aria-atomic="true">正在准备插件市场</p>
<button id="boot-skip" type="button" onclick="if (window.__mofoxBoot) window.__mofoxBoot.skipRequested = true; window.dispatchEvent(new Event('mofox:skip-intro')); this.disabled = true;">跳过开场动画</button>
<button id="boot-retry" type="button" hidden onclick="location.reload()">重新加载</button>
<noscript><p>请启用 JavaScript 以使用插件市场。</p></noscript>
</div>
Expand Down
4 changes: 2 additions & 2 deletions frontend/scripts/build-editorial-font.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Build the optional, self-hosted Chinese display subset (fonttools + brotli)."""
"""构建可选的自托管中文展示字体子集(fonttools + brotli)。"""
from pathlib import Path
from tempfile import TemporaryDirectory
from urllib.request import urlretrieve
Expand All @@ -9,7 +9,7 @@

FRONTEND = Path(__file__).resolve().parents[1]
UPSTREAM = "https://raw.githubusercontent.com/google/fonts/8b0a1d0f5983c89bc2b93f1b5fb55f9e252744b5/ofl/notoserifsc/"
# Only display lettering is bundled. Dynamic names use the local Songti stack.
# 仅打包展示文案所需字形;动态名称使用本地宋体回退字体栈。
LETTERING = """拓展边界,让灵感运行。每一个插件都是种新的可能从用途开始值得一试
精选作品持续生长最近更新由热爱驱动社区创作者下可能你造猜你喜欢还喜欢
找到你的下一块拼图探索发现市场档案技能资料版本说明使用指南消息中心服务状态
Expand Down
8 changes: 4 additions & 4 deletions frontend/scripts/generate-contours.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Generate an original static height-field texture (decorative, not geographic data).
"""生成原创静态高度场纹理(仅用于装饰,不是地理数据)。

Run `python frontend/scripts/generate-contours.py` from the repository root.
Marching squares joins shared edges before simplifying to smooth SVG paths.
在仓库根目录运行 `python frontend/scripts/generate-contours.py`。
行进方格算法先连接共享边,再将其简化为平滑的 SVG 路径。
"""
import math
from pathlib import Path
Expand Down Expand Up @@ -104,7 +104,7 @@ def edge(e):
target = Path(__file__).resolve().parents[1] / 'src/assets/terrain-contours.svg'
paths = ''.join(f'<path d="{path}" stroke-width="{1.15 if layer % 5 == 0 else .7}" opacity="{.85 if layer % 5 == 0 else .55}"/>' for layer, path in lines)
target.write_text(f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {W} {H}" fill="none"><g stroke="white" stroke-linecap="round" stroke-linejoin="round">{paths}</g></svg>\n', encoding='utf-8')
print(f'{len(lines)} joined contour paths; {target.stat().st_size} bytes')
print(f'已连接 {len(lines)} 条等高线路径;{target.stat().st_size} 字节')


if __name__ == '__main__': build()
40 changes: 26 additions & 14 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* API client module - thin wrapper around fetch
* API 客户端模块,对 fetch 进行轻量封装。
*/

import { trackRead } from '@/composables/useLoadingState';
Expand Down Expand Up @@ -386,20 +386,29 @@ export const api = {
},

skills: {
list(params?: Record<string, QueryValue>): Promise<SkillListResponse> {
return get<SkillListResponse>(withQuery('/api/v1/skills', params));
list(
params?: Record<string, QueryValue>,
options?: RequestOptions,
): Promise<SkillListResponse> {
return get<SkillListResponse>(withQuery('/api/v1/skills', params), options);
},
get(skillId: string): Promise<Skill> {
return get<Skill>(`/api/v1/skills/${encodeURIComponent(skillId)}`);
get(skillId: string, options?: RequestOptions): Promise<Skill> {
return get<Skill>(`/api/v1/skills/${encodeURIComponent(skillId)}`, options);
},
versions(skillId: string): Promise<SkillVersionListResponse> {
versions(skillId: string, options?: RequestOptions): Promise<SkillVersionListResponse> {
return get<SkillVersionListResponse>(
`/api/v1/skills/${encodeURIComponent(skillId)}/versions`,
options,
);
},
version(skillId: string, version: string): Promise<SkillVersion> {
version(
skillId: string,
version: string,
options?: RequestOptions,
): Promise<SkillVersion> {
return get<SkillVersion>(
`/api/v1/skills/${encodeURIComponent(skillId)}/versions/${encodeURIComponent(version)}`,
options,
);
},
downloadUrl(skillId: string, version: string): string {
Expand All @@ -408,12 +417,14 @@ export const api = {
comments(
skillId: string,
params?: Record<string, QueryValue>,
options?: RequestOptions,
): Promise<SkillCommentListResponse> {
return get<SkillCommentListResponse>(
withQuery(
`/api/v1/skills/${encodeURIComponent(skillId)}/comments`,
params,
),
options,
);
},
postComment(
Expand All @@ -430,9 +441,10 @@ export const api = {
`/api/v1/skills/${encodeURIComponent(skillId)}/comments/${commentId}`,
);
},
rating(skillId: string): Promise<SkillRatingInfo> {
rating(skillId: string, options?: RequestOptions): Promise<SkillRatingInfo> {
return get<SkillRatingInfo>(
`/api/v1/skills/${encodeURIComponent(skillId)}/rating`,
options,
);
},
postRating(skillId: string, score: number): Promise<SkillRatingInfo> {
Expand Down Expand Up @@ -477,16 +489,16 @@ export const api = {
delete(skillId: string): Promise<void> {
return del(`/api/v1/skills/${encodeURIComponent(skillId)}`);
},
my(): Promise<Skill[]> {
return get<{ items: Skill[] }>('/api/v1/me/skills').then((r) => r.items);
my(options?: RequestOptions): Promise<Skill[]> {
return get<{ items: Skill[] }>('/api/v1/me/skills', options).then((r) => r.items);
},
categories(): Promise<string[]> {
return get<{ items: string[] }>('/api/v1/skills/categories').then(
categories(options?: RequestOptions): Promise<string[]> {
return get<{ items: string[] }>('/api/v1/skills/categories', options).then(
(r) => r.items,
);
},
tags(): Promise<string[]> {
return get<{ items: string[] }>('/api/v1/skills/tags').then(
tags(options?: RequestOptions): Promise<string[]> {
return get<{ items: string[] }>('/api/v1/skills/tags', options).then(
(r) => r.items,
);
},
Expand Down
Loading
Loading