Merge remote-tracking branch 'origin/main'

This commit is contained in:
wangjiahao
2025-07-18 12:22:56 +08:00
21 changed files with 399 additions and 51 deletions
+2 -2
View File
@@ -138,7 +138,7 @@ async def create(session: SessionDep, creator: UserCreator):
session.commit()
@router.put("")
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="editor.id")
#@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="editor.id")
async def update(session: SessionDep, editor: UserEditor):
user_model: UserModel = get_db_user(session = session, user_id = editor.id)
origin_oid: int = user_model.oid
@@ -186,7 +186,7 @@ async def langChange(session: SessionDep, current_user: CurrentUser, language: U
session.commit()
@router.patch("/pwd/{id}")
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
#@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
async def pwdReset(session: SessionDep, current_user: CurrentUser, id: int):
if not current_user.isAdmin:
raise HTTPException('only for admin')
+3 -3
View File
@@ -22,7 +22,7 @@ def get_user_by_account(*, session: Session, account: str) -> BaseUserDTO | None
return None
return BaseUserDTO.model_validate(db_user.model_dump())
@cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="user_id")
#@cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="user_id")
async def get_user_info(*, session: Session, user_id: int) -> UserInfoDTO | None:
db_user: UserModel = get_db_user(session = session, user_id = user_id)
userInfo = UserInfoDTO.model_validate(db_user.model_dump())
@@ -58,7 +58,7 @@ async def user_ws_options(session: Session, uid: int, trans: Optional[I18n] = No
for id, name in result.all()
]
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
#@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
async def single_delete(session: SessionDep, id: int):
user_model: UserModel = get_db_user(session = session, user_id = id)
del_stmt = sqlmodel_delete(UserWsModel).where(UserWsModel.uid == id)
@@ -66,6 +66,6 @@ async def single_delete(session: SessionDep, id: int):
session.delete(user_model)
session.commit()
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
#@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="id")
async def clean_user_cache(id: int):
logging.info(f"User cache for [{id}] has been cleaned")
+7 -1
View File
@@ -13,7 +13,13 @@ template:
- 如数据库引擎是 PostgreSQL、Oracle,则在schema、表名、字段名、别名外层加双引号;
- 如数据库引擎是 MySQL,则在表名、字段名、别名外层加反引号;
- 如数据库引擎是 Microsoft SQL Server,则在schema、表名、字段名、别名外层加方括号。
- 如果生成SQL的字段内有时间格式的字段,若提问中没有指定,则默认按时间升序排序,且格式化为yyyy-MM-dd HH:mm:ss的格式,生成的格式化语法需要适配对应的数据库引擎。
- 如果生成SQL的字段内有时间格式的字段:
- 若提问中没有指定查询顺序,则默认按时间升序排序
- 若提问是时间,且没有指定具体格式,则格式化为yyyy-MM-dd HH:mm:ss的格式
- 若提问是日期,且没有指定具体格式,则格式化为yyyy-MM-dd的格式
- 若提问是年月,且没有指定具体格式,则格式化为yyyy-MM的格式
- 若提问是年,且没有指定具体格式,则格式化为yyyy的格式
- 生成的格式化语法需要适配对应的数据库引擎。
- 生成的SQL使用JSON格式返回:
{{"success":true,"sql":"生成的SQL语句","tables":["表名1","表名2",...]}}
- 问题与生成SQL无关时,直接回答:
-7
View File
@@ -1,7 +0,0 @@
<svg viewBox="0 0 80 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M37.5 6C37.7761 6 38 6.22386 38 6.5V13.5C38 13.7761 37.7761 14 37.5 14L9.5 14C9.22386 14 9 13.7761 9 13.5V6.5C9 6.22386 9.22386 6 9.5 6L37.5 6Z" fill="#3370FF"/>
<path d="M71.5 18C71.7761 18 72 18.2239 72 18.5V25.5C72 25.7761 71.7761 26 71.5 26H9.5C9.22386 26 9 25.7761 9 25.5V18.5C9 18.2239 9.22386 18 9.5 18L71.5 18Z" fill="#3370FF"/>
<path d="M50.5 30C50.7761 30 51 30.2239 51 30.5V37.5C51 37.7761 50.7761 38 50.5 38H9.5C9.22386 38 9 37.7761 9 37.5V30.5C9 30.2239 9.22386 30 9.5 30H50.5Z" fill="#3370FF"/>
<path d="M29.5 42C29.7761 42 30 42.2239 30 42.5V49.5C30 49.7761 29.7761 50 29.5 50H9.5C9.22386 50 9 49.7761 9 49.5V42.5C9 42.2239 9.22386 42 9.5 42H29.5Z" fill="#3370FF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 2.00391V53.0016V54.0016H4V2.00391H7Z" fill="#DEE0E3"/>
</svg>

Before

Width:  |  Height:  |  Size: 877 B

