Skip to content

Commit

Permalink
Fix inviter id setting (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
崔庆才丨静觅 authored Jan 2, 2024
1 parent a39cd3b commit 0cdb32d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix inviter id setting",
"packageName": "@zhishuyun/hub",
"email": "[email protected]",
"dependentChangeType": "patch"
}
7 changes: 4 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import { defineComponent } from 'vue';
import { ElConfigProvider } from 'element-plus';
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';
import { getDomain, getPath, setCookie } from './utils';
import AuthPanel from './components/common/AuthPanel.vue';
import { setCookie } from 'typescript-cookie';
export default defineComponent({
components: {
Expand All @@ -23,6 +23,9 @@ export default defineComponent({
inviterId: this.$route.query.inviter_id?.toString()
};
},
mounted() {
this.onSetCookie();
},
methods: {
onSetCookie() {
// set inviter to cookies to persist
Expand All @@ -31,8 +34,6 @@ export default defineComponent({
const expiration = new Date();
expiration.setDate(expiration.getDate() + 7);
setCookie('INVITER_ID', this.inviterId, {
domain: getDomain(),
path: getPath(),
expires: expiration
});
}
Expand Down
14 changes: 9 additions & 5 deletions src/components/common/AuthPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@
import { defineComponent } from 'vue';
import { ElDialog } from 'element-plus';
import { getBaseUrlAuth } from '@/utils';
import { getCookie } from 'typescript-cookie';
export default defineComponent({
name: 'AuthPanel',
components: {
ElDialog
},
data() {
return {
iframeUrl: `${getBaseUrlAuth()}/auth/login`
};
},
computed: {
iframeUrl() {
return `${getBaseUrlAuth()}/auth/login?inviter_id=${this.inviterId}`;
},
inviterId() {
const result = getCookie('INVITER_ID') || this.$route.query.inviter_id?.toString();
console.debug('inviterId', result);
return result;
},
authenticated() {
return !!this.$store.state.token.access;
}
Expand Down
31 changes: 0 additions & 31 deletions src/utils/cookies.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './baseUrl';
export * from './mode';
export * from './log';
export * from './cookies';

0 comments on commit 0cdb32d

Please sign in to comment.