mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-31 13:57:06 +00:00
Compare commits
29 Commits
refactor/a
...
revert-26-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00ba64d837 | ||
|
|
b9431dace1 | ||
|
|
268757a670 | ||
|
|
01135f430e | ||
|
|
9b1056b13b | ||
|
|
df243204fd | ||
|
|
6be574accc | ||
|
|
63f9d11da9 | ||
|
|
a3e1402df8 | ||
|
|
de7661ea6d | ||
|
|
0a6695bbd3 | ||
|
|
6a933c2e73 | ||
|
|
fee71c798f | ||
|
|
8628994acf | ||
|
|
4a3e233711 | ||
|
|
7603458c1d | ||
|
|
0907fc4863 | ||
|
|
c3c4e9a2fc | ||
|
|
991ab6440b | ||
|
|
2f2e0638d4 | ||
|
|
85ecd08e1b | ||
|
|
408fff8de8 | ||
|
|
298bc12e51 | ||
|
|
dbf20c7967 | ||
|
|
b516ca88f2 | ||
|
|
fde92a5770 | ||
|
|
714fa11412 | ||
|
|
980108e907 | ||
|
|
d20ee1226e |
17
.github/workflows/sync.yml
vendored
Normal file
17
.github/workflows/sync.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# .github/workflows/sync.yml
|
||||
name: Sync Fork
|
||||
|
||||
on:
|
||||
push: # push 时触发, 主要是为了测试配置有没有问题
|
||||
schedule:
|
||||
- cron: '* */3 * * *' # 每3小时触发, 对于一些更新不那么频繁的项目可以设置为每天一次, 低碳一点
|
||||
jobs:
|
||||
repo-sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: TG908/fork-sync@v1.6.3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
owner: QuantumNous # fork 的上游仓库 user
|
||||
head: main # fork 的上游仓库 branch
|
||||
base: main # 本地仓库 branch
|
||||
@@ -97,7 +97,6 @@ func updateVideoSingleTask(ctx context.Context, adaptor channel.TaskAdaptor, cha
|
||||
taskResult.Url = t.FailReason
|
||||
taskResult.Progress = t.Progress
|
||||
taskResult.Reason = t.FailReason
|
||||
task.Data = t.Data
|
||||
} else if taskResult, err = adaptor.ParseTaskResult(responseBody); err != nil {
|
||||
return fmt.Errorf("parseTaskResult failed for task %s: %w", taskId, err)
|
||||
} else {
|
||||
|
||||
@@ -362,20 +362,11 @@ func videoFetchByIDRespBodyBuilder(c *gin.Context) (respBody []byte, taskResp *d
|
||||
}
|
||||
}()
|
||||
|
||||
if len(respBody) != 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/v1/videos/") {
|
||||
respBody = originTask.Data
|
||||
return
|
||||
}
|
||||
respBody, err = json.Marshal(dto.TaskResponse[any]{
|
||||
Code: "success",
|
||||
Data: TaskModel2Dto(originTask),
|
||||
})
|
||||
if err != nil {
|
||||
taskResp = service.TaskErrorWrapper(err, "marshal_response_failed", http.StatusInternalServerError)
|
||||
if len(respBody) == 0 {
|
||||
respBody, err = json.Marshal(dto.TaskResponse[any]{
|
||||
Code: "success",
|
||||
Data: TaskModel2Dto(originTask),
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
35
web/functions/api/[[default]].js
Normal file
35
web/functions/api/[[default]].js
Normal file
@@ -0,0 +1,35 @@
|
||||
// functions/Pages_Functions.js
|
||||
// 该函数会将所有请求转发到环境变量 `TARGET_URL` 指定的地址
|
||||
|
||||
export async function onRequest(context) {
|
||||
// 从上下文中获取原始请求和环境变量
|
||||
const { request, env } = context;
|
||||
|
||||
// 解析原始请求的 URL,以获取路径和查询参数
|
||||
const url = new URL(request.url);
|
||||
const path = url.pathname;
|
||||
const search = url.search;
|
||||
|
||||
// 从环境变量中获取目标 URL,如果未设置则提供一个默认值
|
||||
const target = env.TARGET_URL || 'http://172.0.0.1';
|
||||
|
||||
// 构建目标 URL
|
||||
const targetUrl = `${target}${path}${search}`;
|
||||
|
||||
// 创建一个新的请求以转发到目标地址
|
||||
// 复制原始请求的方法、头部和主体
|
||||
const newRequest = new Request(targetUrl, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
body: request.body,
|
||||
redirect: 'manual' // 防止 fetch 自动处理重定向
|
||||
});
|
||||
|
||||
// 执行转发请求并返回响应
|
||||
try {
|
||||
return await fetch(newRequest);
|
||||
} catch (error) {
|
||||
// 如果目标服务器无法访问,返回一个错误信息
|
||||
return new Response(`Error forwarding request: ${error.message}`, { status: 502 });
|
||||
}
|
||||
}
|
||||
35
web/functions/mj/[[default]].js
Normal file
35
web/functions/mj/[[default]].js
Normal file
@@ -0,0 +1,35 @@
|
||||
// functions/Pages_Functions.js
|
||||
// 该函数会将所有请求转发到环境变量 `TARGET_URL` 指定的地址
|
||||
|
||||
export async function onRequest(context) {
|
||||
// 从上下文中获取原始请求和环境变量
|
||||
const { request, env } = context;
|
||||
|
||||
// 解析原始请求的 URL,以获取路径和查询参数
|
||||
const url = new URL(request.url);
|
||||
const path = url.pathname;
|
||||
const search = url.search;
|
||||
|
||||
// 从环境变量中获取目标 URL,如果未设置则提供一个默认值
|
||||
const target = env.TARGET_URL || 'http://172.0.0.1';
|
||||
|
||||
// 构建目标 URL
|
||||
const targetUrl = `${target}${path}${search}`;
|
||||
|
||||
// 创建一个新的请求以转发到目标地址
|
||||
// 复制原始请求的方法、头部和主体
|
||||
const newRequest = new Request(targetUrl, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
body: request.body,
|
||||
redirect: 'manual' // 防止 fetch 自动处理重定向
|
||||
});
|
||||
|
||||
// 执行转发请求并返回响应
|
||||
try {
|
||||
return await fetch(newRequest);
|
||||
} catch (error) {
|
||||
// 如果目标服务器无法访问,返回一个错误信息
|
||||
return new Response(`Error forwarding request: ${error.message}`, { status: 502 });
|
||||
}
|
||||
}
|
||||
35
web/functions/pg/[[default]].js
Normal file
35
web/functions/pg/[[default]].js
Normal file
@@ -0,0 +1,35 @@
|
||||
// functions/Pages_Functions.js
|
||||
// 该函数会将所有请求转发到环境变量 `TARGET_URL` 指定的地址
|
||||
|
||||
export async function onRequest(context) {
|
||||
// 从上下文中获取原始请求和环境变量
|
||||
const { request, env } = context;
|
||||
|
||||
// 解析原始请求的 URL,以获取路径和查询参数
|
||||
const url = new URL(request.url);
|
||||
const path = url.pathname;
|
||||
const search = url.search;
|
||||
|
||||
// 从环境变量中获取目标 URL,如果未设置则提供一个默认值
|
||||
const target = env.TARGET_URL || 'http://172.0.0.1';
|
||||
|
||||
// 构建目标 URL
|
||||
const targetUrl = `${target}${path}${search}`;
|
||||
|
||||
// 创建一个新的请求以转发到目标地址
|
||||
// 复制原始请求的方法、头部和主体
|
||||
const newRequest = new Request(targetUrl, {
|
||||
method: request.method,
|
||||
headers: request.headers,
|
||||
body: request.body,
|
||||
redirect: 'manual' // 防止 fetch 自动处理重定向
|
||||
});
|
||||
|
||||
// 执行转发请求并返回响应
|
||||
try {
|
||||
return await fetch(newRequest);
|
||||
} catch (error) {
|
||||
// 如果目标服务器无法访问,返回一个错误信息
|
||||
return new Response(`Error forwarding request: ${error.message}`, { status: 502 });
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
"dependencies": {
|
||||
"@douyinfe/semi-icons": "^2.63.1",
|
||||
"@douyinfe/semi-ui": "^2.69.1",
|
||||
"antd": "^5.25.2",
|
||||
"@lobehub/icons": "^2.0.0",
|
||||
"@visactor/react-vchart": "~1.8.8",
|
||||
"@visactor/vchart": "~1.8.8",
|
||||
@@ -44,7 +45,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"build": "node --max-old-space-size=4096 ./node_modules/vite/bin/vite.js build",
|
||||
"lint": "prettier . --check",
|
||||
"lint:fix": "prettier . --write",
|
||||
"eslint": "bunx eslint \"**/*.{js,jsx}\" --cache",
|
||||
|
||||
Reference in New Issue
Block a user