Skip to content

Commit 95b5044

Browse files
committed
fix: 更新存储后端为S3并修复公共分享路由路径
公共分享路由路径从 `/s/{token}` 变更为 `/api/v1/shares/public/{token}`,以保持API路径的一致性。 - 在 `lib.rs` 文件中调整了路由合并顺序,将 `public_routes` 移动到内部合并。 - 更新了 `shares.rs` 文件中的 `public_routes` 函数,将路由路径更改为 `/shares/public/{token}`。 - 在 `shares.ts` 文件中,修改了获取公共分享、验证分享密码和获取分享下载链接的路径。 - 调整了 `vite.config.ts` 文件中的代理配置,移除了对 `/s/` 的代理设置。
1 parent 835d597 commit 95b5044

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

crates/api/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ pub fn build_router(state: state::AppState) -> Router {
1616
.merge(files::routes())
1717
.merge(folders::routes())
1818
.merge(shares::routes())
19+
.merge(shares::public_routes())
1920
.merge(tokens::routes())
2021
.merge(admin::routes());
2122

2223
Router::new()
2324
.nest("/api/v1", api_v1)
24-
.merge(shares::public_routes())
2525
.layer(TraceLayer::new_for_http())
2626
.layer(
2727
CorsLayer::new()

crates/api/src/shares.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ pub fn routes() -> Router<AppState> {
2020
.route("/shares/{id}", axum::routing::delete(delete_share))
2121
}
2222

23-
/// Public share access routes: /s/:token
23+
/// Public share access routes (no auth required)
2424
pub fn public_routes() -> Router<AppState> {
2525
Router::new()
26-
.route("/s/{token}", get(get_share))
27-
.route("/s/{token}/verify", post(verify_share))
28-
.route("/s/{token}/download", get(download_share))
26+
.route("/shares/public/{token}", get(get_share))
27+
.route("/shares/public/{token}/verify", post(verify_share))
28+
.route("/shares/public/{token}/download", get(download_share))
2929
}
3030

3131
#[derive(Deserialize)]

web/src/api/shares.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export async function deleteShare(id: string): Promise<void> {
4747

4848
// Public share endpoints (no auth)
4949
export async function getPublicShare(token: string): Promise<PublicShareInfo> {
50-
const res = await fetch(`/s/${token}`)
50+
const res = await fetch(`/api/v1/shares/public/${token}`)
5151
if (!res.ok) {
5252
const body = await res.json()
5353
throw new Error(body.error?.message || '分享不存在')
@@ -57,7 +57,7 @@ export async function getPublicShare(token: string): Promise<PublicShareInfo> {
5757
}
5858

5959
export async function verifySharePassword(token: string, password: string): Promise<PublicShareInfo> {
60-
const res = await fetch(`/s/${token}/verify`, {
60+
const res = await fetch(`/api/v1/shares/public/${token}/verify`, {
6161
method: 'POST',
6262
headers: { 'Content-Type': 'application/json' },
6363
body: JSON.stringify({ password }),
@@ -71,5 +71,5 @@ export async function verifySharePassword(token: string, password: string): Prom
7171
}
7272

7373
export function getShareDownloadUrl(token: string): string {
74-
return `/s/${token}/download`
74+
return `/api/v1/shares/public/${token}/download`
7575
}

web/vite.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export default defineConfig({
77
server: {
88
proxy: {
99
'/api': 'http://localhost:8080',
10-
'/s/': 'http://localhost:8080',
1110
},
1211
},
1312
})

0 commit comments

Comments
 (0)