ci: 添加 Docker 构建和推送工作流

- 新增 Dockerfile 和 .dockerignore 文件
- 添加 Gitea 持续集成工作流,用于构建和推送 Docker 镜像
- 新增 .gitignore 文件,忽略构建和配置文件
- 添加项目结构和规范文档,包括 TypeScript、模块化、API、数据库等规范
- 新增前端和后端的基础代码结构
This commit is contained in:
D8D Developer
2025-06-11 09:35:39 +00:00
commit 71aaeb9424
70 changed files with 4170 additions and 0 deletions

72
docs/aliyun-sms.md Normal file
View File

@@ -0,0 +1,72 @@
```typescript
// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
import Dysmsapi20170525, * as $Dysmsapi20170525 from '@alicloud/dysmsapi20170525';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import Util, * as $Util from '@alicloud/tea-util';
import { env } from '../../config/env.ts';
export class SMS {
/**
* @remarks
* 使用AK&SK初始化账号Client
* @returns Client
*
* @throws Exception
*/
static createClient(): Dysmsapi20170525 {
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
// 建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378664.html。
if (!env.deploy?.alicloud) {
throw new Error("Aliyun SMS configuration is required");
}
const { accessKeyId, accessKeySecret } = env.deploy.alicloud;
let config = new $OpenApi.Config({
accessKeyId,
accessKeySecret,
});
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
config.endpoint = `dysmsapi.aliyuncs.com`;
return new (Dysmsapi20170525 as any).default(config);
}
/**
* 发送短信
* @param phoneNumber 手机号
* @param code 验证码
* @param templateCode 模板代码,默认使用配置的验证码模板
* @param signName 短信签名,默认使用配置的签名
*/
static async sendVerificationSMS(
phoneNumber: string,
code: string,
templateCode?: string,
signName?: string
): Promise<boolean> {
let client = this.createClient();
let sendSmsRequest = new $Dysmsapi20170525.SendSmsRequest({
signName: signName || (env.sms?.defaultSignName || "多八多"),
templateCode: templateCode || (env.sms?.defaultTemplateCode || "SMS_164760103"),
phoneNumbers: phoneNumber,
templateParam: JSON.stringify({code: code}),
});
let runtime = new $Util.RuntimeOptions({ });
try {
// 发送短信
const result = await client.sendSmsWithOptions(sendSmsRequest, runtime);
console.log("SMS sent successfully:", result);
return true;
} catch (error: unknown) {
// 错误处理
const err = error as { message?: string, data?: { Recommend?: string } };
console.error("SMS sending failed:", err.message);
if (err.data && err.data["Recommend"]) {
console.error("Recommendation:", err.data["Recommend"]);
}
return false;
}
}
}
```

37
docs/sso-verify.md Normal file
View File

@@ -0,0 +1,37 @@
```typescript
// 为Gogs SSO单点登录提供的验证API
authRoutes.get('/sso-verify', async (c) => {
try {
const auth = await initAuth()
// 从Authorization头获取令牌
const token = c.req.header('Authorization')?.replace('Bearer ', '')
if (!token) {
return c.text('Unauthorized', 401)
}
// 验证令牌
try {
const userData = await auth.verifyToken(token)
if (!userData) {
return c.text('Invalid token', 401)
}
// 导入GitUtils工具类并使用其formatUsername方法格式化用户名
const username = GitUtils.formatUsername(userData.username, userData.id);
// 验证成功,设置用户名到响应头
c.header('X-Username', username)
return c.text('OK', 200)
} catch (tokenError) {
log.auth('Token验证失败:', tokenError)
return c.text('Invalid token', 401)
}
} catch (error) {
log.auth('SSO验证失败:', error)
return c.text('Authentication failed', 500)
}
})
```

44
docs/zpay.cn.md Normal file
View File

@@ -0,0 +1,44 @@
API信息兼容 易支付 接口)
接口地址process.env.ZPAY_URL
商户IDPIDprocess.env.ZPAY_PID
商户密钥PKEYprocess.env.ZPAY_PKEY
异步通知地址process.env.ZPAY_NOTIFY_URL
API接口支付
请求URL
https://zpayz.cn/mapi.php
请求方法
POST方式为form-data
请求参数
字段名 变量名 必填 类型 示例值 描述
商户ID pid 是 String 1001
支付渠道ID cid 否 String 1234 如果不填则随机使用某一支付渠道
支付方式 type 是 String alipay 支付宝alipay 微信支付wxpay
商户订单号 out_trade_no 是 String 20160806151343349
异步通知地址 notify_url 是 String http://www.pay.com/notify_url.php 服务器异步通知地址
商品名称 name 是 String VIP会员 如超过127个字节会自动截取
商品金额 money 是 String 1.00 单位最大2位小数
用户IP地址 clientip 是 String 192.168.1.100 用户发起支付的IP地址
设备类型 device 否 String pc 根据当前用户浏览器的UA判断
传入用户所使用的浏览器
或设备类型默认为pc
业务扩展参数 param 否 String 没有请留空 支付后原样返回
签名字符串 sign 是 String 202cb962ac59075b964b07152d234b70 签名算法参考本页底部
签名类型 sign_type 是 String MD5 默认为MD5
成功返回
字段名 变量名 类型 示例值 描述
返回状态码 code Int 1 1为成功其它值为失败
返回信息 msg String 失败时返回原因
订单号 trade_no String 20160806151343349 支付订单号
ZPAY内部订单号 O_id String 123456 ZPAY内部订单号
支付跳转url payurl String https://xxx.cn/pay/wxpay/202010903/ 如果返回该字段则直接跳转到该url支付
二维码链接 qrcode String https://xxx.cn/pay/wxpay/202010903/ 如果返回该字段则根据该url生成二维码
二维码图片 img String https://z-pay.cn/qrcode/123.jpg 该字段为付款二维码的图片地址
失败返回
{"code":"error","msg":"具体的错误信息"}
<-- GET /api/zpay/notify?pid=2025052907394884&trade_no=2025053022001476521427708154&out_trade_no=202500000002&type=alipay&name=VIP%E4%BC%9A%E5%91%98%E6%9C%8D%E5%8A%A1&money=0.01&trade_status=TRADE_SUCCESS&param=user_id%3D123&sign=9a3406e5f177c03646274749463ad979&sign_type=MD5