新增独立用户级 workspace 只读接口和工作区页面,支持文件列表浏览及宽屏内嵌/窄屏弹窗预览,便于后续扩展团队空间与知识库浏览。 Co-authored-by: Copilot <copilot@github.com>
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
|
|
from server.utils.auth_middleware import get_required_user
|
|
from yuxi.services.workspace_service import download_workspace_file, list_workspace_tree, read_workspace_file_content
|
|
from yuxi.storage.postgres.models_business import User
|
|
|
|
workspace = APIRouter(prefix="/workspace", tags=["workspace"])
|
|
|
|
|
|
@workspace.get("/tree", response_model=dict)
|
|
async def get_workspace_tree(
|
|
path: str = Query("/", description="工作区目录路径"),
|
|
current_user: User = Depends(get_required_user),
|
|
):
|
|
return await list_workspace_tree(path=path, current_user=current_user)
|
|
|
|
|
|
@workspace.get("/file", response_model=dict)
|
|
async def get_workspace_file(
|
|
path: str = Query(..., description="工作区文件路径"),
|
|
current_user: User = Depends(get_required_user),
|
|
):
|
|
return await read_workspace_file_content(path=path, current_user=current_user)
|
|
|
|
|
|
@workspace.get("/download")
|
|
async def download_workspace(
|
|
path: str = Query(..., description="工作区文件路径"),
|
|
current_user: User = Depends(get_required_user),
|
|
):
|
|
return await download_workspace_file(path=path, current_user=current_user)
|