-7
View File
@@ -1,7 +0,0 @@
<svg viewBox="0 0 80 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M5 51H76L76 54H4V51H5Z" fill="#DEE0E3"/>
<path d="M11 29.5C11 29.2239 11.2239 29 11.5 29H20.5C20.7761 29 21 29.2239 21 29.5V48.5C21 48.7761 20.7761 49 20.5 49H11.5C11.2239 49 11 48.7761 11 48.5V29.5Z" fill="#3370FF"/>
<path d="M27 4.5C27 4.22386 27.2239 4 27.5 4H36.5C36.7761 4 37 4.22386 37 4.5V48.5C37 48.7761 36.7761 49 36.5 49H27.5C27.2239 49 27 48.7761 27 48.5V4.5Z" fill="#3370FF"/>
<path d="M43 19.5C43 19.2239 43.2239 19 43.5 19H52.5C52.7761 19 53 19.2239 53 19.5V48.5C53 48.7761 52.7761 49 52.5 49H43.5C43.2239 49 43 48.7761 43 48.5V19.5Z" fill="#3370FF"/>
<path d="M59 36.5C59 36.2239 59.2239 36 59.5 36H68.5C68.7761 36 69 36.2239 69 36.5V48.5C69 48.7761 68.7761 49 68.5 49H59.5C59.2239 49 59 48.7761 59 48.5V36.5Z" fill="#3370FF"/>
</svg>

Before

Width:  |  Height:  |  Size: 872 B

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.99983 2.50017H12.4544C13.0318 2.50017 13.4998 2.97987 13.4998 3.5716V8.00017H20.9472C21.5286 8.00017 21.9998 8.51185 21.9998 9.14303V14.8573C21.9998 15.4885 21.5286 16.0002 20.9472 16.0002H15.9998V20.4287C15.9998 21.0205 15.5521 21.5002 14.9998 21.5002H3.99983V22.5C3.99983 22.7761 3.77597 23 3.49983 23H2.49983C2.22369 23 1.99983 22.7761 1.99983 22.5V1.5C1.99983 1.22386 2.22369 1 2.49983 1H3.49983C3.77597 1 3.99983 1.22386 3.99983 1.5V2.50017ZM3.99983 19.5002H13.9998V16.0002H3.99983V19.5002ZM3.99983 14.0002H19.9998V10.0002H3.99983V14.0002ZM3.99983 8.00017H11.4998V4.50017H3.99983V8.00017Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 732 B

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.713135 21.4739V1.80273C0.713135 1.52659 0.936992 1.30273 1.21313 1.30273H2.26008C2.53623 1.30273 2.76008 1.52659 2.76008 1.80273V20.5523H22.5686C22.8447 20.5523 23.0686 20.7761 23.0686 21.0523V22.0992C23.0686 22.3754 22.8447 22.5992 22.5686 22.5992H1.83907C1.54045 22.5992 1.25407 22.4806 1.04291 22.2694C0.83176 22.0583 0.713135 21.7725 0.713135 21.4739Z" fill="currentColor"/>
<path d="M4.19544 18.3911C3.96872 18.2313 3.91539 17.9175 4.07659 17.6918L8.90155 10.9358C8.97757 10.8235 9.07516 10.7274 9.18865 10.6531C9.30213 10.5788 9.42925 10.5278 9.56262 10.5031C9.69599 10.4784 9.83293 10.4804 9.96551 10.5091C10.0981 10.5377 10.2236 10.5925 10.3349 10.6701L15.7191 14.2624L20.9481 8.16625C21.1291 7.95528 21.4474 7.93239 21.6567 8.11531L22.4497 8.80844C22.6562 8.98892 22.6788 9.30208 22.5003 9.51031L16.6806 16.2998C16.5179 16.4883 16.2919 16.611 16.0452 16.6449C15.7984 16.6788 15.5478 16.6215 15.3402 16.4839L10.0275 12.9315L5.77196 18.8941C5.61221 19.118 5.30171 19.1708 5.07694 19.0124L4.19544 18.3911Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.5 20V11.5455C2.5 10.9681 2.97969 10.5 3.57143 10.5H8V3.05263C8 2.47128 8.51167 2 9.14285 2H14.8571C15.4883 2 16 2.47128 16 3.05263V8H20.4286C21.0203 8 21.5 8.44772 21.5 9V20H22.4998C22.776 20 22.9998 20.2239 22.9998 20.5V21.5C22.9998 21.7761 22.776 22 22.4998 22H1.49982C1.22368 22 0.999825 21.7761 0.999825 21.5V20.5C0.999825 20.2239 1.22368 20 1.49982 20H2.5ZM19.5 20V10H16V20H19.5ZM14 20V4H10V20H14ZM8 20V12.5H4.5V20H8Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 561 B

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.53248 2.53248C2.87342 2.19154 3.33584 2 3.818 2H20.182C20.6642 2 21.1266 2.19154 21.4675 2.53248C21.8085 2.87342 22 3.33584 22 3.818V20.182C22 20.6642 21.8085 21.1266 21.4675 21.4675C21.1266 21.8085 20.6642 22 20.182 22H3.818C2.814 22 2 21.186 2 20.182V3.818C2 3.33584 2.19154 2.87342 2.53248 2.53248ZM4 10V14H8V10H4ZM4 16V20H8V16H4ZM10 20H14V16H10V20ZM16 20H20V16H16V20ZM20 14V10H16V14H20ZM14 10H10V14H14V10ZM20 4H4V8H20V4Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 603 B

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 21.3333C17.1547 21.3333 21.3333 17.1547 21.3333 12C18.2222 12 15.1111 12 12 12C12 8.26667 12 5.15556 12 2.66667C6.84534 2.66667 2.66666 6.84534 2.66666 12C2.66666 17.1547 6.84534 21.3333 12 21.3333ZM10.1667 12.7667C10.1667 13.3558 10.6442 13.8333 11.2333 13.8333H19.3333C18.5063 17.0465 15.4713 19.3333 12 19.3333C7.88562 19.3333 4.66666 15.9961 4.66666 11.8817C4.66666 8.41043 6.95354 5.49367 10.1667 4.66667V12.7667Z" fill="currentColor"/>
<path d="M14.8938 10C14.4002 10 14 9.59984 14 9.10621V2C18.2226 2.41925 21.5807 5.77735 22 10H14.8938ZM16 4.66667V8H19.3333C18.7209 6.4875 17.5125 5.27905 16 4.66667Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 748 B

