Compare commits

...

2 Commits

Author SHA1 Message Date
franktrue 4907ac0fda Merge branch 'main' of https://gogs.yxxurl.com/Kelvin/api2gpt-web
continuous-integration/drone/push Build is passing Details
3 years ago
franktrue 33fa961618 使用cookies保存邀请码
3 years ago

@ -30,9 +30,10 @@ export const constantRoutes = [
path: '/m/:code',
redirect: (to) => {
// 保存参数到本地缓存或 cookie
localStorage.setItem('inviteCode', to.params.code)
// localStorage.setItem('inviteCode', to.params.code)
// 如果需要使用 cookie可以使用 document.cookie = 'inviteCode=' + to.params.code
return '/register'
document.cookie = 'inviteCode=' + to.params.code+'; domain=api2gpt.com; path=/'
window.location.href = 'https://www.api2gpt.com'
}
},
{

@ -244,3 +244,14 @@ export function getNormalPath(p) {
export function blobValidate(data) {
return data.type !== 'application/json'
}
// 定义获取 cookie 的函数
export function getCookie(name) {
const regexp = new RegExp('(^| )' + name + '=([^;]*)(;|$)')
const result = document.cookie.match(regexp)
if (result) {
return result[2]
} else {
return null
}
}

@ -95,11 +95,12 @@
<script setup>
import { ElAlert, ElMessageBox } from "element-plus";
import { getCodeMail, register } from "@/api/login";
import { getCookie } from '@/utils/ruoyi'
const router = useRouter();
const { proxy } = getCurrentInstance();
const inviteCode = localStorage.getItem('inviteCode') || ''
const inviteCode = getCookie('inviteCode')
const registerForm = ref({
username: "",
password: "",

Loading…
Cancel
Save