bug fix in referal link

This commit is contained in:
Hesabix 2025-04-01 11:59:05 +00:00
parent e08a6621f1
commit ec17a2f4df
2 changed files with 90 additions and 78 deletions

View file

@ -1,73 +1,49 @@
<template>
<!-- هدر -->
<v-toolbar color="toolbar" flat>
<template v-slot:prepend>
<v-tooltip text="بازگشت" location="bottom">
<template v-slot:activator="{ props }">
<v-btn v-bind="props" @click="$router.back()" class="d-none d-sm-flex" variant="text" icon="mdi-arrow-right" />
</template>
</v-tooltip>
</template>
<v-toolbar-title>
دسترسی توسعه دهندگان
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn color="success" @click="submitNew" prepend-icon="mdi-plus">
ایجاد رابط جدید
<!-- هدر -->
<v-toolbar color="toolbar" flat>
<template v-slot:prepend>
<v-tooltip text="بازگشت" location="bottom">
<template v-slot:activator="{ props }">
<v-btn v-bind="props" @click="$router.back()" class="d-none d-sm-flex" variant="text"
icon="mdi-arrow-right" />
</template>
</v-tooltip>
</template>
<v-toolbar-title>
دسترسی توسعه دهندگان
</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn color="success" @click="submitNew" prepend-icon="mdi-plus">
ایجاد رابط جدید
</v-btn>
</v-toolbar>
<v-text-field v-model="search" prepend-inner-icon="mdi-magnify" label="جست و جو ..." variant="outlined"
density="compact" hide-details class="mb-0" :rounded="0"></v-text-field>
<!-- جدول -->
<v-data-table :headers="headers" :items="items" :search="search" :loading="loading" hover
:header-props="{ class: 'custom-header' }" class="elevation-1">
<!-- ستون عملیات -->
<template v-slot:item.operation="{ item }">
<v-btn icon="mdi-delete" color="error" size="small" variant="text" @click="deleteItem(item.raw.token)">
</v-btn>
</v-toolbar>
<v-text-field
v-model="search"
prepend-inner-icon="mdi-magnify"
label="جست و جو ..."
variant="outlined"
density="compact"
hide-details
class="mb-0"
:rounded="0"
></v-text-field>
<!-- جدول -->
<v-data-table
:headers="headers"
:items="items"
:search="search"
:loading="loading"
hover
:header-props="{ class: 'custom-header' }"
</template>
class="elevation-1"
>
<!-- ستون عملیات -->
<template v-slot:item.operation="{ item }">
<v-btn
icon="mdi-delete"
color="error"
size="small"
variant="text"
@click="deleteItem(item.raw.token)"
>
</v-btn>
</template>
<!-- لودینگ -->
<template v-slot:loading>
<v-skeleton-loader type="table-row" class="my-2"></v-skeleton-loader>
</template>
<!-- لودینگ -->
<template v-slot:loading>
<v-skeleton-loader
type="table-row"
class="my-2"
></v-skeleton-loader>
</template>
<!-- پیام خالی بودن -->
<template v-slot:no-data>
اطلاعاتی برای نمایش وجود ندارد
</template>
<!-- پیام خالی بودن -->
<template v-slot:no-data>
اطلاعاتی برای نمایش وجود ندارد
</template>
<!-- پیام نتیجه جستجو -->
<template v-slot:no-results>
نتیجهای یافت نشد
</template>
</v-data-table>
<!-- پیام نتیجه جستجو -->
<template v-slot:no-results>
نتیجهای یافت نشد
</template>
</v-data-table>
</template>
<script>
@ -83,7 +59,7 @@ export default {
loading: true,
items: [],
headers: [
{
{
title: 'توکن دسترسی',
align: 'center',
key: 'token',

View file

@ -148,7 +148,7 @@ import { required } from "@vuelidate/validators";
import { useVuelidate } from "@vuelidate/core";
import { ref } from "vue";
import VueApexCharts from "vue3-apexcharts";
import { getBasePath } from "@/hesabixConfig.js";
export default {
name: "Dashboard",
components: {
@ -261,15 +261,51 @@ export default {
this.errorDialog = true;
return;
}
navigator.clipboard
.writeText(this.referralLink)
.then(() => {
// روش اول: استفاده از Clipboard API
if (navigator.clipboard && window.isSecureContext) {
navigator.clipboard.writeText(this.referralLink)
.then(() => {
this.copySuccessDialog = true;
})
.catch(() => {
// اگر روش اول شکست خورد، از روش دوم استفاده میکنیم
this.fallbackCopyToClipboard(this.referralLink);
});
} else {
// اگر Clipboard API در دسترس نیست، از روش دوم استفاده میکنیم
this.fallbackCopyToClipboard(this.referralLink);
}
},
fallbackCopyToClipboard(text) {
try {
// ایجاد یک المان موقت
const textArea = document.createElement("textarea");
textArea.value = text;
// تنظیمات استایل برای مخفی کردن المان
textArea.style.position = 'fixed';
textArea.style.top = '0';
textArea.style.left = '0';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
// تلاش برای کپی کردن
const successful = document.execCommand('copy');
document.body.removeChild(textArea);
if (successful) {
this.copySuccessDialog = true;
})
.catch(() => {
this.errorMessage = this.$t("user.copy_failed");
this.errorDialog = true;
});
} else {
throw new Error('Copy failed');
}
} catch (err) {
this.errorMessage = this.$t("user.copy_failed");
this.errorDialog = true;
}
},
async fetchMarketingData() {
try {
@ -321,17 +357,17 @@ export default {
},
},
async mounted() {
try {
const res = await axios.post("/api/user/current/info");
this.user_email = res.data.email;
this.user_fullname = res.data.fullname;
this.user_mobile = res.data.mobile;
this.referralCode = res.data.invateCode || "";
this.referralLink = this.referralCode
? `${window.location.origin}/ms/${this.referralCode}`
? `${window.location.origin + getBasePath()}ms/${this.referralCode}`
: "";
await this.fetchMarketingData();
} catch (error) {
try {} catch (error) {
this.errorMessage =
error.response?.data?.message || this.$t("dialog.error_unknown");
this.errorDialog = true;