增加微信邀请码功能 升级到one-api最新版代码 0.5.4版本

This commit is contained in:
thinker007
2023-09-15 04:48:21 +08:00
parent dd8cc364fe
commit 7b60ccb9ba
5 changed files with 28 additions and 5 deletions

View File

@@ -18,7 +18,10 @@ const LoginForm = () => {
let navigate = useNavigate();
const [status, setStatus] = useState({});
const logo = getLogo();
let affCode = new URLSearchParams(window.location.search).get('aff');
if (affCode) {
localStorage.setItem('aff', affCode);
}
useEffect(() => {
if (searchParams.get('expired')) {
showError('未登录或登录已过期,请重新登录!');
@@ -37,8 +40,20 @@ const LoginForm = () => {
};
const onSubmitWeChatVerificationCode = async () => {
// WeChat 渠道注册也能带上邀请码链接这里检查是否之前打开过邀请码链接通过localStorage存储来寻找
if (!affCode) {
affCode = localStorage.getItem('aff');
}
// 检查 affCode 是否有值
if (affCode) {
// 如果有值,拼接到 URL 中
var url = `/api/oauth/wechat?code=${inputs.wechat_verification_code}&affCode=${affCode}`;
} else {
// 如果没有值不拼接affCode
var url = `/api/oauth/wechat?code=${inputs.wechat_verification_code}`;
}
const res = await API.get(
`/api/oauth/wechat?code=${inputs.wechat_verification_code}`
url
);
const { success, message, data } = res.data;
if (success) {