diff --git a/src/router/index.js b/src/router/index.js index ce97069..94cc0ad 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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' } }, { diff --git a/src/utils/ruoyi.js b/src/utils/ruoyi.js index 2714962..626ef48 100644 --- a/src/utils/ruoyi.js +++ b/src/utils/ruoyi.js @@ -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 + } +} \ No newline at end of file diff --git a/src/views/register.vue b/src/views/register.vue index 708af27..7f81e94 100644 --- a/src/views/register.vue +++ b/src/views/register.vue @@ -95,11 +95,12 @@