Skip to content

Commit 4a293a1

Browse files
Copilotsj817
andcommitted
Add React web application for plugin submission
- Created React app with Vite for plugin marketplace submission - Implemented GitHub OAuth login flow - Added repository selection with auto-detection of submitted plugins - Implemented npm package validation - Added support for app type plugins (single JS files) - Created GitHub Actions workflow for deployment - Updated README with web app information Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com>
1 parent 65a8f20 commit 4a293a1

File tree

20 files changed

+3892
-2
lines changed

20 files changed

+3892
-2
lines changed

.github/workflows/deploy-web.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Deploy Web App to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- copilot/implement-github-login-feature
8+
paths:
9+
- 'web/**'
10+
- '.github/workflows/deploy-web.yml'
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: '20'
33+
cache: 'npm'
34+
cache-dependency-path: 'web/package-lock.json'
35+
36+
- name: Install dependencies
37+
run: |
38+
cd web
39+
npm ci
40+
41+
- name: Build
42+
run: |
43+
cd web
44+
npm run build
45+
46+
- name: Copy plugins.json to dist
47+
run: |
48+
cp plugins.json web/dist/
49+
50+
- name: Setup Pages
51+
uses: actions/configure-pages@v4
52+
53+
- name: Upload artifact
54+
uses: actions/upload-pages-artifact@v3
55+
with:
56+
path: './web/dist'
57+
58+
deploy:
59+
environment:
60+
name: github-pages
61+
url: ${{ steps.deployment.outputs.page_url }}
62+
runs-on: ubuntu-latest
63+
needs: build
64+
steps:
65+
- name: Deploy to GitHub Pages
66+
id: deployment
67+
uses: actions/deploy-pages@v4

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- [插件列表](#插件列表)
88
- [提交插件](#提交插件)
9+
- [在线提交工具](#在线提交工具)
910
- [插件规范](#插件规范)
1011

1112
## 插件列表
@@ -14,13 +15,27 @@
1415

1516
## 提交插件
1617

17-
### 前置条件
18+
### 在线提交工具
19+
20+
我们提供了一个在线工具来简化插件提交流程:
21+
22+
🔗 **[插件提交页面](https://karinjs.github.io/plugins-list/)** (开发中)
23+
24+
该工具提供以下功能:
25+
- 使用 GitHub 登录
26+
- 自动检测已提交的插件
27+
- 验证 npm 包存在性
28+
- 简化的提交流程
29+
30+
### 手动提交
31+
32+
#### 前置条件
1833

1934
1. 确保你的插件符合规范要求
2035
2. 确保你的插件遵循 [插件规范](#插件规范)
2136
3. 准备好插件的相关信息
2237

23-
### 提交步骤
38+
#### 提交步骤
2439

2540
1. Fork 本仓库
2641
2.`plugins.json` 文件中添加你的插件信息

web/.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# GitHub OAuth App Configuration
2+
# Create a GitHub OAuth App at: https://github.com/settings/developers
3+
# Set Authorization callback URL to: http://localhost:5173/plugins-list/ (for dev) or https://karinjs.github.io/plugins-list/ (for production)
4+
5+
VITE_GITHUB_CLIENT_ID=your_github_oauth_client_id_here

web/.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
.env
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

web/README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Karin 插件市场提交页面
2+
3+
这是一个用于提交插件到 Karin 插件市场的 React 应用。
4+
5+
## 功能
6+
7+
- ✅ GitHub OAuth 登录
8+
- ✅ 自动获取用户的 GitHub 仓库
9+
- ✅ 自动检测并勾选已提交的插件(基于 package.json 的 name 字段)
10+
- ✅ 验证 npm 包是否存在(对于 npm 类型插件)
11+
- ✅ 支持单 JS 文件类型插件(app 类型,无需 npm 验证)
12+
13+
## 开发
14+
15+
### 前置要求
16+
17+
- Node.js 18+
18+
- npm 或 pnpm
19+
20+
### 安装依赖
21+
22+
```bash
23+
npm install
24+
```
25+
26+
### 配置 GitHub OAuth
27+
28+
1. 在 GitHub 创建 OAuth App:https://github.com/settings/developers
29+
2. 设置 Authorization callback URL:
30+
- 开发环境:`http://localhost:5173/plugins-list/`
31+
- 生产环境:`https://karinjs.github.io/plugins-list/`
32+
3. 复制 `.env.example``.env`
33+
4.`.env` 中填入你的 Client ID
34+
35+
### 开发模式
36+
37+
```bash
38+
npm run dev
39+
```
40+
41+
### 构建
42+
43+
```bash
44+
npm run build
45+
```
46+
47+
### 部署
48+
49+
构建后的文件在 `dist` 目录中,可以部署到 GitHub Pages 或任何静态网站托管服务。
50+
51+
#### GitHub Pages 部署
52+
53+
1. 确保仓库有 `gh-pages` 分支
54+
2. 运行构建命令
55+
3.`dist` 目录的内容推送到 `gh-pages` 分支
56+
57+
## 测试说明
58+
59+
由于 GitHub OAuth 需要后端服务来交换 access token(不能在前端暴露 client secret),当前实现包含以下测试方法:
60+
61+
### 方法 1:使用个人访问令牌(Personal Access Token)
62+
63+
1. 访问 https://github.com/settings/tokens
64+
2. 点击 "Generate new token (classic)"
65+
3. 勾选 `repo``read:user` 权限
66+
4. 生成令牌并复制
67+
5. 在浏览器控制台运行:
68+
```javascript
69+
localStorage.setItem('github_token', 'YOUR_TOKEN_HERE');
70+
```
71+
6. 刷新页面
72+
73+
### 方法 2:完整 OAuth 流程
74+
75+
需要配置后端服务来处理 OAuth 回调并交换 token。可以使用:
76+
- GitHub Actions
77+
- Cloudflare Workers
78+
- Vercel Serverless Functions
79+
- 或任何其他后端服务
80+
81+
## 使用说明
82+
83+
1. 点击"使用 GitHub 登录"按钮
84+
2. 授权应用访问您的 GitHub 仓库
85+
3. 查看包含 `package.json` 的仓库列表
86+
4. 已提交的插件会自动勾选并显示"已提交"标签
87+
5. 选择要提交的仓库
88+
6. 点击"提交"按钮进行验证
89+
7. 验证成功后,会显示可提交的仓库列表
90+
91+
## 注意事项
92+
93+
- 只有包含 `package.json` 的仓库才会显示
94+
- npm 类型插件会验证包是否在 npm 上存在
95+
- app 类型插件(单 JS 文件)不需要 npm 验证
96+
- 插件名称基于 `package.json` 中的 `name` 字段

web/eslint.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import { defineConfig, globalIgnores } from 'eslint/config'
6+
7+
export default defineConfig([
8+
globalIgnores(['dist']),
9+
{
10+
files: ['**/*.{js,jsx}'],
11+
extends: [
12+
js.configs.recommended,
13+
reactHooks.configs['recommended-latest'],
14+
reactRefresh.configs.vite,
15+
],
16+
languageOptions: {
17+
ecmaVersion: 2020,
18+
globals: globals.browser,
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
ecmaFeatures: { jsx: true },
22+
sourceType: 'module',
23+
},
24+
},
25+
rules: {
26+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
27+
},
28+
},
29+
])

web/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>web</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)