From aa23c51a53d02ee74076ce772cfae9d830c2e8fa Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Mon, 1 Apr 2024 13:33:57 +0800 Subject: [PATCH 1/7] perf(Setting): add tabActiveKey state to Setting component --- web/src/pages/Setting/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/src/pages/Setting/index.js b/web/src/pages/Setting/index.js index fe38ea71..00683e14 100644 --- a/web/src/pages/Setting/index.js +++ b/web/src/pages/Setting/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import SystemSetting from '../../components/SystemSetting'; import { isRoot } from '../../helpers'; import OtherSetting from '../../components/OtherSetting'; @@ -7,6 +7,7 @@ import OperationSetting from '../../components/OperationSetting'; import { Layout, TabPane, Tabs } from '@douyinfe/semi-ui'; const Setting = () => { + const [tabActiveKey, setTabActiveKey] = useState('1'); let panes = [ { tab: '个人设置', @@ -37,10 +38,14 @@ const Setting = () => {
- + setTabActiveKey(key)} + > {panes.map((pane) => ( - {pane.content} + {tabActiveKey === pane.itemKey && pane.content} ))} From 278fd39195bb9327733f64b89e71dcf2b39d78dc Mon Sep 17 00:00:00 2001 From: Maple Gao Date: Mon, 1 Apr 2024 14:33:58 +0800 Subject: [PATCH 2/7] feat: add Claude TopK --- relay/channel/claude/relay-claude.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/relay/channel/claude/relay-claude.go b/relay/channel/claude/relay-claude.go index 4de8dc01..2b5d3d22 100644 --- a/relay/channel/claude/relay-claude.go +++ b/relay/channel/claude/relay-claude.go @@ -34,6 +34,7 @@ func requestOpenAI2ClaudeComplete(textRequest dto.GeneralOpenAIRequest) *ClaudeR StopSequences: nil, Temperature: textRequest.Temperature, TopP: textRequest.TopP, + TopK: textRequest.TopK, Stream: textRequest.Stream, } if claudeRequest.MaxTokensToSample == 0 { @@ -63,6 +64,7 @@ func requestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*ClaudeR StopSequences: nil, Temperature: textRequest.Temperature, TopP: textRequest.TopP, + TopK: textRequest.TopK, Stream: textRequest.Stream, } if claudeRequest.MaxTokens == 0 { From 290dcf75872e10cdc67bf890b3589baa6e116347 Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Mon, 1 Apr 2024 13:51:07 +0800 Subject: [PATCH 3/7] perf(Setting): add useEffect and useNavigate hooks to Setting component --- web/src/pages/Setting/index.js | 35 ++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/web/src/pages/Setting/index.js b/web/src/pages/Setting/index.js index 00683e14..71e3cf88 100644 --- a/web/src/pages/Setting/index.js +++ b/web/src/pages/Setting/index.js @@ -1,18 +1,21 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; +import { Layout, TabPane, Tabs } from '@douyinfe/semi-ui'; +import { useNavigate, useLocation } from 'react-router-dom'; + import SystemSetting from '../../components/SystemSetting'; import { isRoot } from '../../helpers'; import OtherSetting from '../../components/OtherSetting'; import PersonalSetting from '../../components/PersonalSetting'; import OperationSetting from '../../components/OperationSetting'; -import { Layout, TabPane, Tabs } from '@douyinfe/semi-ui'; - const Setting = () => { + const navigate = useNavigate(); + const location = useLocation(); const [tabActiveKey, setTabActiveKey] = useState('1'); let panes = [ { tab: '个人设置', content: , - itemKey: '1', + itemKey: 'personal', }, ]; @@ -20,28 +23,40 @@ const Setting = () => { panes.push({ tab: '运营设置', content: , - itemKey: '2', + itemKey: 'operation', }); panes.push({ tab: '系统设置', content: , - itemKey: '3', + itemKey: 'system', }); panes.push({ tab: '其他设置', content: , - itemKey: '4', + itemKey: 'other', }); } - + const onChangeTab = (key) => { + setTabActiveKey(key); + navigate(`?tab=${key}`); + }; + useEffect(() => { + const searchParams = new URLSearchParams(window.location.search); + const tab = searchParams.get('tab'); + if (tab) { + setTabActiveKey(tab); + } else { + onChangeTab('personal'); + } + }, [location.search]); return (
setTabActiveKey(key)} + activeKey={tabActiveKey} + onChange={(key) => onChangeTab(key)} > {panes.map((pane) => ( From 658bf2ad57f03d5da7d9f36543ab3368708f2c83 Mon Sep 17 00:00:00 2001 From: GAI Group <133845290+AI-ASS@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:49:56 +0800 Subject: [PATCH 4/7] Rename .prettierrc.mjs to .prettierrc.mjs --- web/.prettierrc.mjs | 1 + web/.prettierrc.mjs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 web/.prettierrc.mjs delete mode 100644 web/.prettierrc.mjs diff --git a/web/.prettierrc.mjs b/web/.prettierrc.mjs new file mode 100644 index 00000000..ecae84d3 --- /dev/null +++ b/web/.prettierrc.mjs @@ -0,0 +1 @@ +module.exports = require("@so1ve/prettier-config"); diff --git a/web/.prettierrc.mjs b/web/.prettierrc.mjs deleted file mode 100644 index 7890fda6..00000000 --- a/web/.prettierrc.mjs +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("@so1ve/prettier-config"); \ No newline at end of file From 224746b45a776ea8b07aeddc042d0425c383d40c Mon Sep 17 00:00:00 2001 From: Ghostz <137054651+ye4293@users.noreply.github.com> Date: Tue, 2 Apr 2024 01:13:12 +0800 Subject: [PATCH 5/7] Update misc.go --- controller/misc.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/controller/misc.go b/controller/misc.go index ac094b2b..71c74190 100644 --- a/controller/misc.go +++ b/controller/misc.go @@ -120,18 +120,28 @@ func SendEmailVerification(c *gin.Context) { }) return } - if common.EmailDomainRestrictionEnabled { + if config.EmailDomainRestrictionEnabled { + parts := strings.Split(email, "@") + localPart := parts[0] + domainPart := parts[1] + + containsSpecialSymbols := strings.Contains(localPart, "+") || strings.Count(localPart, ".") > 1 allowed := false - for _, domain := range common.EmailDomainWhitelist { - if strings.HasSuffix(email, "@"+domain) { + for _, domain := range config.EmailDomainWhitelist { + if domainPart == domain { allowed = true break } } - if !allowed { + if allowed && !containsSpecialSymbols { + c.JSON(http.StatusOK, gin.H{ + "success": true, + "message": "Your email address is allowed.", + }) + } else { c.JSON(http.StatusOK, gin.H{ "success": false, - "message": "管理员启用了邮箱域名白名单,您的邮箱地址的域名不在白名单中", + "message": "The administrator has enabled the email domain name whitelist, and your email address is not allowed due to special symbols or it's not in the whitelist.", }) return } From d6e373fbe40d834f26a7bda2c5134735e9327f0b Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Tue, 2 Apr 2024 10:58:21 +0800 Subject: [PATCH 6/7] fix(helpers): add key prop to Tag components --- web/src/helpers/render.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/web/src/helpers/render.js b/web/src/helpers/render.js index a71215ea..f490a721 100644 --- a/web/src/helpers/render.js +++ b/web/src/helpers/render.js @@ -10,37 +10,45 @@ export function renderText(text, limit) { export function renderGroup(group) { if (group === '') { - return default; + return ( + + default + + ); } let groups = group.split(','); groups.sort(); return ( - <> + {groups.map((group) => { if (group === 'vip' || group === 'pro') { return ( - + {group} ); } else if (group === 'svip' || group === 'premium') { return ( - + {group} ); } if (group === 'default') { - return {group}; + return ( + + {group} + + ); } else { return ( - + {group} ); } })} - + ); } From 3e90b6d516c4613044d293a84e3a35ca53333cfa Mon Sep 17 00:00:00 2001 From: QuentinHsu Date: Tue, 2 Apr 2024 13:16:02 +0800 Subject: [PATCH 7/7] refactor(helpers): renderGroup function --- web/src/helpers/render.js | 60 ++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/web/src/helpers/render.js b/web/src/helpers/render.js index f490a721..cd1f8d93 100644 --- a/web/src/helpers/render.js +++ b/web/src/helpers/render.js @@ -8,46 +8,36 @@ export function renderText(text, limit) { return text; } +/** + * Render group tags based on the input group string + * @param {string} group - The input group string + * @returns {JSX.Element} - The rendered group tags + */ export function renderGroup(group) { if (group === '') { - return ( - - default - - ); + return default; } - let groups = group.split(','); - groups.sort(); + + const tagColors = { + 'vip': 'yellow', + 'pro': 'yellow', + 'svip': 'red', + 'premium': 'red' + }; + + const groups = group.split(',').sort(); + return ( - {groups.map((group) => { - if (group === 'vip' || group === 'pro') { - return ( - - {group} - - ); - } else if (group === 'svip' || group === 'premium') { - return ( - - {group} - - ); - } - if (group === 'default') { - return ( - - {group} - - ); - } else { - return ( - - {group} - - ); - } - })} + {groups.map((group) => ( + + {group} + + ))} ); }