Skip to content

Commit 179253d

Browse files
committed
初始化插件市场:issue 投稿 + 静态校验 + registry 生成
0 parents  commit 179253d

15 files changed

Lines changed: 457 additions & 0 deletions

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 每个作者只对自己的插件目录拥有权限;首次上架仍由维护者人工审核合并。
2+
# 一个作者一行,按 @id 前缀匹配。
3+
/plugins/imsyy.* @imsyy

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: 插件开发文档
4+
url: https://splayer-next.imsyy.top/plugins/
5+
about: 编写插件前请先阅读
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 提交 / 更新插件
2+
description: 提交一个新插件,或更新自己已上架的插件
3+
title: "[插件] "
4+
labels: ["plugin-submission"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
提交前请阅读插件开发文档:https://splayer-next.imsyy.top/plugins/
10+
机器人会拉取你的脚本做静态校验并把结果回贴在下方;通过后由维护者人工审核合并。
11+
- type: input
12+
id: plugin-id
13+
attributes:
14+
label: 插件 @id
15+
description: 与脚本头部的 `@id` 一致,全局唯一、上架后不可变(建议 反向域名 风格,如 `yourname.plugin`)
16+
placeholder: yourname.plugin
17+
validations:
18+
required: true
19+
- type: dropdown
20+
id: plugin-type
21+
attributes:
22+
label: 类型
23+
options:
24+
- source(音源)
25+
- control(控制)
26+
validations:
27+
required: true
28+
- type: textarea
29+
id: source
30+
attributes:
31+
label: 脚本来源
32+
description: |
33+
二选一:把 **`.js` 文件直接拖到这个文本框上传**,或**粘贴脚本的 raw 直链**。
34+
更新插件时记得先把脚本里的 `@version` 往上 bump。
35+
placeholder: 把 .js 拖到这里,或粘贴 https://.../plugin.js
36+
validations:
37+
required: true
38+
- type: textarea
39+
id: notes
40+
attributes:
41+
label: 备注
42+
description: 简介、更新说明、或需要维护者注意的事项(可选)
43+
validations:
44+
required: false
45+
- type: checkboxes
46+
id: ack
47+
attributes:
48+
label: 确认
49+
options:
50+
- label: 我已阅读插件文档,对脚本内容与合法性负责
51+
required: true
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: build-registry
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "plugins/**"
8+
- "scripts/build-registry.mjs"
9+
10+
concurrency:
11+
group: build-registry
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
# 生成 registry.json(updateUrl 指向中央 raw)
26+
- run: REPO_RAW=https://raw.githubusercontent.com/${{ github.repository }}/main node scripts/build-registry.mjs
27+
# 回提 registry.json;它不在 plugins/ 下,不会再次触发本工作流
28+
- run: |
29+
git config user.name 'github-actions[bot]'
30+
git config user.email 'github-actions[bot]@users.noreply.github.com'
31+
git add registry.json
32+
git diff --cached --quiet || git commit -m 'chore: 重建 registry.json'
33+
git push

.github/workflows/check-submit.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: check-submit
2+
3+
on:
4+
issues:
5+
types: [opened, edited]
6+
issue_comment:
7+
types: [created]
8+
9+
concurrency:
10+
group: submit-${{ github.event.issue.number }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
issues: write
15+
contents: read
16+
17+
jobs:
18+
validate-submission:
19+
# 仅处理带 plugin-submission 标签的投稿 issue;PR/issue 下 /recheck 可手动复检
20+
if: |
21+
contains(join(github.event.issue.labels.*.name, ','), 'plugin-submission') &&
22+
(github.event_name == 'issues' ||
23+
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/recheck')))
24+
runs-on: ubuntu-latest
25+
timeout-minutes: 5
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
- run: node scripts/intake.mjs
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/validate.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: validate
2+
3+
on:
4+
pull_request:
5+
paths: ["plugins/**"]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
validate:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
- run: node scripts/validate.mjs

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
.DS_Store

README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# SPlayer 插件市场
2+
3+
SPlayer-Next 的官方插件索引仓库。插件本体以 `plugins/<@id>.js` 形式收录于此,CI 聚合生成 `registry.json`,App 拉取它做市场列表,并沿用脚本头的 `@updateUrl` + `@version` 做一键更新。
4+
5+
## 提交 / 更新插件
6+
7+
**Issue**,不用 fork:
8+
9+
1. 新建 Issue → 选「提交 / 更新插件」模板。
10+
2.`@id`、类型,并把 **`.js` 文件拖进文本框上传**(或粘贴脚本 raw 直链)。
11+
3. 机器人自动拉取、静态校验,把结果回贴在 Issue 下。
12+
4. 校验通过后由**维护者人工审核**,合并进 `plugins/`
13+
5. 合并后 CI 重建 `registry.json`,插件进入市场。
14+
15+
**更新**:同样的流程,记得先把脚本里的 `@version` 往上 bump;用户端会检测到新版并一键更新。
16+
17+
> 也可直接对 `plugins/` 发 PR(适合熟悉 git 的作者)。
18+
19+
## 脚本头要求
20+
21+
```js
22+
/**
23+
* @name 插件名(≤24)
24+
* @id yourname.plugin // 全局唯一、上架后不可变
25+
* @version 1.0.0
26+
* @type source | control
27+
* @apiLevel 2 // 控制类需 ≥ 2
28+
* @author you
29+
* @description ...
30+
*/
31+
```
32+
33+
完整开发文档:https://splayer-next.imsyy.top/plugins/
34+
35+
## 安全说明
36+
37+
插件是会在用户机器上运行的可执行代码,沙箱是稳定性边界、不是安全边界。CI 只做静态校验(格式 / `@id` / 敏感用法提示),**判断是否合法/安全由维护者人工把关**——新插件首次上架必经人审。
38+
39+
## 本地
40+
41+
```bash
42+
npm run validate # 校验所有 plugins/*.js
43+
npm run build # 生成 registry.json
44+
```

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "splayer-plugins",
3+
"private": true,
4+
"description": "SPlayer 插件市场",
5+
"scripts": {
6+
"validate": "node scripts/validate.mjs",
7+
"build": "node scripts/build-registry.mjs"
8+
}
9+
}

plugins/imsyy.classisland.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @name ClassIsland 联动
3+
* @id imsyy.classisland
4+
* @version 1.0.0
5+
* @author imsyy
6+
* @type control
7+
* @apiLevel 2
8+
* @description 把当前歌词推送到 ClassIsland 主界面
9+
* @homepage https://github.com/imsyy/SPlayer
10+
*/
11+
12+
splayer.register({ events: ["trackChange", "lineChange"] });
13+
14+
splayer.player.on("lineChange", ({ index }) => {
15+
splayer.log.info("当前歌词行", index);
16+
});

0 commit comments

Comments
 (0)