-5
View File
@@ -1,5 +0,0 @@
<svg viewBox="0 0 80 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M37.686 13.231C37.2791 12.8242 36.6138 12.8437 36.2315 13.2737L34.8455 14.8327C34.1868 15.5735 33.2442 16.6333 32.1089 17.9092C29.8382 20.4611 26.7969 23.8773 23.714 27.3352C17.5164 34.2865 11.2327 41.313 10.6063 41.9394C10.0205 42.5252 10.0205 43.4749 10.6063 44.0607C11.1921 44.6465 12.1419 44.6465 12.7277 44.0607C13.4346 43.3537 19.8175 36.2136 25.9533 29.3316C29.0371 25.8728 32.0791 22.4557 34.3501 19.9034C35.4725 18.642 36.4066 17.5918 37.0644 16.8521L49.5834 29.3711C49.9141 29.7018 50.43 29.7591 50.8253 29.5089L72.851 15.5689L72.8605 15.5622C73.5392 15.0872 73.7043 14.1519 73.2292 13.4732C72.7567 12.7982 71.8291 12.6313 71.1513 13.0968L50.5191 26.0642L37.686 13.231Z" fill="#3370FF"/>
<path d="M11.667 26.5C10.8386 26.5 10.167 27.1716 10.167 28C10.167 28.8284 10.8386 29.5 11.667 29.5H33.6392L42.646 40.1151C42.8119 40.3107 43.0467 40.4351 43.3017 40.4624L71.4856 43.489C72.3058 43.589 73.0528 43.0065 73.1554 42.1861C73.2582 41.364 72.6751 40.6143 71.8531 40.5115L44.4294 37.5801L35.3277 26.853C35.1377 26.6291 34.8588 26.5 34.5651 26.5H11.667Z" fill="#00D6B9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7 2.00391V51.0016L76 51.0016L76 54.0016H4V2.00391H7Z" fill="#DEE0E3"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

-4
View File
@@ -1,4 +0,0 @@
<svg viewBox="0 0 80 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M39.1377 52.9999C52.3009 52.9999 63.0031 42.4632 63.2702 29.364C63.2758 29.0879 63.0515 28.8623 62.7753 28.8623C54.8961 28.8623 47.0169 28.8623 39.1377 28.8623C39.1377 19.4553 39.1377 11.5758 39.1377 5.22392C39.1377 4.94778 38.912 4.72409 38.636 4.72972C25.5367 4.99681 15 15.699 15 28.8623C15 42.1931 25.8068 52.9999 39.1377 52.9999Z" fill="#3370FF"/>
<path d="M46.6201 23.6894C45.3435 23.6894 44.3086 22.6545 44.3086 21.3779V3.5521C44.3086 3.25643 44.5649 3.02499 44.8583 3.06121C55.3368 4.35483 63.6432 12.6612 64.9368 23.1397C64.973 23.4331 64.7416 23.6894 64.4459 23.6894H46.6201Z" fill="#00D6B9"/>
</svg>

Before

Width:  |  Height:  |  Size: 693 B

-12
View File
@@ -1,12 +0,0 @@
<svg viewBox="0 0 80 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13 7.16675C13 6.89061 13.2239 6.66675 13.5 6.66675H65.8333C66.1095 6.66675 66.3333 6.89061 66.3333 7.16675V17.3334H13V7.16675Z" fill="#3370FF"/>
<path d="M29 20H13V28H29V20Z" fill="#ADC6FF"/>
<path d="M47.6667 20H31.6667V28H47.6667V20Z" fill="#ADC6FF"/>
<path d="M66.3333 20H50.3333V28H66.3333V20Z" fill="#ADC6FF"/>
<path d="M29 41.3333H13V48C13 48.7364 13.597 49.3333 14.3333 49.3333H29V41.3333Z" fill="#ADC6FF"/>
<path d="M47.6667 41.3333H31.6667V49.3333H47.6667V41.3333Z" fill="#ADC6FF"/>
<path d="M66.3333 41.3333H50.3333V49.3333H65C65.7364 49.3333 66.3333 48.7364 66.3333 48V41.3333Z" fill="#ADC6FF"/>
<path d="M29 30.6667H13V38.6667H29V30.6667Z" fill="#ADC6FF"/>
<path d="M47.6667 30.6667H31.6667V38.6667H47.6667V30.6667Z" fill="#ADC6FF"/>
<path d="M66.3333 30.6667H50.3333V38.6667H66.3333V30.6667Z" fill="#ADC6FF"/>
</svg>

