mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: export
This commit is contained in:
+2
-4
@@ -2,18 +2,16 @@ from fastapi import APIRouter
|
||||
|
||||
from apps.system.api import login, user, aimodel
|
||||
from apps.settings.api import terminology
|
||||
from apps.datasource.api import datasource
|
||||
from apps.datasource.api import datasource, export
|
||||
from apps.chat.api import chat
|
||||
from apps.dashboard.api import dashboard_api
|
||||
|
||||
|
||||
api_router = APIRouter()
|
||||
api_router.include_router(login.router)
|
||||
api_router.include_router(user.router)
|
||||
api_router.include_router(aimodel.router)
|
||||
api_router.include_router(terminology.router)
|
||||
api_router.include_router(datasource.router)
|
||||
api_router.include_router(export.router)
|
||||
api_router.include_router(chat.router)
|
||||
api_router.include_router(dashboard_api.router)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# Author: Junjun
|
||||
# Date: 2025/6/24
|
||||
|
||||
import time
|
||||
|
||||
from fastapi import APIRouter
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
|
||||
from common.core.deps import SessionDep
|
||||
|
||||
router = APIRouter(tags=["export"], prefix="/export")
|
||||
|
||||
|
||||
@router.get("/png")
|
||||
async def export(session: SessionDep):
|
||||
driver = webdriver.Chrome() # 或者使用webdriver.Firefox()等
|
||||
print('init done')
|
||||
# 打开网页
|
||||
driver.get('https://g2.antv.antgroup.com/examples/general/interval/#bar-basic')
|
||||
driver.set_window_size(width=1920, height=1080)
|
||||
|
||||
# 等待页面加载完成(根据需要调整时间)
|
||||
|
||||
try:
|
||||
# 等待直到某个元素加载完成,例如某个具体的元素或者某个时间(例如10秒)
|
||||
print("started driver")
|
||||
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "canvas")))
|
||||
time.sleep(2)
|
||||
except:
|
||||
print("Timeout")
|
||||
|
||||
# 获取整个页面的截图并保存为图片文件
|
||||
driver.save_screenshot('screenshot.png')
|
||||
|
||||
# 关闭浏览器
|
||||
driver.quit()
|
||||
@@ -35,6 +35,8 @@ dependencies = [
|
||||
"oracledb (>=3.1.1,<4.0.0)",
|
||||
"pyyaml (>=6.0.2,<7.0.0)",
|
||||
"fastapi-mcp (>=0.3.4,<0.4.0)",
|
||||
"selenium (>=4.33.0,<5.0.0)",
|
||||
"pillow (>=11.2.1,<12.0.0)",
|
||||
]
|
||||
[[tool.uv.index]]
|
||||
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
|
||||
|
||||
@@ -19,4 +19,5 @@ export const datasourceApi = {
|
||||
saveTable: (data: any) => request.post('/datasource/editTable', data),
|
||||
saveField: (data: any) => request.post('/datasource/editField', data),
|
||||
getDs: (id: number) => request.post(`/datasource/get/${id}`),
|
||||
exportFromServer: () => request.get('/export/png'),
|
||||
}
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
@click="editDs(undefined)"
|
||||
>{{ t('ds.add') }}</el-button
|
||||
>
|
||||
<el-button class="border-radius_8" type="primary" :icon="IconOpeAdd" @click="exportPng"
|
||||
>export</el-button
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="connections-container">
|
||||
@@ -75,6 +78,17 @@ const allDsList = ref<any>([]) // all ds list
|
||||
const router = useRouter()
|
||||
const loading = ref(false)
|
||||
|
||||
const exportPng = () => {
|
||||
datasourceApi
|
||||
.exportFromServer()
|
||||
.then(() => {
|
||||
console.log('export success')
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
})
|
||||
}
|
||||
|
||||
function searchHandle() {
|
||||
if (searchValue.value) {
|
||||
dsList.value = JSON.parse(JSON.stringify(allDsList.value)).filter((item: any) => {
|
||||
|
||||
Reference in New Issue
Block a user