CaIon
93ce48aca8
feat: restructure token usage routes and enhance token retrieval logic
2025-08-23 15:45:43 +08:00
Calcium-Ion
df1ec4832c
Merge branch 'alpha' into main
2025-08-23 15:27:08 +08:00
CaIon
6748b006b7
refactor: centralize logging and update resource initialization
...
This commit refactors the logging mechanism across the application by replacing direct logger calls with a centralized logging approach using the `common` package. Key changes include:
- Replaced instances of `logger.SysLog` and `logger.FatalLog` with `common.SysLog` and `common.FatalLog` for consistent logging practices.
- Updated resource initialization error handling to utilize the new logging structure, enhancing maintainability and readability.
- Minor adjustments to improve code clarity and organization throughout various modules.
This change aims to streamline logging and improve the overall architecture of the codebase.
2025-08-14 21:10:04 +08:00
CaIon
e2037ad756
refactor: Introduce pre-consume quota and unify relay handlers
...
This commit introduces a major architectural refactoring to improve quota management, centralize logging, and streamline the relay handling logic.
Key changes:
- **Pre-consume Quota:** Implements a new mechanism to check and reserve user quota *before* making the request to the upstream provider. This ensures more accurate quota deduction and prevents users from exceeding their limits due to concurrent requests.
- **Unified Relay Handlers:** Refactors the relay logic to use generic handlers (e.g., `ChatHandler`, `ImageHandler`) instead of provider-specific implementations. This significantly reduces code duplication and simplifies adding new channels.
- **Centralized Logger:** A new dedicated `logger` package is introduced, and all system logging calls are migrated to use it, moving this responsibility out of the `common` package.
- **Code Reorganization:** DTOs are generalized (e.g., `dalle.go` -> `openai_image.go`) and utility code is moved to more appropriate packages (e.g., `common/http.go` -> `service/http.go`) for better code structure.
2025-08-14 20:05:06 +08:00
Xyfacai
456475d593
refactor: format api page query and err result
2025-07-14 22:03:22 +08:00
t0ng7u
093d86040f
🗑️ feat(token): implement batch token deletion API & front-end integration
...
• Back-end
• model/token.go
• Add `BatchDeleteTokens(ids []int, userId int)` – transactional DB removal + async Redis cache cleanup.
• controller/token.go
• Introduce `TokenBatch` DTO and `DeleteTokenBatch` handler calling the model layer; returns amount deleted.
• router/api-router.go
• Register `POST /api/token/batch` route (user-scoped).
• Front-end (TokensTable.js)
• Replace per-token deletion loops with single request to `/api/token/batch`.
• Display dynamic i18n message: “Deleted {{count}} tokens!”.
• Add modal confirmation:
• Title “Batch delete token”.
• Content “Are you sure you want to delete the selected {{count}} tokens?”.
• UI/UX tweaks
• Responsive button group (flex-wrap, mobile line-break).
• Clear `selectedKeys` after refresh / successful deletion to avoid ghost selections.
• i18n
• Ensure placeholder style matches translation keys (`{{count}}`).
This commit delivers efficient, scalable token management and an improved user experience across devices.
2025-06-22 16:35:30 +08:00
Apple\Apple
dcefd7dfb4
🚀 feat(pagination): unify backend-driven pagination & improve channel tag aggregation
...
SUMMARY
• Migrated Token, Task, Midjourney, Channel, Redemption tables to true server-side pagination.
• Added total / page / page_size metadata in API responses; switched all affected React tables to consume new structure.
• Implemented counting helpers:
– model/token.go CountUserTokens
– model/task.go TaskCountAllTasks / TaskCountAllUserTask
– model/midjourney.go CountAllTasks / CountAllUserTask
– model/channel.go CountAllChannels / CountAllTags
• Refactored controllers (token, task, midjourney, channel) for 1-based paging & aggregated returns.
• Redesigned `ChannelsTable.js`:
– `loadChannels`, `syncPageData`, `enrichChannels` for tag-mode grouping without recursion.
– Fixed runtime white-screen (maximum call-stack) by removing child duplication.
– Pagination, search, tag-mode, idSort all hot-reload correctly.
• Removed unused `log` import in controller/midjourney.go.
BREAKING CHANGES
Front-end consumers must now expect data.items / total / page / page_size from list endpoints (`/api/channel`, `/api/task`, `/api/mj`, `/api/token`, etc.).
2025-06-12 17:25:25 +08:00
lollipopkit🏳️⚧️
530af5e358
feat: /api/token/usage
2025-04-29 17:13:28 +08:00
1808837298@qq.com
b58b1dc0ec
feat: 更新令牌生成算法
2024-09-25 16:31:25 +08:00
CalciumIon
052bc2075b
feat: 令牌分组
2024-09-18 05:19:49 +08:00
CalciumIon
f505afdc10
feat: 添加令牌ip白名单功能
2024-09-17 20:49:51 +08:00
CaIon
521ef5e219
fix: token model limit
2024-01-11 19:18:48 +08:00
CaIon
1244963e81
feat: 可设置令牌能调用的模型
2024-01-08 16:25:17 +08:00
CaIon
44d9eb9d05
完善兑换码界面
2023-11-10 00:10:41 +08:00
CaIon
3d87f868a3
令牌分页
2023-11-03 22:47:55 +08:00
JustSong
2a527ee436
fix: fix token name too long
2023-08-12 16:58:29 +08:00
Yolo°
c58f710227
feat: improve frontend ( #387 )
...
* fork
* fork
* chore: update style
---------
Co-authored-by: JustSong <songquanpeng@foxmail.com >
2023-08-12 10:49:30 +08:00
JustSong
f0c40a6cd0
fix: fix cannot enable token if set to unlimited time ( close #230 )
2023-07-02 14:47:06 +08:00
JustSong
2847a08852
feat: the format of key is now constant with that of OpenAI
2023-06-03 10:53:25 +08:00
JustSong
ea8e7c517b
fix: fix token quota not updated
2023-05-16 12:09:17 +08:00
JustSong
01abed0a30
refactor: bind quota to account instead of token ( close #64 , #31 )
2023-05-16 11:26:09 +08:00
JustSong
e6af636fa0
fix: the initial quota for new token now calculated correctly ( #51 )
2023-05-11 21:29:05 +08:00
JustSong
3071300c0c
feat: support API /dashboard/billing/credit_grants now ( #45 )
2023-05-10 09:28:41 +08:00
JustSong
601fa5cea8
refactor: use quota instead of times
2023-04-28 14:57:20 +08:00
JustSong
b9cc5dfa3f
feat: able to set initial quota for new user ( close #22 )
2023-04-26 21:40:56 +08:00
JustSong
9e2f2383b9
feat: now user can top up via redemption code ( close #9 )
2023-04-26 17:02:26 +08:00
JustSong
03491029f2
feat: limit the ability of common user to set the remaining usage times of token ( #9 )
2023-04-26 11:10:14 +08:00
JustSong
109736cc05
fix: only reduce remain times when request /v1/chat/completions ( close #15 )
...
BREAKING CHANGE: now remain_times is -1 doesn't mean unlimited times anymore!
2023-04-26 10:45:34 +08:00
JustSong
918ba60802
feat: able to set the token's expiration time and number of uses
2023-04-24 20:52:40 +08:00
JustSong
63da6dc6a0
Able to manage token now
2023-04-23 12:43:10 +08:00
JustSong
b908229429
Token API done without verification
2023-04-23 11:31:00 +08:00