Before

Width:  |  Height:  |  Size: 913 B

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.3594 8.65978L6.32239 8.63293C6.14037 8.63212 5.99302 8.48396 5.99227 8.30098L5.98967 7.6697C5.98891 7.48561 6.13675 7.33575 6.31988 7.33499C6.32083 7.33498 6.32178 7.33498 6.32272 7.33499L12.4811 7.36237L10.9553 5.8286C10.8258 5.69842 10.8258 5.48737 10.9553 5.35719L11.4243 4.88579C11.5538 4.75561 11.7637 4.75561 11.8932 4.88579L14.4724 7.47851C14.7314 7.73886 14.7314 8.16097 14.4724 8.42132L11.8932 11.014C11.7637 11.1442 11.5538 11.1442 11.4243 11.014L10.9553 10.5426C10.8258 10.4125 10.8258 10.2014 10.9553 10.0712L12.3594 8.65978ZM10.2864 2.66659H2.65971V13.3333H10.2864C10.4696 13.3333 10.618 13.4825 10.618 13.6666V14.3333C10.618 14.5173 10.4696 14.6666 10.2864 14.6666H1.99652C1.63025 14.6666 1.33333 14.3681 1.33333 13.9999V1.99992C1.33333 1.63173 1.63025 1.33325 1.99652 1.33325H10.2864C10.4696 1.33325 10.618 1.48249 10.618 1.66659V2.33325C10.618 2.51735 10.4696 2.66659 10.2864 2.66659Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14.0018 1.77783C14.3393 1.77783 14.6182 2.02864 14.6624 2.35404L14.6685 2.4445V13.5619C14.6685 13.8994 14.4177 14.1784 14.0923 14.2225L14.0018 14.2286H9.89135C9.73027 14.2286 9.59587 14.1143 9.56479 13.9624L9.55802 13.8953V13.2286C9.55802 13.0675 9.67228 12.9331 9.82417 12.902L9.89135 12.8953H13.3351V3.11117H4.40531L4.4062 6.11374C4.4062 6.29784 4.25696 6.44708 4.07287 6.44708H3.4062C3.22211 6.44708 3.07287 6.29784 3.07287 6.11374V2.11117C3.07287 1.95008 3.18713 1.81569 3.33902 1.7846L3.4062 1.77783H14.0018ZM6.64081 7.59331C6.73892 7.59331 6.83386 7.62809 6.90876 7.69146L9.70361 10.0563C9.8785 10.2043 9.90031 10.4661 9.75233 10.6409C9.73747 10.6585 9.72117 10.6748 9.70361 10.6897L6.90876 13.0545C6.73387 13.2025 6.47213 13.1807 6.32415 13.0058C6.26077 12.9309 6.226 12.836 6.226 12.7379L6.22649 11.1169L2.11133 11.1169C1.92724 11.1169 1.778 10.9677 1.778 10.7836V10.1169C1.778 9.93279 1.92724 9.78356 2.11133 9.78356L6.22649 9.78354L6.226 8.00813C6.226 7.77903 6.41172 7.59331 6.64081 7.59331Z" fill="#646A73"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,13 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2544_1401)">
<path d="M3.73867 8.73602V8.60268H2.66334L2.66135 8.734C2.65754 8.98598 2.70329 9.21145 2.80442 9.40561C2.90233 9.5936 3.03455 9.74991 3.20082 9.87263L3.20203 9.87351C3.36921 9.99404 3.55868 10.0807 3.76898 10.1344C3.97928 10.1906 4.19507 10.2187 4.416 10.2187C4.68537 10.2187 4.92661 10.1874 5.13772 10.1222C5.34953 10.0578 5.53141 9.96697 5.67895 9.84733C5.82899 9.72494 5.94356 9.57894 6.02015 9.40964C6.09601 9.24197 6.13334 9.06131 6.13334 8.86935C6.13334 8.63802 6.08334 8.43592 5.97253 8.27309C5.87482 8.1211 5.75572 7.99735 5.61456 7.90459C5.48064 7.81658 5.34261 7.75189 5.20056 7.71216C5.07733 7.67348 4.97613 7.64563 4.89892 7.62996C4.66254 7.56998 4.47032 7.5206 4.32217 7.4818C4.18064 7.44382 4.07352 7.40715 3.99789 7.3726C3.92609 7.33813 3.89826 7.30961 3.88956 7.29547C3.87803 7.27674 3.86667 7.24293 3.86667 7.18402C3.86667 7.12134 3.88021 7.08142 3.89761 7.05531C3.92304 7.01716 3.95439 6.98564 3.99235 6.96004C4.03514 6.93357 4.08212 6.91477 4.13414 6.90382C4.19286 6.89146 4.25121 6.88535 4.30934 6.88535C4.40492 6.88535 4.48987 6.89361 4.56481 6.90922L4.56586 6.90943C4.64088 6.92443 4.70343 6.94921 4.75547 6.98208C4.80208 7.01152 4.83964 7.05219 4.86848 7.10726L4.87091 7.1115C4.90072 7.16367 4.92203 7.23657 4.92826 7.33633L4.93608 7.46135H6.00534V7.32802C6.00534 7.09133 5.95965 6.88157 5.86133 6.70464C5.76989 6.53032 5.644 6.38646 5.48447 6.27479C5.32736 6.16481 5.14822 6.08731 4.94881 6.04111C4.75649 5.99222 4.55565 5.96802 4.34667 5.96802C4.16381 5.96802 3.98143 5.9928 3.79982 6.04199C3.61498 6.09205 3.44756 6.16962 3.29878 6.27533C3.14797 6.38248 3.02495 6.51757 2.93027 6.67933L2.92975 6.68022C2.8343 6.84623 2.78934 7.03896 2.78934 7.25335C2.78934 7.44369 2.82424 7.615 2.90003 7.76237L2.90228 7.76639C2.97842 7.90264 3.07736 8.018 3.19888 8.11117C3.31613 8.20106 3.448 8.27456 3.5937 8.33207L3.59658 8.33313C3.73566 8.38437 3.87827 8.42828 4.02439 8.46488C4.16415 8.50427 4.30222 8.54013 4.43861 8.57243C4.56859 8.60321 4.68303 8.6387 4.78249 8.67848C4.87673 8.71618 4.9454 8.76071 4.99369 8.809L4.99631 8.81148C5.03427 8.84744 5.056 8.89448 5.056 8.96535C5.056 9.03645 5.03826 9.08575 5.01049 9.1221C4.97402 9.16595 4.92808 9.20164 4.87068 9.22897C4.80849 9.25858 4.74134 9.27972 4.66871 9.29206C4.58912 9.30191 4.51561 9.30668 4.448 9.30668C4.34867 9.30668 4.25322 9.29556 4.16139 9.27358C4.07288 9.24895 3.9976 9.21466 3.93406 9.17185C3.87729 9.12795 3.83015 9.07134 3.79297 8.99984C3.75899 8.93449 3.73867 8.84838 3.73867 8.73602Z" fill="#646A73"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.2466 9.94027L9.76453 9.50154C9.89576 9.33147 9.999 9.14082 10.0744 8.93031C10.1654 8.67634 10.2102 8.40321 10.2102 8.11202C10.2102 7.81422 10.1655 7.53603 10.0747 7.27861C9.98413 7.01826 9.85308 6.78965 9.68086 6.59447C9.50763 6.39814 9.29627 6.24478 9.04854 6.13425C8.79773 6.02235 8.51563 5.96802 8.20488 5.96802C7.89739 5.96802 7.61566 6.02245 7.36191 6.13395L7.36122 6.13425C7.11349 6.24478 6.90213 6.39814 6.7289 6.59447C6.55668 6.78965 6.42563 7.01826 6.33504 7.27861C6.24423 7.53603 6.19955 7.81422 6.19955 8.11202C6.19955 8.40323 6.2446 8.67849 6.33536 8.93565C6.42619 9.18923 6.55751 9.41248 6.72977 9.60388C6.90298 9.79633 7.11407 9.94754 7.36121 10.0578L7.36347 10.0588C7.61681 10.1662 7.89799 10.2187 8.20488 10.2187C8.54657 10.2187 8.84904 10.157 9.10788 10.0284L9.67291 10.5375L10.2466 9.94027ZM7.99383 9.0156L8.25449 9.25292C8.23906 9.2532 8.22254 9.25335 8.20488 9.25335C8.03357 9.25335 7.89695 9.22116 7.78948 9.16337C7.67567 9.09855 7.58492 9.01487 7.51532 8.91198C7.44279 8.80476 7.38851 8.68421 7.35299 8.54934C7.32006 8.40712 7.30355 8.26141 7.30355 8.11202C7.30355 7.95494 7.32019 7.80356 7.35324 7.65764C7.38898 7.51532 7.44338 7.39175 7.51533 7.2854L7.51631 7.28391C7.58591 7.17798 7.67606 7.09534 7.7883 7.03467L7.79069 7.03331C7.89782 6.97251 8.03391 6.93868 8.20488 6.93868C8.37585 6.93868 8.51193 6.97253 8.61905 7.03333L8.62148 7.03465C8.73371 7.09531 8.82383 7.17799 8.89344 7.28391L8.89444 7.28539C8.96607 7.39128 9.01858 7.51433 9.05083 7.65624L9.05153 7.65902C9.0879 7.80451 9.10621 7.95541 9.10621 8.11202C9.10621 8.30609 9.0857 8.46484 9.04784 8.59104C9.02681 8.66112 9.00248 8.7236 8.97519 8.77896L8.56555 8.40472L7.99383 9.0156Z" fill="#646A73"/>
<path d="M11.6199 6.05868H10.5159V10.1334H13.4759V9.16268H11.6199V6.05868Z" fill="#646A73"/>
<path d="M1.33334 15.3334C0.965149 15.3334 0.666672 15.0349 0.666672 14.6667V1.33341C0.666672 0.965225 0.965149 0.666748 1.33334 0.666748H14.6667C15.0349 0.666748 15.3333 0.965225 15.3333 1.33341V14.6667C15.3333 15.0349 15.0349 15.3334 14.6667 15.3334H1.33334ZM2.00001 14.0001H14V2.00008H2.00001V14.0001Z" fill="#646A73"/>
</g>
<defs>
<clipPath id="clip0_2544_1401">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.99999 1.33325H4.99999C5.18409 1.33325 5.33333 1.48249 5.33333 1.66659V2.33325C5.33333 2.51735 5.18409 2.66659 4.99999 2.66659H2.66666V4.99992C2.66666 5.18401 2.51742 5.33325 2.33333 5.33325H1.66666C1.48257 5.33325 1.33333 5.18401 1.33333 4.99992V1.99992C1.33333 1.63173 1.63181 1.33325 1.99999 1.33325ZM14 14.6666H11C10.8159 14.6666 10.6667 14.5173 10.6667 14.3333V13.6666C10.6667 13.4825 10.8159 13.3333 11 13.3333H13.3333V10.9999C13.3333 10.8158 13.4826 10.6666 13.6667 10.6666H14.3333C14.5174 10.6666 14.6667 10.8158 14.6667 10.9999V13.9999C14.6667 14.3681 14.3682 14.6666 14 14.6666ZM1.33333 13.9999V10.9999C1.33333 10.8158 1.48257 10.6666 1.66666 10.6666H2.33333C2.51742 10.6666 2.66666 10.8158 2.66666 10.9999V13.3333H4.99999C5.18409 13.3333 5.33333 13.4825 5.33333 13.6666V14.3333C5.33333 14.5173 5.18409 14.6666 4.99999 14.6666H1.99999C1.63181 14.6666 1.33333 14.3681 1.33333 13.9999ZM14.6667 1.99992V4.99992C14.6667 5.18401 14.5174 5.33325 14.3333 5.33325H13.6667C13.4826 5.33325 13.3333 5.18401 13.3333 4.99992V2.66659H11C10.8159 2.66659 10.6667 2.51735 10.6667 2.33325V1.66659C10.6667 1.48249 10.8159 1.33325 11 1.33325H14C14.3682 1.33325 14.6667 1.63173 14.6667 1.99992Z" fill="#646A73"/>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 5.33309C11.2636 5.33309 10.6667 4.73616 10.6667 3.99981V1.99989C10.6667 1.63172 10.9651 1.33325 11.3333 1.33325C11.7015 1.33325 12 1.63172 12 1.99989V3.99981H14C14.3682 3.99981 14.6667 4.29827 14.6667 4.66645C14.6667 5.03462 14.3682 5.33309 14 5.33309H12ZM3.99999 10.6662C4.73637 10.6662 5.33333 11.2631 5.33333 11.9995V13.9994C5.33333 14.3676 5.03485 14.666 4.66666 14.666C4.29847 14.666 3.99999 14.3676 3.99999 13.9994V11.9995H1.99999C1.63181 11.9995 1.33333 11.701 1.33333 11.3328C1.33333 10.9647 1.63181 10.6662 1.99999 10.6662H3.99999ZM10.6667 11.9995C10.6667 11.2631 11.2636 10.6662 12 10.6662H14C14.3682 10.6662 14.6667 10.9647 14.6667 11.3328C14.6667 11.701 14.3682 11.9995 14 11.9995H12V13.9994C12 14.3676 11.7015 14.666 11.3333 14.666C10.9651 14.666 10.6667 14.3676 10.6667 13.9994V11.9995ZM5.33333 3.99981C5.33333 4.73616 4.73637 5.33309 3.99999 5.33309H1.99999C1.63181 5.33309 1.33333 5.03462 1.33333 4.66645C1.33333 4.29827 1.63181 3.99981 1.99999 3.99981H3.99999V1.99989C3.99999 1.63172 4.29847 1.33325 4.66666 1.33325C5.03485 1.33325 5.33333 1.63172 5.33333 1.99989V3.99981Z" fill="#1F2329"/>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

