From 674abe5ae26e61dfba91bfcf2b36f07db2773bd1 Mon Sep 17 00:00:00 2001 From: licoy Date: Tue, 12 Nov 2024 16:30:51 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E7=BB=9F=E4=B8=80=E8=BF=90?= =?UTF-8?q?=E8=90=A5=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=8C=89=E9=92=AE=E5=A4=A7=E5=B0=8F=E8=A7=84=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Setting/Operation/SettingsCreditLimit.js | 2 +- web/src/pages/Setting/Operation/SettingsDataDashboard.js | 2 +- web/src/pages/Setting/Operation/SettingsDrawing.js | 2 +- web/src/pages/Setting/Operation/SettingsGeneral.js | 2 +- web/src/pages/Setting/Operation/SettingsLog.js | 2 +- web/src/pages/Setting/Operation/SettingsMonitoring.js | 2 +- web/src/pages/Setting/Operation/SettingsSensitiveWords.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/web/src/pages/Setting/Operation/SettingsCreditLimit.js b/web/src/pages/Setting/Operation/SettingsCreditLimit.js index ed5862a..ce3960f 100644 --- a/web/src/pages/Setting/Operation/SettingsCreditLimit.js +++ b/web/src/pages/Setting/Operation/SettingsCreditLimit.js @@ -144,7 +144,7 @@ export default function SettingsCreditLimit(props) { - diff --git a/web/src/pages/Setting/Operation/SettingsDataDashboard.js b/web/src/pages/Setting/Operation/SettingsDataDashboard.js index de0911e..5955da7 100644 --- a/web/src/pages/Setting/Operation/SettingsDataDashboard.js +++ b/web/src/pages/Setting/Operation/SettingsDataDashboard.js @@ -135,7 +135,7 @@ export default function DataDashboard(props) { - diff --git a/web/src/pages/Setting/Operation/SettingsDrawing.js b/web/src/pages/Setting/Operation/SettingsDrawing.js index e951bb0..1f47ff4 100644 --- a/web/src/pages/Setting/Operation/SettingsDrawing.js +++ b/web/src/pages/Setting/Operation/SettingsDrawing.js @@ -178,7 +178,7 @@ export default function SettingsDrawing(props) { - diff --git a/web/src/pages/Setting/Operation/SettingsGeneral.js b/web/src/pages/Setting/Operation/SettingsGeneral.js index cdb6f33..0d4b650 100644 --- a/web/src/pages/Setting/Operation/SettingsGeneral.js +++ b/web/src/pages/Setting/Operation/SettingsGeneral.js @@ -184,7 +184,7 @@ export default function GeneralSettings(props) { - diff --git a/web/src/pages/Setting/Operation/SettingsLog.js b/web/src/pages/Setting/Operation/SettingsLog.js index 6977dca..ddb3f99 100644 --- a/web/src/pages/Setting/Operation/SettingsLog.js +++ b/web/src/pages/Setting/Operation/SettingsLog.js @@ -135,7 +135,7 @@ export default function SettingsLog(props) { - diff --git a/web/src/pages/Setting/Operation/SettingsMonitoring.js b/web/src/pages/Setting/Operation/SettingsMonitoring.js index fc86b97..8a3d776 100644 --- a/web/src/pages/Setting/Operation/SettingsMonitoring.js +++ b/web/src/pages/Setting/Operation/SettingsMonitoring.js @@ -142,7 +142,7 @@ export default function SettingsMonitoring(props) { - diff --git a/web/src/pages/Setting/Operation/SettingsSensitiveWords.js b/web/src/pages/Setting/Operation/SettingsSensitiveWords.js index 21583b6..c7b43a3 100644 --- a/web/src/pages/Setting/Operation/SettingsSensitiveWords.js +++ b/web/src/pages/Setting/Operation/SettingsSensitiveWords.js @@ -123,7 +123,7 @@ export default function SettingsSensitiveWords(props) { - From cdc02f660b64c49c192a9545ecc4b6d3c1555d6e Mon Sep 17 00:00:00 2001 From: licoy Date: Tue, 12 Nov 2024 16:32:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96switch=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E5=A4=A7=E5=B0=8F=E8=A7=84=E6=A0=BC=E4=B8=8E?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E8=A1=A8=E5=8D=95=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/Setting/Operation/SettingsDataDashboard.js | 2 +- web/src/pages/Setting/Operation/SettingsDrawing.js | 12 ++++++------ web/src/pages/Setting/Operation/SettingsGeneral.js | 6 +++--- web/src/pages/Setting/Operation/SettingsLog.js | 2 +- .../pages/Setting/Operation/SettingsMonitoring.js | 4 ++-- .../Setting/Operation/SettingsSensitiveWords.js | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/web/src/pages/Setting/Operation/SettingsDataDashboard.js b/web/src/pages/Setting/Operation/SettingsDataDashboard.js index 5955da7..98e0d43 100644 --- a/web/src/pages/Setting/Operation/SettingsDataDashboard.js +++ b/web/src/pages/Setting/Operation/SettingsDataDashboard.js @@ -87,7 +87,7 @@ export default function DataDashboard(props) { { diff --git a/web/src/pages/Setting/Operation/SettingsDrawing.js b/web/src/pages/Setting/Operation/SettingsDrawing.js index 1f47ff4..c842cd7 100644 --- a/web/src/pages/Setting/Operation/SettingsDrawing.js +++ b/web/src/pages/Setting/Operation/SettingsDrawing.js @@ -81,7 +81,7 @@ export default function SettingsDrawing(props) { { @@ -96,7 +96,7 @@ export default function SettingsDrawing(props) { @@ -111,7 +111,7 @@ export default function SettingsDrawing(props) { @@ -126,7 +126,7 @@ export default function SettingsDrawing(props) { @@ -146,7 +146,7 @@ export default function SettingsDrawing(props) { --relax 以及 --turbo 参数 } - size='large' + size='default' checkedText='|' uncheckedText='〇' onChange={(value) => @@ -165,7 +165,7 @@ export default function SettingsDrawing(props) { 检测必须等待绘图成功才能进行放大等操作 } - size='large' + size='default' checkedText='|' uncheckedText='〇' onChange={(value) => diff --git a/web/src/pages/Setting/Operation/SettingsGeneral.js b/web/src/pages/Setting/Operation/SettingsGeneral.js index 0d4b650..e315c7c 100644 --- a/web/src/pages/Setting/Operation/SettingsGeneral.js +++ b/web/src/pages/Setting/Operation/SettingsGeneral.js @@ -141,7 +141,7 @@ export default function GeneralSettings(props) { { @@ -156,7 +156,7 @@ export default function GeneralSettings(props) { @@ -171,7 +171,7 @@ export default function GeneralSettings(props) { diff --git a/web/src/pages/Setting/Operation/SettingsLog.js b/web/src/pages/Setting/Operation/SettingsLog.js index ddb3f99..4aa9311 100644 --- a/web/src/pages/Setting/Operation/SettingsLog.js +++ b/web/src/pages/Setting/Operation/SettingsLog.js @@ -102,7 +102,7 @@ export default function SettingsLog(props) { { diff --git a/web/src/pages/Setting/Operation/SettingsMonitoring.js b/web/src/pages/Setting/Operation/SettingsMonitoring.js index 8a3d776..684ad84 100644 --- a/web/src/pages/Setting/Operation/SettingsMonitoring.js +++ b/web/src/pages/Setting/Operation/SettingsMonitoring.js @@ -114,7 +114,7 @@ export default function SettingsMonitoring(props) { { @@ -129,7 +129,7 @@ export default function SettingsMonitoring(props) { diff --git a/web/src/pages/Setting/Operation/SettingsSensitiveWords.js b/web/src/pages/Setting/Operation/SettingsSensitiveWords.js index c7b43a3..5c3a851 100644 --- a/web/src/pages/Setting/Operation/SettingsSensitiveWords.js +++ b/web/src/pages/Setting/Operation/SettingsSensitiveWords.js @@ -77,7 +77,7 @@ export default function SettingsSensitiveWords(props) { { @@ -92,7 +92,7 @@ export default function SettingsSensitiveWords(props) { From 67d09d68c6a6d53cba1c2f27344bd2d5bc7c2354 Mon Sep 17 00:00:00 2001 From: licoy Date: Tue, 12 Nov 2024 17:00:06 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=AE=A1=E7=90=86=E6=93=8D=E4=BD=9C=E6=A0=8F=E5=9D=87?= =?UTF-8?q?=E4=B8=BA=E9=A1=B6=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/ChannelsTable.js | 415 ++++++++++++------------- web/src/components/LogsTable.js | 30 +- web/src/components/RedemptionsTable.js | 65 ++-- web/src/components/TokensTable.js | 67 ++-- web/src/components/UsersTable.js | 20 +- 5 files changed, 297 insertions(+), 300 deletions(-) diff --git a/web/src/components/ChannelsTable.js b/web/src/components/ChannelsTable.js index 2942a0b..d09f34f 100644 --- a/web/src/components/ChannelsTable.js +++ b/web/src/components/ChannelsTable.js @@ -17,7 +17,7 @@ import { renderQuota, } from '../helpers/render'; import { - Button, + Button, Divider, Dropdown, Form, InputNumber, @@ -707,226 +707,217 @@ const ChannelsTable = () => { }; return ( - <> - -
{ - searchChannels(searchKeyword, searchGroup, searchModel); - }} - labelPosition='left' - > -
- - { - setSearchKeyword(v.trim()); - }} - /> - { - setSearchModel(v.trim()); - }} - /> - { - setSearchGroup(v); - searchChannels(searchKeyword, v, searchModel); - }} - /> + <> + + { + searchChannels(searchKeyword, searchGroup, searchModel); + }} + labelPosition='left' + > +
+ + { + setSearchKeyword(v.trim()); + }} + /> + { + setSearchModel(v.trim()); + }} + /> + { + setSearchGroup(v); + searchChannels(searchKeyword, v, searchModel); + }} + /> + + +
+ + +
+ + 使用ID排序 + { + localStorage.setItem('id-sort', v + ''); + setIdSort(v); + loadChannels(0, pageSize, v) + .then() + .catch((reason) => { + showError(reason); + }); + }} + > + + + + + + + + + + +
- -
- +
- 使用ID排序 + 开启批量删除 { - localStorage.setItem('id-sort', v + ''); - setIdSort(v); - loadChannels(0, pageSize, v) - .then() - .catch((reason) => { - showError(reason); - }); - }} + label='开启批量删除' + uncheckedText='关' + aria-label='是否开启批量删除' + onChange={(v) => { + setEnableBatchDelete(v); + }} > - - -
- - '', - onPageSizeChange: (size) => { - handlePageSizeChange(size).then(); - }, - onPageChange: handlePageChange, - }} - loading={loading} - onRow={handleRow} - rowSelection={ - enableBatchDelete - ? { - onChange: (selectedRowKeys, selectedRows) => { - // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); - setSelectedChannels(selectedRows); - }, - } - : null - } - /> -
- - - - - - - - - - - - - - - {/*
*/} - - {/*
*/} -
-
- - 开启批量删除 - { - setEnableBatchDelete(v); - }} - > - - - - - - - -
- + + + + + + + + +
'', + onPageSizeChange: (size) => { + handlePageSizeChange(size).then(); + }, + onPageChange: handlePageChange, + }} + loading={loading} + onRow={handleRow} + rowSelection={ + enableBatchDelete + ? { + onChange: (selectedRowKeys, selectedRows) => { + // console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows); + setSelectedChannels(selectedRows); + }, + } + : null + } + /> + ); }; diff --git a/web/src/components/LogsTable.js b/web/src/components/LogsTable.js index a7c3c8f..28e1a1a 100644 --- a/web/src/components/LogsTable.js +++ b/web/src/components/LogsTable.js @@ -767,6 +767,22 @@ const LogsTable = () => { +
+ +
{ onPageChange: handlePageChange, }} /> - ); diff --git a/web/src/components/RedemptionsTable.js b/web/src/components/RedemptionsTable.js index 09d812b..a8cb017 100644 --- a/web/src/components/RedemptionsTable.js +++ b/web/src/components/RedemptionsTable.js @@ -10,7 +10,7 @@ import { import { ITEMS_PER_PAGE } from '../constants'; import { renderQuota } from '../helpers/render'; import { - Button, + Button, Divider, Form, Modal, Popconfirm, @@ -391,6 +391,39 @@ const RedemptionsTable = () => { onChange={handleKeywordChange} /> + +
+ + +
{ rowSelection={rowSelection} onRow={handleRow} >
- - ); }; diff --git a/web/src/components/TokensTable.js b/web/src/components/TokensTable.js index c8ba584..e3cdca9 100644 --- a/web/src/components/TokensTable.js +++ b/web/src/components/TokensTable.js @@ -10,7 +10,7 @@ import { import { ITEMS_PER_PAGE } from '../constants'; import {renderGroup, renderQuota} from '../helpers/render'; import { - Button, + Button, Divider, Dropdown, Form, Modal, @@ -596,6 +596,40 @@ const TokensTable = () => { 查询 + +
+ + +
{ rowSelection={rowSelection} onRow={handleRow} >
- - ); }; diff --git a/web/src/components/UsersTable.js b/web/src/components/UsersTable.js index 060267e..fddb30c 100644 --- a/web/src/components/UsersTable.js +++ b/web/src/components/UsersTable.js @@ -476,10 +476,18 @@ const UsersTable = () => { type='primary' htmlType='submit' className='btn-margin-right' - style={{ marginRight: 8 }} > 查询 +
@@ -496,16 +504,6 @@ const UsersTable = () => { }} loading={loading} /> - ); }; From fad29a8cc2b780effd15403f98294755a992cfb0 Mon Sep 17 00:00:00 2001 From: licoy Date: Tue, 12 Nov 2024 19:59:42 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0`GLOBAL=5FAPI=5FR?= =?UTF-8?q?ATE=5FLIMIT=5FDURATION`=E4=B8=8E`GLOBAL=5FWEB=5FRATE=5FLIMIT=5F?= =?UTF-8?q?DURATION`=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8E=A7=E5=88=B6=E8=AE=BF=E9=97=AE=E9=80=9F=E7=8E=87?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/constants.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/constants.go b/common/constants.go index aefe72f..914c558 100644 --- a/common/constants.go +++ b/common/constants.go @@ -144,11 +144,11 @@ var ( // All duration's unit is seconds // Shouldn't larger then RateLimitKeyExpirationDuration var ( - GlobalApiRateLimitNum = GetEnvOrDefault("GLOBAL_API_RATE_LIMIT", 180) - GlobalApiRateLimitDuration int64 = 3 * 60 + GlobalApiRateLimitNum = GetEnvOrDefault("GLOBAL_API_RATE_LIMIT", 180) + GlobalApiRateLimitDuration = int64(GetEnvOrDefault("GLOBAL_API_RATE_LIMIT_DURATION", 180)) - GlobalWebRateLimitNum = GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT", 60) - GlobalWebRateLimitDuration int64 = 3 * 60 + GlobalWebRateLimitNum = GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT", 60) + GlobalWebRateLimitDuration = int64(GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT_DURATION", 180)) UploadRateLimitNum = 10 UploadRateLimitDuration int64 = 60 From 08023f6d969a017318a8e1d077ba4d8d4fa1d296 Mon Sep 17 00:00:00 2001 From: licoy Date: Tue, 12 Nov 2024 20:02:33 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0`GLOBAL=5FAPI=5FR?= =?UTF-8?q?ATE=5FLIMIT=5FENABLE`=E4=B8=8E`GLOBAL=5FWEB=5FRATE=5FLIMIT=5FEN?= =?UTF-8?q?ABLE`=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=98=AF=E5=90=A6=E5=BC=80=E5=90=AF=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E9=80=9F=E7=8E=87=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/constants.go | 2 ++ middleware/rate-limit.go | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/common/constants.go b/common/constants.go index 914c558..5815802 100644 --- a/common/constants.go +++ b/common/constants.go @@ -144,9 +144,11 @@ var ( // All duration's unit is seconds // Shouldn't larger then RateLimitKeyExpirationDuration var ( + GlobalApiRateLimitEnable = GetEnvOrDefaultBool("GLOBAL_API_RATE_LIMIT_ENABLE", true) GlobalApiRateLimitNum = GetEnvOrDefault("GLOBAL_API_RATE_LIMIT", 180) GlobalApiRateLimitDuration = int64(GetEnvOrDefault("GLOBAL_API_RATE_LIMIT_DURATION", 180)) + GlobalWebRateLimitEnable = GetEnvOrDefaultBool("GLOBAL_WEB_RATE_LIMIT_ENABLE", true) GlobalWebRateLimitNum = GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT", 60) GlobalWebRateLimitDuration = int64(GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT_DURATION", 180)) diff --git a/middleware/rate-limit.go b/middleware/rate-limit.go index 8e5cff6..e38fb8f 100644 --- a/middleware/rate-limit.go +++ b/middleware/rate-limit.go @@ -13,6 +13,10 @@ var timeFormat = "2006-01-02T15:04:05.000Z" var inMemoryRateLimiter common.InMemoryRateLimiter +var defNext = func(c *gin.Context) { + c.Next() +} + func redisRateLimiter(c *gin.Context, maxRequestNum int, duration int64, mark string) { ctx := context.Background() rdb := common.RDB @@ -83,11 +87,17 @@ func rateLimitFactory(maxRequestNum int, duration int64, mark string) func(c *gi } func GlobalWebRateLimit() func(c *gin.Context) { - return rateLimitFactory(common.GlobalWebRateLimitNum, common.GlobalWebRateLimitDuration, "GW") + if common.GlobalWebRateLimitEnable { + return rateLimitFactory(common.GlobalWebRateLimitNum, common.GlobalWebRateLimitDuration, "GW") + } + return defNext } func GlobalAPIRateLimit() func(c *gin.Context) { - return rateLimitFactory(common.GlobalApiRateLimitNum, common.GlobalApiRateLimitDuration, "GA") + if common.GlobalApiRateLimitEnable { + return rateLimitFactory(common.GlobalApiRateLimitNum, common.GlobalApiRateLimitDuration, "GA") + } + return defNext } func CriticalRateLimit() func(c *gin.Context) {