276 lines
7.9 KiB
TypeScript
276 lines
7.9 KiB
TypeScript
import boursecuLogo from '@/assets/img/boursemes_logofull.png'
|
|
import boursecuSplashLogo from '@/assets/img/boursemes-splash.png'
|
|
import boursecuLoginLogo from '@/assets/img/boursemes-login.png'
|
|
import boursecuTransactionsIcon from '@/assets/img/boursecu-transactions-icon.png'
|
|
import boursecuPhysicalReceiveIcon from '@/assets/img/boursecu-physical-receive-icon.png'
|
|
import boursecuConvertIcon from '@/assets/img/boursecu-convert-icon.png'
|
|
import boursecuWalletIcon from '@/assets/img/boursecu-wallet-icon.png'
|
|
import boursecuBuySellIcon from '@/assets/img/boursecu-buy-sell-icon.png'
|
|
import boursecuAssetsIcon from '@/assets/img/boursecu-assets-icon.png'
|
|
import boursecuHomeIcon from '@/assets/img/boursecu-home-icon.png'
|
|
import boursecuSettingsIcon from '@/assets/img/boursecu-settings-icon.png'
|
|
import bazretalaLoginLogo from '@/assets/img/bazretala-login-logo.png'
|
|
import bazretalaNavLogo from '@/assets/img/bazretala-nav-logo.png'
|
|
import bazretalaFundBg from '@/assets/img/bazretala-fund-bg.png'
|
|
import bazretalaEmptyFund from '@/assets/img/bazretala-empty-fund.png'
|
|
|
|
export function getConfigApp(key: string) {
|
|
const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user:{}
|
|
|
|
if (config) {
|
|
return config[key]
|
|
}
|
|
return null
|
|
}
|
|
|
|
export function isBoursecuProject() {
|
|
return getConfigApp('name') === 'boursecu'
|
|
}
|
|
|
|
export function isBazretalaProject() {
|
|
return getConfigApp('name') === 'bazretala'
|
|
}
|
|
|
|
export function getBoursecuTransactionsIcon() {
|
|
return boursecuTransactionsIcon
|
|
}
|
|
|
|
export function getBoursecuPhysicalReceiveIcon() {
|
|
return boursecuPhysicalReceiveIcon
|
|
}
|
|
|
|
export function getBoursecuConvertIcon() {
|
|
return boursecuConvertIcon
|
|
}
|
|
|
|
export function getBoursecuWalletIcon() {
|
|
return boursecuWalletIcon
|
|
}
|
|
|
|
export function getBoursecuBuySellIcon() {
|
|
return boursecuBuySellIcon
|
|
}
|
|
|
|
export function getBoursecuAssetsIcon() {
|
|
return boursecuAssetsIcon
|
|
}
|
|
|
|
export function getBoursecuHomeIcon() {
|
|
return boursecuHomeIcon
|
|
}
|
|
|
|
export function getBoursecuSettingsIcon() {
|
|
return boursecuSettingsIcon
|
|
}
|
|
|
|
export function getBoursecuActionIconSrc(actionId: string): string | undefined {
|
|
const icons: Record<string, string> = {
|
|
buySell: boursecuBuySellIcon,
|
|
wallet: boursecuWalletIcon,
|
|
assets: boursecuAssetsIcon,
|
|
transactions: boursecuTransactionsIcon,
|
|
physicalReceive: boursecuPhysicalReceiveIcon,
|
|
convert: boursecuConvertIcon,
|
|
home: boursecuHomeIcon,
|
|
settings: boursecuSettingsIcon,
|
|
}
|
|
|
|
return icons[actionId]
|
|
}
|
|
|
|
export function hasCustomLoginLogoLayout() {
|
|
return isBoursecuProject() || isBazretalaProject()
|
|
}
|
|
|
|
export const BOURSECU_BRAND_RED = '#bc3c3b'
|
|
export const BOURSECU_BRAND_BLUE = '#2178b5'
|
|
export const BOURSECU_BRAND_NAV = '#133050'
|
|
export const BOURSECU_COPPER_BG = '#b87333'
|
|
export const BOURSECU_COPPER_BG_LIGHT = '#fdf0e6'
|
|
export const BOURSECU_COPPER_BG_GRADIENT = 'linear-gradient(135deg, #c98a4a 0%, #a86528 100%)'
|
|
|
|
export function getProjectBrandRed() {
|
|
return isBoursecuProject() ? BOURSECU_BRAND_RED : null
|
|
}
|
|
|
|
/** رنگ اصلی دکمهها و چارت — boursecu ثابت آبی، بقیه از تنظیمات tenant */
|
|
export function getProjectPrimaryColor() {
|
|
if (isBoursecuProject()) {
|
|
return BOURSECU_BRAND_BLUE
|
|
}
|
|
|
|
const color = getConfigApp('color')
|
|
return color != null ? String(color) : undefined
|
|
}
|
|
|
|
export function resolveProjectColor(color?: string | null) {
|
|
if (!color || !isBoursecuProject()) {
|
|
return color
|
|
}
|
|
|
|
if (color === 'red' || color.startsWith('red-')) {
|
|
return BOURSECU_BRAND_RED
|
|
}
|
|
|
|
return color
|
|
}
|
|
|
|
export function getProjectLoginLogo(avatar?: string | null) {
|
|
if (isBoursecuProject()) {
|
|
return boursecuLoginLogo
|
|
}
|
|
if (isBazretalaProject()) {
|
|
return bazretalaLoginLogo
|
|
}
|
|
return avatar ?? getConfigApp('avatar')
|
|
}
|
|
|
|
/** لوگوی صفحه لودینگ اولیه — جدا از لوگوی لاگین/ناوبری */
|
|
export function getProjectSplashLogo(avatar?: string | null) {
|
|
if (isBoursecuProject()) {
|
|
return boursecuSplashLogo
|
|
}
|
|
return getProjectLoginLogo(avatar)
|
|
}
|
|
|
|
export function getProjectNavLogo(avatar?: string | null) {
|
|
if (isBazretalaProject()) {
|
|
return bazretalaNavLogo
|
|
}
|
|
if (isBoursecuProject()) {
|
|
return boursecuLogo
|
|
}
|
|
return avatar ?? getConfigApp('avatar')
|
|
}
|
|
|
|
/** لوگوی ناوبری موبایل — boursecu همان لوگوی لاگین (پسزمینه سفید) */
|
|
export function getProjectMobileNavLogo(avatar?: string | null) {
|
|
if (isBoursecuProject()) {
|
|
return boursecuLoginLogo
|
|
}
|
|
return getProjectNavLogo(avatar)
|
|
}
|
|
|
|
export const BAZRETALA_SUPPORT_PHONE = '09121784258'
|
|
|
|
export function getProjectSupportPhone() {
|
|
if (isBazretalaProject()) {
|
|
return BAZRETALA_SUPPORT_PHONE
|
|
}
|
|
return ''
|
|
}
|
|
|
|
export function getProjectSupportPhoneLink() {
|
|
const phone = getProjectSupportPhone()
|
|
return phone ? `tel:${phone}` : 'tel:'
|
|
}
|
|
|
|
export const BAZRETALA_BALE_ID = 'bazretala'
|
|
|
|
export function getProjectBaleLink() {
|
|
if (isBazretalaProject()) {
|
|
return `https://ble.ir/${BAZRETALA_BALE_ID}`
|
|
}
|
|
return 'https://ble.ir/'
|
|
}
|
|
|
|
export function getProjectBaleContactLink() {
|
|
if (getConfigApp('name') === 'garoosi') {
|
|
return 'https://ble.ir/garoosiadmin'
|
|
}
|
|
return getProjectBaleLink()
|
|
}
|
|
|
|
/** لینک دکمه «تماس با پشتیبانی» — bazretala به بله، garoosi تماس، بقیه تلفن پشتیبانی */
|
|
export function getProjectSupportContactLink() {
|
|
if (isBazretalaProject()) {
|
|
return getProjectBaleLink()
|
|
}
|
|
if (getConfigApp('name') === 'garoosi') {
|
|
return 'tel:09031265925'
|
|
}
|
|
return getProjectSupportPhoneLink()
|
|
}
|
|
|
|
export function getProjectFundHeaderBackground(defaultBackground: string) {
|
|
if (isBazretalaProject()) {
|
|
return bazretalaFundBg
|
|
}
|
|
return defaultBackground
|
|
}
|
|
|
|
export function getProjectFundEmptyImage(defaultImage: string) {
|
|
if (isBazretalaProject()) {
|
|
return bazretalaEmptyFund
|
|
}
|
|
return defaultImage
|
|
}
|
|
|
|
export function getProjectFundEmptyText() {
|
|
if (isBazretalaProject()) {
|
|
return 'یک بذر جدید بکار!'
|
|
}
|
|
return 'یک گنج جدید بساز!'
|
|
}
|
|
|
|
export function getProjectLoginTaglineLines() {
|
|
if (!isBoursecuProject()) {
|
|
return null
|
|
}
|
|
|
|
return [
|
|
'مرجع هوشمند معاملات',
|
|
' و سرمایهگذاری در صنعت مس',
|
|
]
|
|
}
|
|
|
|
export function getProjectSplashBackground() {
|
|
return isBoursecuProject() ? BOURSECU_BRAND_NAV : '#ffffff'
|
|
}
|
|
|
|
/** Reset splash-time inline backgrounds so mobile overscroll shows white again. */
|
|
export function resetAppSurfaceBackground() {
|
|
const background = '#ffffff'
|
|
document.documentElement.style.backgroundColor = background
|
|
document.body.style.backgroundColor = background
|
|
|
|
const metaTheme = document.querySelector('meta[name="theme-color"]')
|
|
if (metaTheme) {
|
|
metaTheme.setAttribute('content', background)
|
|
}
|
|
}
|
|
|
|
export function getProjectFontFamily() {
|
|
return getConfigApp('name') === 'boursecu' ? "'dana', sans-serif" : "'iran-sans', sans-serif"
|
|
}
|
|
|
|
export function applyProjectFont() {
|
|
document.documentElement.style.setProperty('--App-font-family', getProjectFontFamily())
|
|
if (getConfigApp('name') === 'boursecu') {
|
|
document.documentElement.classList.add('font-dana')
|
|
}
|
|
}
|
|
export function isTWA() {
|
|
if (sessionStorage.getItem('appMode') === 'twa') return true;
|
|
if (document.referrer.startsWith('android-app://')) {
|
|
sessionStorage.setItem('appMode', 'twa');
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
export function applyProjectTheme() {
|
|
applyProjectFont()
|
|
|
|
if (!isBoursecuProject()) {
|
|
return
|
|
}
|
|
|
|
document.documentElement.classList.add('project-boursecu')
|
|
document.documentElement.style.setProperty('--App-primary-color', BOURSECU_BRAND_BLUE)
|
|
document.documentElement.style.setProperty('--App-brand-nav', BOURSECU_BRAND_NAV)
|
|
document.documentElement.style.setProperty('--App-brand-red', BOURSECU_BRAND_RED)
|
|
document.documentElement.style.setProperty('--App-brand-red-50', '#f8ecec')
|
|
document.documentElement.style.setProperty('--App-brand-red-100', '#f0d8d8')
|
|
document.documentElement.style.setProperty('--App-brand-red-700', '#963130')
|
|
}
|