+8
View File
@@ -372,6 +372,7 @@
"no_fields_yet": "暂无字段"
},
"chat": {
"type": "图表类型",
"chart_type": {
"table": "明细表",
"bar": "条形图",
@@ -379,6 +380,13 @@
"line": "折线图",
"pie": "饼图"
},
"show_sql": "查看SQL",
"export_to": "导出为",
"excel": "Excel",
"picture": "图片",
"add_to_dashboard": "添加到仪表板",
"full_screen": "全屏",
"exit_full_screen": "退出全屏",
"sql_generation": "生成SQL",
"chart_generation": "生成图表",
"inference_process": "思考过程",
+5 -5
View File
@@ -6,11 +6,11 @@ import MdComponent from './component/MdComponent.vue'
import DisplayChartBlock from './component/DisplayChartBlock.vue'
import type { ChartTypes } from '@/views/chat/component/BaseChart.ts'
import { ArrowDown } from '@element-plus/icons-vue'
import ICON_BAR from '@/assets/svg/chart/bar.svg'
import ICON_COLUMN from '@/assets/svg/chart/column.svg'
import ICON_LINE from '@/assets/svg/chart/line.svg'
import ICON_PIE from '@/assets/svg/chart/pie.svg'
import ICON_TABLE from '@/assets/svg/chart/table.svg'
import ICON_BAR from '@/assets/svg/chart/icon_bar_outlined.svg'
import ICON_COLUMN from '@/assets/svg/chart/icon_dashboard_outlined.svg'
import ICON_LINE from '@/assets/svg/chart/icon_chart-line.svg'
import ICON_PIE from '@/assets/svg/chart/icon_pie_outlined.svg'
import ICON_TABLE from '@/assets/svg/chart/icon_form_outlined.svg'
import { find } from 'lodash-es'
import { useI18n } from 'vue-i18n'
@@ -4,17 +4,36 @@ import DisplayChartBlock from '@/views/chat/component/DisplayChartBlock.vue'
import { computed, ref } from 'vue'
import { concat } from 'lodash-es'
import type { ChartTypes } from '@/views/chat/component/BaseChart.ts'
import ICON_BAR from '@/assets/svg/chart/icon_bar_outlined.svg'
import ICON_COLUMN from '@/assets/svg/chart/icon_dashboard_outlined.svg'
import ICON_LINE from '@/assets/svg/chart/icon_chart-line.svg'
import ICON_PIE from '@/assets/svg/chart/icon_pie_outlined.svg'
import ICON_TABLE from '@/assets/svg/chart/icon_form_outlined.svg'
import icon_sql_outlined from '@/assets/svg/icon_sql_outlined.svg'
import icon_export_outlined from '@/assets/svg/icon_export_outlined.svg'
import icon_into_item_outlined from '@/assets/svg/icon_into-item_outlined.svg'
import icon_window_max_outlined from '@/assets/svg/icon_window-max_outlined.svg'
import icon_window_mini_outlined from '@/assets/svg/icon_window-mini_outlined.svg'
import { useI18n } from 'vue-i18n'
const props = withDefaults(
defineProps<{
message: ChatMessage
isPredict?: boolean
chatType?: ChartTypes
enlarge?: boolean
}>(),
{
isPredict: false,
chatType: undefined,
enlarge: false,
}
)
const { t } = useI18n()
const emits = defineEmits(['exitFullScreen'])
const dataObject = computed<{
fields: Array<string>
data: Array<{ [key: string]: any }>
@@ -92,12 +111,79 @@ const chartType = computed<ChartTypes>({
if (currentChartType.value) {
return currentChartType.value
}
return chartObject.value.type ?? 'table'
return props.chatType ?? chartObject.value.type ?? 'table'
},
set(v) {
currentChartType.value = v
},
})
const chartTypeList = computed(() => {
const _list = []
if (chartObject.value) {
switch (chartObject.value.type) {
case 'table':
break
case 'column':
case 'bar':
case 'line':
_list.push({
value: 'column',
name: t('chat.chart_type.column'),
icon: ICON_COLUMN,
})
_list.push({
value: 'bar',
name: t('chat.chart_type.bar'),
icon: ICON_BAR,
})
_list.push({
value: 'line',
name: t('chat.chart_type.line'),
icon: ICON_LINE,
})
break
case 'pie':
_list.push({
value: 'pie',
name: t('chat.chart_type.pie'),
icon: ICON_PIE,
})
}
}
return _list
})
function changeTable() {
chartType.value = 'table'
onTypeChange()
}
function onTypeChange() {
chartRef.value?.onTypeChange()
}
const dialogVisible = ref(false)
function openFullScreen() {
dialogVisible.value = true
}
function closeFullScreen() {
emits('exitFullScreen')
}
function onExitFullScreen() {
dialogVisible.value = false
}
function showSql() {
console.log('todo')
}
function addToDashboard() {
console.log('todo')
}
</script>
<template>
@@ -107,20 +193,136 @@ const chartType = computed<ChartTypes>({
(isPredict && message?.record?.chart && data.length > 0)
"
class="chart-component-container"
:class="{ 'full-screen': enlarge }"
>
<div class="header-bar">todo</div>
<div class="header-bar">
<div class="title">
{{ chartObject.title }}
</div>
<div class="buttons-bar">
<div class="chart-select-container">
<el-tooltip effect="dark" :content="t('chat.type')" placement="top">
<el-select
v-if="chartTypeList.length > 0"
v-model="chartType"
class="chart-select"
:class="{ 'chart-active': currentChartType !== 'table' }"
@change="onTypeChange"
>
<el-option v-for="type in chartTypeList" :key="type.value" :value="type.value">
<el-icon size="16">
<component :is="type.icon" />
</el-icon>
{{ type.name }}
</el-option>
</el-select>
</el-tooltip>
<el-tooltip effect="dark" :content="t('chat.chart_type.table')" placement="top">
<el-button
class="tool-btn"
:class="{ 'chart-active': currentChartType === 'table' }"
text
@click="changeTable"
>
<el-icon size="16">
<ICON_TABLE />
</el-icon>
</el-button>
</el-tooltip>
</div>
<div>
<el-tooltip effect="dark" :content="t('chat.show_sql')" placement="top">
<el-button class="tool-btn" text @click="showSql">
<el-icon size="16">
<icon_sql_outlined />
</el-icon>
</el-button>
</el-tooltip>
</div>
<div>
<el-tooltip effect="dark" :content="t('chat.export_to')" placement="top">
<el-button class="tool-btn" text>
<el-icon size="16">
<icon_export_outlined />
</el-icon>
</el-button>
</el-tooltip>
</div>
<div>
<el-tooltip effect="dark" :content="t('chat.add_to_dashboard')" placement="top">
<el-button class="tool-btn" text @click="addToDashboard">
<el-icon size="16">
<icon_into_item_outlined />
</el-icon>
</el-button>
</el-tooltip>
</div>
<div class="divider" />
<div v-if="!enlarge">
<el-tooltip effect="dark" :content="t('chat.full_screen')" placement="top">
<el-button class="tool-btn" text @click="openFullScreen">
<el-icon size="16">
<icon_window_max_outlined />
</el-icon>
</el-button>
</el-tooltip>
</div>
<div v-else>
<el-tooltip effect="dark" :content="t('chat.exit_full_screen')" placement="top">
<el-button class="tool-btn" text @click="closeFullScreen">
<el-icon size="16">
<icon_window_mini_outlined />
</el-icon>
</el-button>
</el-tooltip>
</div>
</div>
</div>
<div v-if="message?.record?.chart" class="chart-block">
<DisplayChartBlock
:id="message.record.id"
:id="message.record.id + (enlarge ? '-fullscreen' : '')"
ref="chartRef"
:chart-type="chartType"
:message="message"
:data="data"
/>
</div>
<el-dialog
v-if="!enlarge"
v-model="dialogVisible"
fullscreen
:show-close="false"
class="chart-fullscreen-dialog"
header-class="chart-fullscreen-dialog-header"
body-class="chart-fullscreen-dialog-body"
>
<ChartBlock
v-if="dialogVisible"
:message="message"
:is-predict="isPredict"
:chat-type="chartType"
enlarge
@exit-full-screen="onExitFullScreen"
/>
</el-dialog>
</div>
</template>
<style lang="less">
.chart-fullscreen-dialog {
padding: 0;
}
.chart-fullscreen-dialog-header {
display: none;
}
.chart-fullscreen-dialog-body {
padding: 0;
}
</style>
<style scoped lang="less">
.chart-component-container {
width: 100%;
@@ -128,18 +330,143 @@ const chartType = computed<ChartTypes>({
display: flex;
flex-direction: column;
gap: 16px;
border: 1px solid rgba(222, 224, 227, 1);
border-radius: 12px;
&.full-screen {
border: unset;
border-radius: unset;
padding: 0;
.header-bar {
border-bottom: 1px solid rgba(31, 35, 41, 0.15);
height: 55px;
padding: 16px 24px;
}
.chart-block {
margin: unset;
padding: 16px;
height: calc(100vh - 56px);
}
}
.header-bar {
height: 32px;
display: flex;
align-items: center;
flex-direction: row;
.tool-btn {
width: 24px;
height: 24px;
font-size: 16px;
font-weight: 400;
line-height: 24px;
border-radius: 6px;
color: rgba(100, 106, 115, 1);
.tool-btn-inner {
display: flex;
flex-direction: row;
align-items: center;
}
&:hover {
background: rgba(31, 35, 41, 0.1);
}
&:active {
background: rgba(31, 35, 41, 0.1);
}
}
.chart-active {
background: rgba(28, 186, 144, 0.1);
color: rgba(28, 186, 144, 1);
border-radius: 6px;
:deep(.ed-select__wrapper) {
background: transparent;
}
:deep(.ed-select__input) {
color: rgba(28, 186, 144, 1);
}
:deep(.ed-select__placeholder) {
color: rgba(28, 186, 144, 1);
}
:deep(.ed-select__caret) {
color: rgba(28, 186, 144, 1);
}
}
.title {
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
color: rgba(31, 35, 41, 1);
font-weight: 500;
font-size: 16px;
line-height: 24px;
}
.buttons-bar {
display: flex;
flex-direction: row;
align-items: center;
gap: 16px;
.divider {
width: 1px;
height: 16px;
border-left: 1px solid rgba(31, 35, 41, 0.15);
}
}
.chart-select-container {
padding: 3px;
display: flex;
flex-direction: row;
gap: 4px;
border-radius: 6px;
border: 1px solid rgba(217, 220, 223, 1);
.chart-select {
min-width: 40px;
width: 40px;
height: 24px;
:deep(.ed-select__wrapper) {
padding: 4px;
min-height: 24px;
box-shadow: unset;
border-radius: 6px;
&:hover {
background: rgba(31, 35, 41, 0.1);
}
&:active {
background: rgba(31, 35, 41, 0.1);
}
}
:deep(.ed-select__caret) {
font-size: 12px !important;
}
}
}
}
.chart-block {
height: 352px;
width: 100%;
margin-top: 16px;
}
}
</style>