diff --git a/common/constants.go b/common/constants.go index aefe72f..5815802 100644 --- a/common/constants.go +++ b/common/constants.go @@ -144,11 +144,13 @@ var ( // All duration's unit is seconds // Shouldn't larger then RateLimitKeyExpirationDuration var ( - GlobalApiRateLimitNum = GetEnvOrDefault("GLOBAL_API_RATE_LIMIT", 180) - GlobalApiRateLimitDuration int64 = 3 * 60 + GlobalApiRateLimitEnable = GetEnvOrDefaultBool("GLOBAL_API_RATE_LIMIT_ENABLE", true) + 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 + GlobalWebRateLimitEnable = GetEnvOrDefaultBool("GLOBAL_WEB_RATE_LIMIT_ENABLE", true) + GlobalWebRateLimitNum = GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT", 60) + GlobalWebRateLimitDuration = int64(GetEnvOrDefault("GLOBAL_WEB_RATE_LIMIT_DURATION", 180)) UploadRateLimitNum = 10 UploadRateLimitDuration int64 = 60 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) { 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} /> - ); }; 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..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) { { @@ -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..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) => @@ -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..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) { @@ -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..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) { { @@ -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..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) { @@ -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..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) { @@ -123,7 +123,7 @@ export default function SettingsSensitiveWords(props) { -