Add short link (#85)

Co-authored-by: Germey <germey@acedata.cloud>
This commit is contained in:
GermeyandGermey authored and GitHub committed 2024-07-16 13:56:26 +00:00
1 parent fbdb163844
commit 7421cc22c9
69 files changed
+3201 -675

No files matched your search

+15 -8
View File
@@ -191,7 +191,7 @@ import {
ElTooltip,
ElSkeleton
} from 'element-plus';
import { distributionLevelOperator, distributionStatusOperator } from '@/operators';
import { distributionLevelOperator, distributionStatusOperator, shortUrlOperator } from '@/operators';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { userOperator } from '@/operators';
import QrCode from 'vue-qrcode';
@@ -202,6 +202,7 @@ interface IData {
invitees: IUser[];
inviteesCount: number | undefined;
distributionLevels: IDistributionLevel[];
distributionLink: string | undefined;
distributionStatus: IDistributionStatus | undefined;
loading: boolean;
}
@@ -228,6 +229,7 @@ export default defineComponent({
invitees: [],
inviteesCount: undefined,
distributionLevels: [],
distributionLink: undefined,
distributionStatus: undefined,
loading: false
};
@@ -247,13 +249,6 @@ export default defineComponent({
result[item.level] = item;
});
return result;
},
distributionLink() {
const origin = window.location.origin;
if (!this.$store.getters.user?.id) {
return origin;
}
return `${origin}?inviter_id=${this.$store.getters.user.id}`;
}
},
watch: {
@@ -265,6 +260,7 @@ export default defineComponent({
},
async mounted() {
this.onFetchData();
this.onGenerateDistributionLink();
},
methods: {
goHistory() {
@@ -305,6 +301,16 @@ export default defineComponent({
}
);
},
async onGenerateDistributionLink() {
const origin = window.location.origin;
const link = `${origin}?inviter_id=${this.$store.getters.user.id}`;
try {
const url = (await shortUrlOperator.create(link))?.data?.data?.url;
this.distributionLink = url || link;
} catch (error) {
this.distributionLink = link;
}
},
async onFetchDistributionStatus() {
const { data } = await distributionStatusOperator.getAll({
user_id: this.$store.getters.user.id
@@ -392,6 +398,7 @@ export default defineComponent({
}
.link-wrapper {
text-align: center;
margin-bottom: 10px;
.link {
color: var(--el-color-primary);