fix fallback base on show product
This commit is contained in:
+49
-1
@@ -12,6 +12,8 @@ import bazretalaNavLogo from '@/assets/img/bazretala-nav-logo.png'
|
|||||||
import bazretalaFundBg from '@/assets/img/bazretala-fund-bg.png'
|
import bazretalaFundBg from '@/assets/img/bazretala-fund-bg.png'
|
||||||
import bazretalaEmptyFund from '@/assets/img/bazretala-empty-fund.png'
|
import bazretalaEmptyFund from '@/assets/img/bazretala-empty-fund.png'
|
||||||
|
|
||||||
|
import { useSettingsStore } from '@/store/settingsStore'
|
||||||
|
|
||||||
export function getConfigApp(key: string) {
|
export function getConfigApp(key: string) {
|
||||||
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user:{}
|
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user:{}
|
||||||
|
|
||||||
@@ -244,6 +246,41 @@ export function getReferralShareTitle(projectName?: string | null) {
|
|||||||
return projectName ?? getConfigApp('name_fa') ?? getConfigApp('name') ?? 'طلا'
|
return projectName ?? getConfigApp('name_fa') ?? getConfigApp('name') ?? 'طلا'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** جایگزینی ٪نام / %نام و ٪لینک / %لینک در قالب متن دعوت */
|
||||||
|
export function renderInviteLinkText(
|
||||||
|
template: string,
|
||||||
|
options: { userName?: string | null; link?: string | null },
|
||||||
|
): string {
|
||||||
|
const userName = String(options.userName ?? '').trim()
|
||||||
|
const link = String(options.link ?? '').trim()
|
||||||
|
|
||||||
|
return template
|
||||||
|
.replace(/[%٪]\s*لینک/gu, link)
|
||||||
|
.replace(/[%٪]\s*نام/gu, userName)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveReferralLoginLink(referralId?: string | number | null): string {
|
||||||
|
const id = String(referralId ?? '').trim()
|
||||||
|
if (!id) return ''
|
||||||
|
|
||||||
|
let base = ''
|
||||||
|
try {
|
||||||
|
base = String(useSettingsStore().getSettingByKey('app_url') ?? '').trim()
|
||||||
|
} catch {
|
||||||
|
base = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if (base) {
|
||||||
|
return `${base.replace(/\/+$/, '')}/login?id=${encodeURIComponent(id)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined' && window.location?.origin) {
|
||||||
|
return `${window.location.origin}/login?id=${encodeURIComponent(id)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `/login?id=${encodeURIComponent(id)}`
|
||||||
|
}
|
||||||
|
|
||||||
export function getReferralShareText(options: {
|
export function getReferralShareText(options: {
|
||||||
userName?: string | null
|
userName?: string | null
|
||||||
projectName?: string | null
|
projectName?: string | null
|
||||||
@@ -251,11 +288,22 @@ export function getReferralShareText(options: {
|
|||||||
}) {
|
}) {
|
||||||
const userName = options.userName ?? ''
|
const userName = options.userName ?? ''
|
||||||
const referralId = options.referralId ?? ''
|
const referralId = options.referralId ?? ''
|
||||||
const link = `${window.location.hostname}/login?id=${referralId}`
|
const link = resolveReferralLoginLink(referralId)
|
||||||
const marketText = options.projectName
|
const marketText = options.projectName
|
||||||
? `بازار طلای ${options.projectName}`
|
? `بازار طلای ${options.projectName}`
|
||||||
: 'بازار طلا'
|
: 'بازار طلا'
|
||||||
|
|
||||||
|
let template = ''
|
||||||
|
try {
|
||||||
|
template = String(useSettingsStore().getSettingByKey('invite_link_text') ?? '').trim()
|
||||||
|
} catch {
|
||||||
|
template = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if (template) {
|
||||||
|
return renderInviteLinkText(template, { userName, link })
|
||||||
|
}
|
||||||
|
|
||||||
if (isBoursecuProject()) {
|
if (isBoursecuProject()) {
|
||||||
return `مس؛ فلز آینده جهان
|
return `مس؛ فلز آینده جهان
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user