40 Commits
Author SHA1 Message Date
mohmdsdgandCursor 9d391aeb95 feat: show selected products on public /tv board
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 17:16:59 +03:30
mohmdsdgandCursor a9d0cba909 feat: load program-settings from SuperAdmin with 3-host failover
Use /api/public/program-settings only and retry montzar/montech/montest
three rounds before showing the bootstrap error.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-18 16:10:35 +03:30
mohmdsdgandCursor 5d3ca82236 feat: align piggy, support chat and numeric input with modular app
Persian keyboards send ٫ ، and / as decimal or thousand separators, so amount
and weight fields now normalize input before parsing. Support chat reopens an
existing thread instead of starting a new one, and axios surfaces the server
message on failure.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-11 22:17:17 +03:30
mohmdsdgandCursor d2183c9a3c feat: failover SuperAdmin domains for get_user/get_version
Replace nerkh.gold with adm.montzar/montech/montest and prefer last successful URL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-11 12:13:42 +03:30
MojtabaSoumi 4361e71030 1405/05/15-change redirect route 2026-08-06 11:54:35 +03:30
mohmdsdg 46807e3089 added gholak 2026-08-03 22:36:23 +03:30
mohmdsdg d6608283f6 fix some bugs 2026-08-03 11:52:44 +03:30
mohmdsdg e41a898686 fix pargar and login 2 2026-08-01 14:10:21 +03:30
mohmdsdg 0cd3772517 fix pargar and login 2026-08-01 14:04:26 +03:30
mohmdsdg 5b0bb45e52 added chat 2 2026-07-30 18:33:08 +03:30
mohmdsdg 106b0ebbdf fix some bugs from accounting 7 2026-07-28 21:14:34 +03:30
mohmdsdg a49b20dfd4 fix some bugs from accounting 7 2026-07-28 21:02:44 +03:30
mohmdsdg 7cd3fac28b fix pargar mande 2026-07-25 12:13:30 +03:30
mohmdsdg 9319906737 fix some bugs 7 2026-07-22 12:20:39 +03:30
mohmdsdg 0106c94d24 fix some bugs 2026-07-19 21:49:31 +03:30
MojtabaSoumi 37d86ba36e 1405/04/27
-responive bugs
2026-07-18 15:46:38 +03:30
MojtabaSoumi c2a355f2de 1405/04/27
-
2026-07-18 11:30:40 +03:30
mohmdsdg bc80ddc1f1 Merge branch 'kashkool' of https://get.feep.ir/ghatreh/ghatreh_user into kashkool 2026-07-16 15:22:50 +03:30
mohmdsdg 362040a649 update 2026-07-16 15:21:53 +03:30
MojtabaSoumi a5c714a15b 1405/04/25
-
2026-07-16 12:00:57 +03:30
mohmdsdg 5d390fb225 update 2026-07-16 11:14:58 +03:30
mohmdsdg 51e3c3f0cb added pargar 2026-07-05 20:49:01 +03:30
mohmdsdg e4d92831c2 fix bugs 2026-07-02 16:26:08 +03:30
mohmdsdg 3561e8ae07 Merge remote-tracking branch 'origin/kashkool' into kashkool 2026-07-02 09:43:22 +03:30
mohmdsdg ce8029919c fix bugs 2026-07-01 22:29:18 +03:30
MojtabaSoumi 3a3a55287b 1405/04/10-fix bugs 2026-07-01 18:18:46 +03:30
MojtabaSoumi c3aaeaf91a 1405/04/10-fix bugs 2026-07-01 18:16:12 +03:30
mohmdsdg 4fa2c0d57d fix bugs 2026-06-30 22:21:56 +03:30
mohmdsdg 8b855e5ee4 fix kashkool 2026-06-29 22:43:28 +03:30
mohmdsdg be17631109 new update 2026-06-29 15:27:35 +03:30
mohmdsdg 2e159dde20 bug fixed 2026-06-13 18:03:15 +03:30
mohmdsdg 548866160c kashkool ver 1 2026-06-13 14:03:52 +03:30
mohmdsdg f7ba6963ef store 6 2026-06-13 12:20:11 +03:30
mohmdsdg 68be4fd5a1 store 2026-06-12 20:29:26 +03:30
MojtabaSoumi 511564be64 1405/03/20-fix bug in update cart 2026-06-10 17:14:20 +03:30
MojtabaSoumi bf34d0fba0 1405/03/09-fix bug in transactions & cart 2026-05-30 16:13:21 +03:30
mohmdsdg 53a3e2f61a fix error on order 2026-05-30 12:52:44 +03:30
MojtabaSoumi 518a5316cb 1405/02/30-kashkool 2026-05-20 09:41:01 +03:30
MojtabaSoumi 400178591e 1405/02/29-kashkool 2026-05-19 20:53:52 +03:30
MojtabaSoumi 80e573ecad 1405/02/29-kashkool gold 2026-05-19 20:34:34 +03:30
329 changed files with 34382 additions and 6291 deletions
+9 -5
View File
@@ -7,6 +7,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ABadge: typeof import('ant-design-vue/es')['Badge']
AButton: typeof import('ant-design-vue/es')['Button']
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
ADivider: typeof import('ant-design-vue/es')['Divider']
@@ -15,16 +16,12 @@ declare module 'vue' {
AInput: typeof import('ant-design-vue/es')['Input']
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
AModal: typeof import('ant-design-vue/es')['Modal']
ARadio: typeof import('ant-design-vue/es')['Radio']
ARadioButton: typeof import('ant-design-vue/es')['RadioButton']
ARadioGroup: typeof import('ant-design-vue/es')['RadioGroup']
ASelect: typeof import('ant-design-vue/es')['Select']
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
ASlider: typeof import('ant-design-vue/es')['Slider']
ASpin: typeof import('ant-design-vue/es')['Spin']
ASwitch: typeof import('ant-design-vue/es')['Switch']
ATag: typeof import('ant-design-vue/es')['Tag']
ATextarea: typeof import('ant-design-vue/es')['Textarea']
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
BaseDatePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/BaseDatePicker.vue')['default']
Basic: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/basic.vue')['default']
@@ -52,9 +49,13 @@ declare module 'vue' {
ExtraFooter: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/extra-footer.vue')['default']
Format: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/format.vue')['default']
GoldLoading: typeof import('./src/components/GoldLoading.vue')['default']
InstallButton: typeof import('./src/components/InstallButton.vue')['default']
ListAnim: typeof import('./src/components/ListAnim.vue')['default']
Mode: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/mode.vue')['default']
PresettedRanges: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/presetted-ranges.vue')['default']
ProductImage: typeof import('./src/components/ProductImage.vue')['default']
PwaInstallGuideModal: typeof import('./src/components/pwa/PwaInstallGuideModal.vue')['default']
PwaInstallStepIllustration: typeof import('./src/components/pwa/PwaInstallStepIllustration.vue')['default']
RangePicker: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/range-picker.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
@@ -62,12 +63,15 @@ declare module 'vue' {
Size: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/size.vue')['default']
StartEnd: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/start-end.vue')['default']
Suffix: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/suffix.vue')['default']
SupportContactBar: typeof import('./src/components/SupportContactBar.vue')['default']
SupportMessengerBrandIcon: typeof import('./src/components/SupportMessengerBrandIcon.vue')['default']
SupportMessengerPicker: typeof import('./src/components/SupportMessengerPicker.vue')['default']
Switchable: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/switchable.vue')['default']
Text: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/text.vue')['default']
Time: typeof import('./src/components/BasicPacks/BaseDatePicker/src/datePick/demo/time.vue')['default']
TradeFeeConfirmSummary: typeof import('./src/components/TradeFeeConfirmSummary.vue')['default']
TransactionSkeleton: typeof import('./src/components/TransactionSkeleton.vue')['default']
VanActionSheet: typeof import('vant/es')['ActionSheet']
VanDialog: typeof import('vant/es')['Dialog']
VanField: typeof import('vant/es')['Field']
}
}
+729 -33
View File
@@ -1,49 +1,745 @@
<!DOCTYPE html>
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="theme-color" content="#ffffff">
<title>Ghatreh</title>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.png" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content"
/>
<title>در حال بارگذاری...</title>
<!---->
<style>
#whatsapp-button {
position: fixed;
bottom: 90px;
right: 20px;
width: 60px;
height: 60px;
background-color: #ffffff;
border-radius: 50%;
:root {
--boot-bg: #ffffff;
--boot-bg-soft: #f8fafc;
--boot-card: rgba(255, 255, 255, 0.88);
--boot-border: rgba(15, 23, 42, 0.08);
--boot-text: #111827;
--boot-muted: rgba(15, 23, 42, 0.62);
--boot-accent: #2563eb;
--boot-orb: rgba(37, 99, 235, 0.10);
--boot-spinner-track: rgba(15, 23, 42, 0.10);
--boot-shadow: rgba(15, 23, 42, 0.10);
}
html,
body {
margin: 0;
min-height: 100%;
background: var(--boot-bg);
}
#app {
min-height: 100vh;
}
.boot-loader {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 4px 10px rgba(0,0,0,0.3);
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease;
z-index: 9999;
justify-content: center;
direction: rtl;
font-family:
system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
sans-serif;
background:
radial-gradient(circle at top, var(--boot-orb), transparent 38%),
linear-gradient(
135deg,
var(--boot-bg) 0%,
var(--boot-bg-soft) 100%
);
color: var(--boot-text);
overflow: hidden;
}
#whatsapp-button:hover {
transform: scale(1.1);
box-shadow: 0 6px 14px rgba(0,0,0,0.3);
.boot-loader__card {
position: relative;
width: min(340px, calc(100vw - 48px));
padding: 30px 22px 28px;
border-radius: 24px;
text-align: center;
background: var(--boot-card);
border: 1px solid var(--boot-border);
box-shadow: 0 18px 48px var(--boot-shadow);
backdrop-filter: blur(10px);
}
#whatsapp-button:hover + #whatsapp-tooltip {
opacity: 1;
transform: translateY(0);
.boot-loader__orb {
position: absolute;
top: -72px;
left: 50%;
width: 150px;
height: 150px;
transform: translateX(-50%);
border-radius: 999px;
background: var(--boot-orb);
filter: blur(8px);
pointer-events: none;
}
.boot-loader__spinner {
position: relative;
z-index: 1;
width: 56px;
height: 56px;
margin: 0 auto 20px;
border-radius: 999px;
border: 4px solid var(--boot-spinner-track);
border-top-color: var(--boot-accent);
animation: boot-spin 0.9s linear infinite;
}
.boot-loader__title {
position: relative;
z-index: 1;
margin: 0;
font-size: 19px;
font-weight: 800;
letter-spacing: -0.02em;
}
.boot-loader__text {
position: relative;
z-index: 1;
margin: 10px 0 0;
color: var(--boot-muted);
font-size: 14px;
line-height: 2;
}
@keyframes boot-spin {
to {
transform: rotate(360deg);
}
}
</style>
<script>
;(function () {
var CONFIG_COOKIE_NAME = 'APP_CONFIG_CACHE'
function getCookie(name) {
var cookie = document.cookie.split('; ').find(function (row) {
return row.indexOf(name + '=') === 0
})
if (!cookie) return null
return cookie.substring(name.length + 1)
}
function readCachedConfig() {
try {
var rawCookie = getCookie(CONFIG_COOKIE_NAME)
if (!rawCookie) return null
var decoded = decodeURIComponent(rawCookie)
var payload = JSON.parse(decoded)
return payload && payload.config ? payload.config : null
} catch (error) {
console.warn('Boot theme: failed to read cached config', error)
return null
}
}
function normalizeHex(hex) {
if (!hex || typeof hex !== 'string') return null
var value = hex.trim()
if (!value) return null
if (value[0] !== '#') {
value = '#' + value
}
if (/^#[0-9a-fA-F]{3}$/.test(value)) {
value =
'#' +
value[1] +
value[1] +
value[2] +
value[2] +
value[3] +
value[3]
}
if (!/^#[0-9a-fA-F]{6}$/.test(value)) return null
return value
}
function hexToRgb(hex) {
var normalized = normalizeHex(hex)
if (!normalized) return null
var num = parseInt(normalized.slice(1), 16)
return {
r: (num >> 16) & 255,
g: (num >> 8) & 255,
b: num & 255
}
}
function rgbToHex(r, g, b) {
function toHex(value) {
var hex = Math.max(0, Math.min(255, Math.round(value))).toString(16)
return hex.length === 1 ? '0' + hex : hex
}
return '#' + toHex(r) + toHex(g) + toHex(b)
}
function mix(hexA, hexB, weight) {
var a = hexToRgb(hexA)
var b = hexToRgb(hexB)
if (!a || !b) return hexA
return rgbToHex(
a.r * (1 - weight) + b.r * weight,
a.g * (1 - weight) + b.g * weight,
a.b * (1 - weight) + b.b * weight
)
}
function brightness(hex) {
var rgb = hexToRgb(hex)
if (!rgb) return 0
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000
}
function hexToRgba(hex, alpha) {
var rgb = hexToRgb(hex)
if (!rgb) return 'rgba(96, 165, 250, ' + alpha + ')'
return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + alpha + ')'
}
function setVar(name, value) {
document.documentElement.style.setProperty(name, value)
}
function applyBootTheme() {
var config = readCachedConfig()
var user = config && config.user ? config.user : null
if (!user) return
var tenantColor = normalizeHex(user.color)
var tenantSecondary = normalizeHex(user.secondary_color)
var tenantBackground = normalizeHex(user.background_color)
/**
* مهم:
* background_color بک‌گراند اپ است.
* اگر نبود، لودینگ باید روشن بماند، نه اینکه color را بک‌گراند کنیم.
*/
var bg = tenantBackground || '#ffffff'
/**
* color و secondary_color فقط برای accent استفاده می‌شوند.
*/
var accent = tenantSecondary || tenantColor || '#2563eb'
var isLight = brightness(bg) > 155
var bgSoft = isLight ? mix(bg, accent, 0.045) : mix(bg, '#ffffff', 0.055)
var text = isLight ? '#111827' : '#ffffff'
var muted = isLight ? 'rgba(15, 23, 42, 0.62)' : 'rgba(255, 255, 255, 0.70)'
var card = isLight ? 'rgba(255, 255, 255, 0.88)' : 'rgba(255, 255, 255, 0.07)'
var border = isLight ? 'rgba(15, 23, 42, 0.08)' : 'rgba(255, 255, 255, 0.12)'
var orb = hexToRgba(accent, isLight ? 0.10 : 0.18)
var spinnerTrack = isLight ? 'rgba(15, 23, 42, 0.10)' : 'rgba(255, 255, 255, 0.14)'
var shadow = isLight ? 'rgba(15, 23, 42, 0.10)' : 'rgba(0, 0, 0, 0.24)'
setVar('--boot-bg', bg)
setVar('--boot-bg-soft', bgSoft)
setVar('--boot-accent', accent)
setVar('--boot-text', text)
setVar('--boot-muted', muted)
setVar('--boot-card', card)
setVar('--boot-border', border)
setVar('--boot-orb', orb)
setVar('--boot-spinner-track', spinnerTrack)
setVar('--boot-shadow', shadow)
document.title = user.name_fa || user.name || 'در حال بارگذاری...'
}
applyBootTheme()
})()
</script>
</head>
<body>
<div id="app"></div>
<div id="app">
<div class="boot-loader">
<div class="boot-loader__card">
<div class="boot-loader__orb"></div>
<div class="boot-loader__spinner"></div>
<h1 class="boot-loader__title">در حال هدایت به سامانه</h1>
<p class="boot-loader__text">لطفاً چند لحظه صبر کنید...</p>
</div>
</div>
</div>
<script>
;(function () {
var BOOT_TIMEOUT_MS = 90000
var RETRY_KEY = '__APP_BOOT_RETRY_CLICKED__'
var RECOVERY_KEY = '__APP_BOOT_RECOVERY_DONE__'
var CONFIG_COOKIE_NAME = 'APP_CONFIG_CACHE'
var CONFIG_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 7
var TOKEN_STORAGE_KEY = 'liman_user_token'
var VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
var VERSION_STORAGE_KEY = 'version'
var CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
function getProtocol() {
return window.location.protocol === 'https:' ? 'https:' : 'http:'
}
function resolveTenantDomain() {
var host = String(window.location.hostname || '').trim()
if (!host || host === 'localhost' || host === '127.0.0.1') {
return 'k.montzar.ir'
}
return host
}
function getSuperAdminBases() {
return [
'https://adm.montzar.ir',
'https://adm.montech.ir',
'https://adm.montest.ir'
]
}
function isDevHost() {
var host = String(window.location.hostname || '').trim()
return host === 'localhost' || host === '127.0.0.1'
}
function getVersionUrls() {
var domain = encodeURIComponent(resolveTenantDomain())
var urls = getSuperAdminBases().map(function (base) {
return base + '/get_version?domain=' + domain
})
if (isDevHost()) {
var protocol = getProtocol()
urls = urls.concat([
'https://tablo.talasevin.ir/get_version',
'https://abshode-service.montgit.ir/server/get_version',
protocol + '//212.23.201.173:8381/get_version',
protocol + '//91.212.174.137:4040/server/get_version'
])
}
return urls
}
function getConfigUrls() {
var domain = encodeURIComponent(resolveTenantDomain())
var urls = getSuperAdminBases().map(function (base) {
return base + '/get_user?domain=' + domain
})
if (isDevHost()) {
var protocol = getProtocol()
urls = urls.concat([
protocol + '//tablo.talasevin.ir/get_user',
protocol + '//abshode-service.montgit.ir/server/get_user',
protocol + '//212.23.201.173:8381/get_user',
protocol + '//91.212.174.137:4040/server/get_user'
])
}
return urls
}
function sortVersionUrls(urls) {
var lastSuccessUrl = localStorage.getItem(VERSION_SUCCESS_URL_KEY)
if (!lastSuccessUrl) {
return urls.slice()
}
return [lastSuccessUrl].concat(urls.filter(function (url) {
return url !== lastSuccessUrl
}))
}
function sortByLastSuccess(urls) {
var lastSuccessUrl = localStorage.getItem(CONFIG_SUCCESS_URL_KEY)
return urls.slice().sort(function (a, b) {
if (a === lastSuccessUrl) return -1
if (b === lastSuccessUrl) return 1
return 0
})
}
function normalizeVersionResponse(data) {
if (typeof data === 'string' || typeof data === 'number') {
return String(data).trim()
}
if (!data) return ''
if (typeof data.data === 'string' || typeof data.data === 'number') {
return String(data.data).trim()
}
var version =
data.version ||
data.value ||
(data.data && typeof data.data === 'object' ? data.data.version : '')
return version ? String(version).trim() : ''
}
async function fetchJsonOrText(url, timeout) {
var controller = new AbortController()
var timeoutId = window.setTimeout(function () {
controller.abort()
}, timeout)
try {
var response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json'
},
cache: 'no-store',
signal: controller.signal
})
if (!response.ok) {
throw new Error('Request failed: ' + response.status)
}
var contentType = response.headers.get('content-type') || ''
if (contentType.indexOf('application/json') !== -1) {
return await response.json()
}
return await response.text()
} finally {
window.clearTimeout(timeoutId)
}
}
async function fetchVersionFromUrl(url, timeout) {
var controller = new AbortController()
var timeoutId = window.setTimeout(function () {
controller.abort()
}, timeout)
try {
var response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json'
},
cache: 'no-store',
signal: controller.signal
})
if (!response.ok) {
throw new Error('Version request failed: ' + response.status)
}
var contentType = response.headers.get('content-type') || ''
var data
if (contentType.indexOf('application/json') !== -1) {
data = await response.json()
} else {
data = await response.text()
}
var version = normalizeVersionResponse(data)
if (!version) {
throw new Error('Version response is empty')
}
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
return version
} catch (error) {
if (localStorage.getItem(VERSION_SUCCESS_URL_KEY) === url) {
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
}
console.warn('Version failed:', url, error)
return undefined
} finally {
window.clearTimeout(timeoutId)
}
}
async function loadRemoteVersion(rounds) {
var urls = sortVersionUrls(getVersionUrls())
for (var round = 1; round <= rounds; round++) {
for (var i = 0; i < urls.length; i++) {
var timeout = i === urls.length - 1 ? 6000 : 3500
var result = await fetchVersionFromUrl(urls[i], timeout)
if (result) {
return result
}
}
}
return null
}
async function fetchFreshConfig(rounds) {
var urls = sortByLastSuccess(getConfigUrls())
for (var round = 1; round <= rounds; round++) {
for (var i = 0; i < urls.length; i++) {
var url = urls[i]
try {
var config = await fetchJsonOrText(url, i === urls.length - 1 ? 7000 : 4000)
if (!config || typeof config !== 'object') {
throw new Error('Config response is invalid')
}
return {
config: config,
url: url
}
} catch (error) {
if (localStorage.getItem(CONFIG_SUCCESS_URL_KEY) === url) {
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
}
console.warn('Config failed:', url, 'round:', round, error)
}
}
}
throw new Error('Cannot fetch fresh config')
}
function writeConfigCookie(config) {
try {
var payload = {
cached_at: Date.now(),
config: config
}
var encoded = encodeURIComponent(JSON.stringify(payload))
var secure = window.location.protocol === 'https:' ? '; Secure' : ''
document.cookie =
CONFIG_COOKIE_NAME +
'=' +
encoded +
'; Path=/; Max-Age=' +
CONFIG_COOKIE_MAX_AGE_SECONDS +
'; SameSite=Lax' +
secure
} catch (error) {
console.warn('Failed to write config cookie:', error)
}
}
function clearReadableCookies() {
document.cookie.split(';').forEach(function (cookie) {
var name = cookie.split('=')[0] && cookie.split('=')[0].trim()
if (!name) return
document.cookie = name + '=; Path=/; Max-Age=0; SameSite=Lax'
})
}
function clearLocalStorageExceptToken() {
var token = localStorage.getItem(TOKEN_STORAGE_KEY)
localStorage.clear()
if (token) {
localStorage.setItem(TOKEN_STORAGE_KEY, token)
}
}
async function clearServiceWorkersAndCaches() {
try {
if ('serviceWorker' in navigator) {
var registrations = await navigator.serviceWorker.getRegistrations()
await Promise.all(
registrations.map(function (registration) {
return registration.unregister()
})
)
}
} catch (error) {
console.warn('Failed to unregister service workers:', error)
}
try {
if ('caches' in window) {
var keys = await caches.keys()
await Promise.all(
keys.map(function (key) {
return caches.delete(key)
})
)
}
} catch (error) {
console.warn('Failed to clear caches:', error)
}
}
function reloadWithCacheBust() {
var url = new URL(window.location.href)
url.searchParams.set('__boot_recover', String(Date.now()))
window.location.replace(url.toString())
}
function renderRecovering(text) {
var app = document.getElementById('app')
if (!app) return
app.innerHTML =
'<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; direction: rtl; font-family: sans-serif; padding: 24px; background: var(--boot-bg); color: var(--boot-text);">' +
'<div style="width: min(420px, 100%); text-align: center; background: var(--boot-card); border: 1px solid var(--boot-border); border-radius: 24px; padding: 28px 22px;">' +
'<div style="width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 999px; border: 4px solid rgba(255,255,255,0.18); border-top-color: var(--boot-accent); animation: bootSpin 0.9s linear infinite;"></div>' +
'<style>@keyframes bootSpin { to { transform: rotate(360deg); } }</style>' +
'<h2 style="margin: 0 0 12px; font-size: 20px;">در حال بازیابی برنامه</h2>' +
'<p style="margin: 0; color: var(--boot-muted); line-height: 2; font-size: 14px;">' +
(text || 'لطفاً چند لحظه صبر کنید.') +
'</p>' +
'</div>' +
'</div>'
}
function renderBootError() {
var app = document.getElementById('app')
if (!app) return
app.innerHTML =
'<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; direction: rtl; font-family: sans-serif; padding: 24px; background: var(--boot-bg); color: var(--boot-text);">' +
'<div style="width: min(420px, 100%); text-align: center; background: var(--boot-card); border: 1px solid var(--boot-border); border-radius: 24px; padding: 28px 22px;">' +
'<div style="font-size: 42px; margin-bottom: 12px;">⚠️</div>' +
'<h2 style="margin: 0 0 12px; font-size: 20px;">خطا در بارگذاری برنامه</h2>' +
'<p style="margin: 0 0 20px; color: var(--boot-muted); line-height: 2; font-size: 14px;">' +
'برقراری ارتباط با سرور امکان‌پذیر نیست. لطفاً اتصال اینترنت خود را بررسی کرده و صفحه را تازه‌سازی نمایید.' +
'</p>' +
'<button onclick="window.__APP_BOOT_SIMPLE_RETRY__()" style="padding: 11px 22px; border: 0; border-radius: 12px; background: var(--boot-accent); color: white; cursor: pointer; font-weight: 700;">' +
'تازه‌سازی صفحه' +
'</button>' +
'<button onclick="window.__APP_BOOT_CLEAN_RELOAD__()" style="margin-right: 8px; padding: 11px 18px; border: 1px solid var(--boot-border); border-radius: 12px; background: transparent; color: var(--boot-text); cursor: pointer; font-weight: 700;">' +
'پاک‌سازی و تلاش مجدد' +
'</button>' +
'</div>' +
'</div>'
}
async function cleanFetchAndReload() {
renderRecovering('در حال دریافت تنظیمات جدید برنامه...')
var version = await loadRemoteVersion(3)
var freshConfigResult = await fetchFreshConfig(3)
clearReadableCookies()
// clearLocalStorageExceptToken()
await clearServiceWorkersAndCaches()
writeConfigCookie(freshConfigResult.config)
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, freshConfigResult.url)
if (version) {
localStorage.setItem(VERSION_STORAGE_KEY, version)
}
sessionStorage.removeItem(RETRY_KEY)
sessionStorage.removeItem(RECOVERY_KEY)
reloadWithCacheBust()
}
window.__APP_BOOT_SIMPLE_RETRY__ = function () {
sessionStorage.setItem(RETRY_KEY, '1')
reloadWithCacheBust()
}
window.__APP_BOOT_CLEAN_RELOAD__ = async function () {
try {
sessionStorage.setItem(RECOVERY_KEY, '1')
await cleanFetchAndReload()
} catch (error) {
console.error('Manual boot recovery failed:', error)
renderBootError()
}
}
window.__BOOT_TIMEOUT__ = window.setTimeout(async function () {
if (window.__APP_BOOTSTRAPPED__) return
var app = document.getElementById('app')
var stillBooting = app && app.querySelector('.boot-loader')
if (!stillBooting) return
if (!sessionStorage.getItem(RETRY_KEY)) {
renderBootError()
return
}
if (!sessionStorage.getItem(RECOVERY_KEY)) {
sessionStorage.setItem(RECOVERY_KEY, '1')
try {
await cleanFetchAndReload()
} catch (error) {
console.error('Auto boot recovery after retry failed:', error)
renderBootError()
}
return
}
renderBootError()
}, BOOT_TIMEOUT_MS)
})()
</script>
<script type="module" src="/src/main.ts"></script>
<a href="https://web.rubika.ir/#c=u0I8F1U0a939b0df5ba9f73618d33d7c" target="_blank" id="whatsapp-button">
<img class="p-2" src="/src/assets/img/rubika.webp" alt="" />
</a>
</body>
</html>
</html>
+847 -43
View File
File diff suppressed because it is too large Load Diff
+3 -1
View File
@@ -19,6 +19,7 @@
"axios": "^1.6.2",
"dayjalali": "^1.0.1",
"echarts": "^5.4.3",
"express": "^5.2.1",
"jalaliday": "^2.3.0",
"lodash": "^4.17.21",
"moment": "^2.29.4",
@@ -38,7 +39,8 @@
"vue3-apexcharts": "^1.4.4",
"vue3-lazyload": "^0.3.8",
"vue3-odometer": "^0.1.3",
"vue3-otp-input": "^0.4.1"
"vue3-otp-input": "^0.4.1",
"wavesurfer.js": "^7.12.6"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.2",
-10
View File
@@ -1,10 +0,0 @@
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "ir.ghatreh.app",
"sha256_cert_fingerprints": ["60:54:C6:C1:22:6C:2E:EA:A1:05:02:B1:17:F5:7D:49:1A:C0:84:FF:4C:ED:FD:42:D9:7F:DF:B2:70:37:8E:03"]
}
}
]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 23 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 100 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 KiB

After

Width:  |  Height:  |  Size: 583 KiB

+262 -68
View File
@@ -1,12 +1,5 @@
<template>
<div class="desktopConfig w-full right-0 left-0 absolute">
<div v-if="popVisible" class="top-0 bottom-0 wrap-fix bg-primary z-100 opacity-60">
<div class="absolute right-0 left-0 bottom-10vh flex flex-col items-center">
<div><BasicButton>درباره ما</BasicButton></div>
<div></div>
<div></div>
</div>
</div>
<div class="desktopConfig w-full right-0 left-0">
<transition mode="out-in" name="fade">
<AConfigProvider
v-if="!showSplash"
@@ -21,76 +14,109 @@
direction="rtl"
>
<router-view v-slot="{ Component, route }">
<!-- Use any custom transition and to `fade` -->
<transition :name="route.meta.transition || 'fade'">
<div>
<component :is="Component" />
</div>
<component :is="Component" :key="route.fullPath" class="app-main" />
</transition>
</router-view>
</AConfigProvider>
<div v-else class="flex bottom-0 wrap-fix top-0 bg-white z-1000000000000 justify-center">
<div class="top-0 wrap-fix h-1/3 w-screen flex">
<img :src="img_topGradiant" alt="" class="absolute z-10 w-screen h-full object-cover" />
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none" />
<div v-else class="app-splash-screen flex items-center justify-center bg-white">
<div class="app-splash-screen__gradient app-splash-screen__gradient--top h-1/3 flex">
<img :src="img_topGradiant" alt="" class="absolute z-10 w-full h-full object-cover" />
<img :src="img_pattern" alt="" class="absolute w-full h-full object-none" />
</div>
<div class="wrap-fix bottom-0 h-1/3 w-screen">
<div class="app-splash-screen__gradient app-splash-screen__gradient--bottom h-1/3">
<img
:src="img_bottomGradiant"
alt=""
class="absolute z-10 w-screen h-full object-cover"
class="absolute z-10 w-full h-full object-cover"
/>
<img :src="img_pattern" alt="" class="absolute w-screen h-full object-none" />
<img :src="img_pattern" alt="" class="absolute w-full h-full object-none" />
</div>
<div class="self-center splash_appear_fade_in">
<img :src="logoFull" class="h-[20vh]">
<!-- <img :src="logo" alt="" class="z-100 bg-primary rounded-full w-full aspect-square self-center h-40" />-->
<div class="splash_appear_fade_in relative z-10">
<img :src="logoFull" class="h-[20vh] max-h-[180px] w-auto object-contain" alt="" />
</div>
<div class="fixed w-full bottom-5 home_appear_fade_in_up">
<div class="text-center text-xs">نسخه: {{ pkg.version }}</div>
<div class="app-splash-screen__version home_appear_fade_in_up">
<div class="text-center text-xs">نسخه: {{ displayVersion }}</div>
</div>
<div class="absolute bottom-10">
<div class="app-splash-screen__spinner">
<a-spin :indicator="indicator" size="small" />
</div>
</div>
</transition>
<van-dialog
v-model:show="versionDialog"
class="updateButton"
confirm-button-text="به روزرسانی کنید"
show-confirm-button
@confirm="update()"
<div
v-if="showSupportButton && !showSplash && route.name !== 'support'"
id="support-button"
ref="supportButtonEl"
class="draggable-support-button"
:class="{ 'is-dragging': supportDragging, 'is-picker-open': supportPickerOpen }"
:style="supportButtonStyle"
title="پشتیبانی"
@pointerdown="onSupportPointerDown"
@pointermove="onSupportPointerMove"
@pointerup="handleSupportPointerUp"
@pointercancel="onSupportPointerCancel"
>
<div class="flex flex-col items-center p-2">
<DotLottieVue
class="w-full aspect-square"
autoplay
loop
src="https://lottie.host/cb620e8e-c64a-42e8-a6b5-8844146e5999/nmft7oBO8q.json"
/>
<div class="home_appear_fade_in_up mt-2">نسخه جدید قطره منتشر شد!</div>
<div class="support-button-inner" :style="{ '--support-accent': supportAccentColor }">
<BasicIcon :icon="supportIcon" size="18" class="support-button-icon" />
<span class="support-button-label">پشتیبانی</span>
<span
v-if="supportChatUnreadCount > 0"
class="support-fab-badge"
>
{{ supportChatUnreadCount > 99 ? '99+' : supportChatUnreadCount }}
</span>
</div>
</van-dialog>
</div>
<SupportMessengerPicker
v-model:open="supportPickerOpen"
:entries="supportMessengerEntries"
:anchor-el="pickerAnchorEl"
@select="openMessengerEntry"
/>
<VersionUpdateModal />
<PwaInstallGuideModal
v-model:open="guideOpen"
:platform="platform"
@complete="completeGuide()"
/>
</div>
</template>
<script lang="ts" setup>
import { colors } from './themeConfig'
import pkg from '../package.json'
import { useRegisterSW } from 'virtual:pwa-register/vue'
import { h, onMounted, ref } from 'vue'
import { update } from 'lodash'
import { getDisplayAppVersion } from '@/config/config-cache'
import { computed, defineAsyncComponent, h, onMounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { message } from 'ant-design-vue'
import { showBrowserNotification } from '@/utils/browserNotification'
import img_topGradiant from '@/views/login/assets/img/gr_top_white.svg'
import img_pattern from '@/views/login/assets/img/pattern.svg'
import { LoadingOutlined } from '@ant-design/icons-vue'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import { useSupportMessenger } from '@/composables/useSupportMessenger'
import { loadSupportMessengerFromSettings } from '@/utils/supportMessenger'
import SupportMessengerPicker from '@/components/SupportMessengerPicker.vue'
import { useDraggableFloatingButton } from '@/utils/useDraggableFloatingButton'
import { useApplyDesktopLayoutClass } from '@/layouts/composables/useAppLayout'
import { usePwaInstall } from '@/composables/usePwaInstall'
import PwaInstallGuideModal from '@/components/pwa/PwaInstallGuideModal.vue'
import { useUserStore } from '@/store/userStore'
import { useSettingsStore } from '@/store/settingsStore'
import { connectChatIfExists, disconnectChat, isSettingFlagOn, unreadSupportCount, useChatService } from '@/utils/chat'
import { getToken } from '@/utils'
import img_bottomGradiant from '@/views/login/assets/img/gr_bottom_white.svg'
import logoFull from '@/assets/img/logo_full_.png'
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
const { offlineReady, needRefresh, updateServiceWorker } = useRegisterSW()
const VersionUpdateModal = defineAsyncComponent(
() => import('@/modules/version/VersionUpdateModal.vue')
)
const indicator = h(LoadingOutlined, {
style: {
@@ -98,34 +124,130 @@ const indicator = h(LoadingOutlined, {
},
spin: true
})
const displayVersion = getDisplayAppVersion(pkg.version)
const showSplash = ref(true)
const route = useRoute()
useApplyDesktopLayoutClass()
onMounted(() => {
checkVersion()
const {
guideOpen,
platform,
completeGuide,
} = usePwaInstall()
const {
supportPickerOpen,
supportPickerAnchor,
supportMessengerEntries,
messengerMeta,
isChatEnabled,
hasMessengerLink: showSupportButton,
openMessengerEntry,
openSupportMessenger,
} = useSupportMessenger()
const supportButtonEl = ref<HTMLElement | null>(null)
const pickerAnchorEl = computed(() => supportPickerAnchor.value ?? supportButtonEl.value)
const supportChatUnreadCount = computed(() =>
isChatEnabled.value ? Number(unreadSupportCount.value) || 0 : 0,
)
const supportIcon = computed(() => messengerMeta.value.icon)
const supportAccentColor = computed(() =>
(messengerMeta.value.accent !== '#334155'
? messengerMeta.value.accent
: colors.primary) || '#334155',
)
const {
dragging: supportDragging,
fabStyle: supportButtonStyle,
handlePointerDown: onSupportPointerDown,
handlePointerMove: onSupportPointerMove,
handlePointerUp: supportPointerUp,
handlePointerCancel: onSupportPointerCancel,
} = useDraggableFloatingButton('ghatreh_support_button_position_v1', {
width: 118,
height: 42,
defaultBottomGap: 12,
defaultRightOffset: 16,
})
function handleSupportPointerUp(event: PointerEvent) {
const clicked = supportPointerUp(event)
if (!clicked) return
event.stopPropagation()
void openSupportMessenger(supportButtonEl.value)
}
onMounted(async () => {
await loadSupportMessengerFromSettings()
setTimeout(() => {
showSplash.value = false
}, 2000)
})
const versionDialog = ref<boolean>(false)
const userStore = useUserStore()
const settingsStore = useSettingsStore()
const { latestIncomingNotification } = useChatService()
let lastConnectedChatSessionKey = ''
let lastSupportToastAt = 0
function checkVersion() {
const version = localStorage.getItem('version')
// if (true) {
if (!version){
update()
}
if (version != pkg.version) {
versionDialog.value = true
}
}
watch(
() => [
userStore.userInfo?.chat_room_id,
userStore.userInfo?.chat_user_id,
settingsStore.getSettingByKey('chat_api_key'),
settingsStore.getSettingByKey('show_to_users_chat'),
settingsStore.getSettingByKey('has_chat'),
getToken(),
],
async ([roomId, chatUserId, chatApiKey, chatAdminFlag, chatCustomerFlag, token]) => {
const chatOn =
isSettingFlagOn(chatAdminFlag) && isSettingFlagOn(chatCustomerFlag)
if (!token || !chatOn || !chatApiKey || !roomId || !chatUserId) {
lastConnectedChatSessionKey = ''
disconnectChat()
return
}
function update() {
localStorage.setItem('version', pkg.version)
updateServiceWorker()
window.location.reload()
}
const sessionKey = `${roomId}:${chatUserId}:${chatApiKey}`
if (lastConnectedChatSessionKey === sessionKey) return
try {
await connectChatIfExists()
lastConnectedChatSessionKey = sessionKey
} catch (error) {
lastConnectedChatSessionKey = ''
console.error('connectChatIfExists failed:', error)
}
},
{ immediate: true },
)
watch(latestIncomingNotification, (payload) => {
if (!payload) return
if (payload.at === lastSupportToastAt) return
lastSupportToastAt = payload.at
// فقط وقتی خارج از صفحهٔ چت (گیت داخل chat.ts)؛ داخل چت نوتیف نمی‌آید
if (typeof document === 'undefined' || document.visibilityState === 'visible') {
message.info({
content: `پیام جدید پشتیبانی: ${payload.body}`,
duration: 3,
})
}
void showBrowserNotification({
title: payload.title || 'پشتیبانی',
body: payload.body || 'پیام جدید',
tag: 'support-chat-message',
url: '/support',
})
})
</script>
@@ -136,10 +258,82 @@ function update() {
font-size: 15px;
}
@media screen and (min-width: 426px) {
.desktopConfig {
width: 426px;
position: relative !important;
#support-button {
position: fixed;
z-index: 5100;
cursor: grab;
user-select: none;
border-radius: 9999px;
&.is-dragging {
cursor: grabbing;
}
}
.support-button-inner {
position: relative;
display: inline-flex;
align-items: center;
gap: 8px;
padding: 9px 14px 9px 12px;
background: #ffffff;
border: 1px solid rgba(15, 23, 42, 0.08);
border-radius: 9999px;
box-shadow: 0 6px 20px rgba(15, 23, 42, 0.14);
color: #1e293b;
font-size: 13px;
font-weight: 600;
line-height: 1;
direction: rtl;
transition: box-shadow 0.2s ease, transform 0.2s ease;
.support-button-icon {
color: var(--support-accent, #334155);
flex-shrink: 0;
}
.support-button-label {
white-space: nowrap;
}
}
.support-fab-badge {
position: absolute;
top: -6px;
left: -4px;
z-index: 2;
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: 999px;
background: #dc2626;
color: #fff;
font-size: 10px;
font-weight: 700;
line-height: 18px;
text-align: center;
box-shadow: 0 0 0 2px #fff;
}
#support-button:not(.is-dragging):hover .support-button-inner {
transform: translateY(-1px);
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}
#support-button.is-dragging .support-button-inner {
box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}
#support-button.is-picker-open .support-button-inner {
transform: scale(0.94);
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
}
/* در دسکتاپ، دکمه پشتیبانی کنار سایدبار و پایین صفحه قرار می‌گیرد (مانند khaneghi_user) */
html.app-layout--desktop {
#support-button {
bottom: 12px;
right: calc(var(--app-desktop-sidebar-width, 260px) + 20px);
}
}
</style>
+24
View File
@@ -0,0 +1,24 @@
import useAxios from '@/utils/useAxios'
export type AppNotificationSeverity = 'info' | 'success' | 'warning' | 'danger'
export interface CustomerAppNotification {
id: number
title: string
body: string
severity: AppNotificationSeverity
created_at?: string
is_read: boolean
}
export const getAppNotifications = async () =>
await useAxios.get<CustomerAppNotification[]>(`/customer/app_notifications`)
export const getAppNotificationsUnreadCount = async () =>
await useAxios.get<{ unread_count: number }>(`/customer/app_notifications/unread-count`)
export const markAppNotificationRead = async (id: number) =>
await useAxios.post(`/customer/app_notifications/${id}/read`)
export const markAllAppNotificationsRead = async () =>
await useAxios.post(`/customer/app_notifications/read-all`)
+10
View File
@@ -0,0 +1,10 @@
import useAxios from '@/utils/useAxios'
export interface StoreCategory {
id: number
name: string
sort_order?: number
}
export const getStoreCategories = async (): Promise<StoreCategory[]> =>
await useAxios.get<StoreCategory[]>('/customer/categories')
+6
View File
@@ -0,0 +1,6 @@
import useAxios from '@/utils/useAxios'
import type { User } from '@/models/login'
export const startChat = async (): Promise<{ message: string; user: User }> => {
return await useAxios.get<{ message: string; user: User }>(`/customer/start-chat`)
}
+5
View File
@@ -0,0 +1,5 @@
import useAxios from '@/utils/useAxios'
export async function getSettings() {
return await useAxios.get(`api/get_settings`)
}
+6 -2
View File
@@ -4,10 +4,14 @@ import type { PWallet, Wallet } from '@/models/wallet'
export const getProducts = async (): Promise<any> => {
return await useAxios.get<Product[]>(`/customer/product/list`)
return await useAxios.get<Product[]>(`/customer/product/list`, { timeout: 15000 })
}
export const getTvProducts = async (): Promise<Product[]> => {
const response = await useAxios.get<unknown>(`/customer/tv/products`, { timeout: 15000 })
return Array.isArray(response) ? (response as Product[]) : []
}
export const getProductById = async ( id:number|null): Promise<any> => {
return await useAxios.get<Product[]>(`/customer/product/list/${id}`)
return await useAxios.get<Product[]>(`/customer/product/list/${id}`, { timeout: 15000 })
}
export const getProductInventory = async (): Promise<any> => {
return await useAxios.post<PInventory[]>(`/customer/wallet/product/table`)
+41
View File
@@ -0,0 +1,41 @@
import {
fetchSuperAdminJson,
resolveTenantDomain,
SA_PROGRAM_SETTINGS_PATH,
} from '@/config/superadmin'
export type SuperAdminSettingRow = {
id?: number
key?: string
value?: string | number
title_fa?: string
description?: string
is_active?: boolean | number | string
type?: string
can_edit?: number | boolean | string
}
function parseSettingsPayload(data: unknown): SuperAdminSettingRow[] {
if (Array.isArray(data)) return data as SuperAdminSettingRow[]
if (data && typeof data === 'object') {
const obj = data as Record<string, unknown>
if (Array.isArray(obj.settings)) return obj.settings as SuperAdminSettingRow[]
if (Array.isArray(obj.items)) return obj.items as SuperAdminSettingRow[]
if (Array.isArray(obj.data)) return obj.data as SuperAdminSettingRow[]
}
return []
}
/** تنظیمات پیشرفته نسخه از سوپرادمین — فقط GET /api/public/program-settings?domain= */
export async function fetchSuperAdminProgramSettings(): Promise<SuperAdminSettingRow[]> {
const domain = encodeURIComponent(resolveTenantDomain())
try {
const data = await fetchSuperAdminJson(
(base) => `${base}${SA_PROGRAM_SETTINGS_PATH}?domain=${domain}`,
)
return parseSettingsPayload(data)
} catch (error) {
console.warn('SuperAdmin program-settings failed after retries:', error)
return []
}
}
+4
View File
@@ -1,9 +1,13 @@
import useAxios from '@/utils/useAxios'
import type { Card, Wallet } from '@/models/wallet'
import type { WalletAssetsSummary } from '@/models/walletAssets'
import type {Transaction} from '@/models/transaction'
export const getWallet = async () => await useAxios.get<Wallet>(`/customer/wallet/me`)
export const getWalletAssets = async () =>
await useAxios.get<WalletAssetsSummary>(`/customer/wallet/assets`)
export const withdraw = async (obj: Transaction): Promise<any> => {
return await useAxios.post<Transaction>(`/customer/wallet/withdraw`, obj)
}
+53
View File
@@ -0,0 +1,53 @@
import type { RouteLocationNormalized } from 'vue-router'
import router from '@/router'
import { message } from 'ant-design-vue'
let fingerPosition = false
let fingerTimeoutId: ReturnType<typeof setTimeout> | null = null
let hasFingerPrint = false
export function setTruth() {
fingerPosition = true
}
export function setEnableAuthenticate() {
fingerPosition = false
}
export function setFingerPosition(value: boolean) {
fingerPosition = value
}
export function getFingerPosition() {
return fingerPosition
}
export function setHasFingerPrint(value: boolean) {
hasFingerPrint = value
}
export function getHasFingerPrint() {
return hasFingerPrint
}
export function clearFingerTimeout() {
if (fingerTimeoutId) {
clearTimeout(fingerTimeoutId)
fingerTimeoutId = null
}
}
export function setFingerTimeOut(to: RouteLocationNormalized) {
clearFingerTimeout()
fingerTimeoutId = setTimeout(async () => {
if (!hasFingerPrint) return
fingerPosition = false
await router.push({ name: 'login' })
if (to.name !== 'login') {
message.warn('شما مدت زیادی با کشکول گلد کار نکردید، لطفا دوباره وارد شوید.')
}
}, 180000)
}
+90
View File
@@ -0,0 +1,90 @@
import { loadAppConfig } from '@/config/load-config'
import { setAppConfig } from '@/config/app-config'
import { applyAppConfig } from '@/config/apply-config'
import { startPwaManifest } from '@/modules/pwa/manifest'
import { createVueApp } from '@/app/createApp'
import { setupRouterGuards } from '@/app/setupRouter'
import { useSettingsStore } from '@/store/settingsStore'
import { initPriceRealtimeChannel } from '@/utils/priceSocket'
import { initMobileScrollRestoration } from '@/layouts/composables/useMobileScrollReset'
type BootWindow = Window & {
__BOOT_TIMEOUT__?: number
__APP_BOOTSTRAPPED__?: boolean
}
function clearBootTimeout() {
const bootWindow = window as BootWindow
if (bootWindow.__BOOT_TIMEOUT__) {
window.clearTimeout(bootWindow.__BOOT_TIMEOUT__)
bootWindow.__BOOT_TIMEOUT__ = undefined
}
}
function withTimeout<T>(promise: Promise<T>, ms: number, message: string): Promise<T> {
return Promise.race([
promise,
new Promise<T>((_, reject) => {
window.setTimeout(() => {
reject(new Error(message))
}, ms)
})
])
}
function showBootstrapError(error: unknown) {
clearBootTimeout()
console.error('Bootstrap failed:', error)
const appRoot = document.querySelector('#app')
if (!appRoot) return
appRoot.innerHTML = `
<div style="min-height: 100vh; display: flex; align-items: center; justify-content: center; direction: rtl; font-family: sans-serif; padding: 24px; background: var(--boot-bg, #ffffff); color: var(--boot-text, #111827);">
<div style="width: min(420px, 100%); text-align: center; background: var(--boot-card, #fff); border: 1px solid var(--boot-border, rgba(15,23,42,0.08)); border-radius: 24px; padding: 28px 22px;">
<div style="font-size: 42px; margin-bottom: 12px;">⚠️</div>
<h2 style="margin: 0 0 12px; font-size: 20px;">خطا در راه‌اندازی برنامه</h2>
<p style="margin: 0 0 20px; color: var(--boot-muted, rgba(15,23,42,0.62)); line-height: 2; font-size: 14px;">
برقراری ارتباط با سرور امکان‌پذیر نیست. لطفاً اتصال اینترنت خود را بررسی کرده و صفحه را تازه‌سازی نمایید.
</p>
<button
onclick="location.reload()"
style="padding: 11px 22px; border: 0; border-radius: 12px; background: var(--boot-accent, #2563eb); color: white; cursor: pointer; font-weight: 700;"
>
تازه‌سازی صفحه
</button>
</div>
</div>
`
}
export async function bootstrapApp() {
try {
const config = await withTimeout(loadAppConfig(), 20000, 'Config loading timeout')
setAppConfig(config)
startPwaManifest(config)
applyAppConfig()
const { app } = createVueApp()
const settingsStore = useSettingsStore()
await withTimeout(settingsStore.fetchSettings(), 45000, 'Settings loading timeout')
initPriceRealtimeChannel((key) => settingsStore.getSettingByKey(key))
initMobileScrollRestoration()
setupRouterGuards()
app.mount('#app')
;(window as BootWindow).__APP_BOOTSTRAPPED__ = true
clearBootTimeout()
sessionStorage.removeItem('__APP_BOOT_RECOVERY_DONE__')
sessionStorage.removeItem('__APP_BOOT_RETRY_CLICKED__')
} catch (error) {
showBootstrapError(error)
}
}
+18
View File
@@ -0,0 +1,18 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import VueLazyLoad from 'vue3-lazyload'
import VueApexCharts from 'vue3-apexcharts'
import App from '@/App.vue'
import router from '@/router'
export function createVueApp() {
const app = createApp(App)
const pinia = createPinia()
app.use(pinia)
app.use(VueLazyLoad, {})
app.use(router)
app.use(VueApexCharts)
return { app, pinia }
}
+151
View File
@@ -0,0 +1,151 @@
import { computed, watch } from 'vue'
import router from '@/router'
import { authenticateWithFingerprint, getToken, isIphone, removeToken } from '@/utils'
import { useUserStore } from '@/store/userStore'
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router'
import { useAuthStore } from '@/store/useAuthStore'
import {
clearFingerTimeout,
getFingerPosition,
getHasFingerPrint,
setFingerPosition,
setFingerTimeOut,
setHasFingerPrint
} from '@/app/authBoot'
import { recoverMobileViewportAfterAuth } from '@/layouts/composables/useMobileScrollReset'
export function setupRouterGuards() {
const userStore = useUserStore()
const authStore = useAuthStore()
const isApple: boolean = isIphone()
let isFirst = true
const currentRoute = computed(() => router.currentRoute.value.fullPath)
async function start() {
if (!getToken()) {
return
}
if (!userStore.userInfo) {
await userStore.getMyInfo()
}
}
function goToLogin(to: RouteLocationNormalized, next: NavigationGuardNext) {
if (to.name === 'buyProduct' || to.name === 'productDetail' || to.name === 'about' || to.name === 'cart' || to.name === 'tv') {
return next()
}
if (to.name !== 'login') {
return next({ name: 'login' })
}
return next()
}
function goToHome(to: RouteLocationNormalized, next: NavigationGuardNext) {
if (to.name !== 'buyProduct') {
return next({ name: 'buyProduct' })
}
return next()
}
router.beforeEach(async (to, from, next) => {
authStore.setLoading(true)
clearFingerTimeout()
setFingerTimeOut(to)
if (to.name === 'notifyTrigger' && getToken()) {
const { useSettingsStore } = await import('@/store/settingsStore')
const settingsStore = useSettingsStore()
if (!settingsStore.loaded) {
await settingsStore.fetchSettings()
}
if (!settingsStore.isSettingTruthy('has_page_price_trigger')) {
return next({ name: (from.name as string) || 'user' })
}
}
if (to.name === 'appNotifications' && getToken()) {
const { useSettingsStore } = await import('@/store/settingsStore')
const settingsStore = useSettingsStore()
if (!settingsStore.loaded) {
await settingsStore.fetchSettings()
}
if (!settingsStore.isSettingTruthy('has_page_notification')) {
return next({ name: (from.name as string) || 'home' })
}
}
if (to.name === 'giftCard' && getToken()) {
const { useSettingsStore } = await import('@/store/settingsStore')
const settingsStore = useSettingsStore()
if (!settingsStore.loaded) {
await settingsStore.fetchSettings()
}
if (!settingsStore.isSettingTruthy('has_page_gift_card')) {
return next({ name: (from.name as string) || 'user' })
}
}
if (isFirst) {
isFirst = false
if (getToken()) {
await userStore.getMyInfo()
const finger_print = userStore.userInfo.finger_print
setHasFingerPrint(finger_print)
if (isApple && finger_print) {
removeToken()
goToLogin(to, next)
} else if (!isApple && finger_print) {
setFingerPosition(await authenticateWithFingerprint())
if (!getFingerPosition()) {
goToLogin(to, next)
}
} else {
if (to.name == 'login') {
goToHome(to, next)
}
return next()
}
} else {
if (['login', '404', 'buyProduct', 'productDetail', 'about', 'cart', 'tv'].includes(to.name as string)) {
return next()
}
goToLogin(to, next)
}
} else {
if (getFingerPosition()) {
if (getToken()) {
if (to.name === 'login') {
return next({ name: from.name || 'buyProduct' })
}
return next()
}
if (['login', '404', 'buyProduct', 'productDetail', 'about', 'cart', 'tv'].includes(to.name as string)) {
return next()
}
return next({ name: 'login' })
}
if (getToken() && !getHasFingerPrint()) {
next()
} else {
goToLogin(to, next)
}
}
})
router.afterEach((to, from) => {
if (document.documentElement.classList.contains('app-layout--desktop')) return
if (from.name === 'login') {
recoverMobileViewportAfterAuth()
}
})
watch(currentRoute, async () => (userStore.userInfo ? '' : await start()))
}
+43 -10
View File
@@ -1,5 +1,18 @@
@import (less) './var.less';
@import (less) './fonts.less';
@import (less) '../../layouts/styles/desktop-shell.less';
@import (less) '../../layouts/styles/mobile-frame.less';
@import (less) '../../layouts/styles/mobile-page-common.less';
@import (less) '../../layouts/desktop/styles/desktop-page-common.less';
@import (less) '../../views/base/fund/desktop/styles/desktop-fund.less';
@import (less) '../../views/base/transactions/desktop/styles/desktop-transactions.less';
@import (less) '../../views/base/wallet/desktop/styles/desktop-wallet.less';
@import (less) '../../views/base/user/desktop/styles/desktop-user.less';
@import (less) '../../views/base/priceTrigger/desktop/styles/desktop-price-trigger.less';
@import (less) '../../views/base/home/desktop/styles/desktop-home.less';
@import (less) '../../views/base/gold/desktop/styles/desktop-gold.less';
@import (less) '../../views/login/desktop/styles/desktop-login.less';
@import (less) '../../layouts/desktop/styles/desktop-inner-pages.less';
html {
scroll-behavior: smooth;
@@ -50,6 +63,21 @@ body {
:root {
color-scheme: only light;
--app-safe-top: env(safe-area-inset-top, 0px);
--app-safe-bottom: env(safe-area-inset-bottom, 0px);
--app-credit-bar-inner: 0px;
--app-home-header-offset: calc(4.25rem + var(--app-safe-top));
--app-credit-footer-offset: var(--app-safe-bottom);
--app-nav-height: 80px;
--app-bottom-chrome-height: calc(var(--app-nav-height) + var(--app-safe-bottom));
--app-add-card-height: 88px;
--wallet-card-dock-overlap: 52px;
--app-z-nav: 5000;
--app-z-wallet-dock: 4490;
--app-z-wallet-add-bar: 4510;
--app-z-action-sheet: 5200;
--app-z-dialog: 5300;
--app-z-modal: 5500;
}
.ant-form-item {
@@ -74,18 +102,23 @@ body {
opacity: 0;
}
/*.van-action-sheet{
z-index: 2001 !important;
.van-action-sheet{
z-index: 5001 !important;
}
.van-overlay{
z-index: 2000 !important;
}*/
//.van-overlay{
// z-index: 2000 !important;
//}
.color-transition {
transition: color 0.3s ease;
}
.app-main {
width: 100%;
min-height: 100vh;
}
.background-color-transition {
transition: background-color 0.3s ease;
}
@@ -133,7 +166,7 @@ body {
background-color: #fff;
//display: none;
outline: none;
border: 1px solid #521620 !important;
border: 1px solid #a72b77 !important;
}
}
@@ -331,18 +364,18 @@ body {
}
.ant-radio-group-solid
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover{
color: #521620 !important;
color: #a72b77 !important;
}
.ant-input-group-addon{
background-color: #521620 !important;
background-color: #a72b77 !important;
color: #e0be7f !important;
}
.ant-slider-track{
background-color: #521620 !important;
background-color: #a72b77 !important;
}
.ant-slider-handle {
background-color: #521620 !important;
background-color: #a72b77 !important;
}
+3 -2
View File
@@ -1,7 +1,8 @@
@prefixCls: 'noname';
@primary-color: #521620;
@secondary-color: #521620;
@primary-color: #a72b77;
@secondary-color: #a72b77;
@App-primary-color: #a72b77;
@prefixCls-font-family: 'iran-sans';
@prefixCls-background-color: #fff;
Binary file not shown.

After

Width:  |  Height:  |  Size: 607 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 KiB

After

Width:  |  Height:  |  Size: 583 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

+10
View File
@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">
<circle cx="128" cy="128" r="124" fill="#12B76A"/>
<!-- Bootstrap Icons telephone-fill — گوشی کامل -->
<g transform="translate(48 48) scale(10)">
<path
fill="#fff"
d="M1.885.511a1.745 1.745 0 0 1 2.612.163L6.29 2.98c.329.423.445.967.315 1.49l-.547 2.19a.678.678 0 0 0 .178.643l2.457 2.457a.678.678 0 0 0 .644.178l2.189-.547a1.745 1.745 0 0 1 1.49.315l2.306 1.794c.829.645.905 1.87.163 2.611l-1.034 1.034c-.74.74-1.846 1.065-2.877.702a18.634 18.634 0 0 1-7.01-4.42 18.634 18.634 0 0 1-4.42-7.009c-.362-1.03-.038-2.137.703-2.877L1.885.511z"
/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+7
View File
@@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" fill="none">
<circle cx="128" cy="128" r="128" fill="#3B82F6"/>
<path
fill="#fff"
d="M78 76h100c11 0 20 9 20 20v64c0 11-9 20-20 20h-52l-30 26v-26H78c-11 0-20-9-20-20V96c0-11 9-20 20-20zm16 40h68v14H94v-14zm0 28h48v14H94v-14z"
/>
</svg>

After

Width:  |  Height:  |  Size: 337 B

+7
View File
@@ -0,0 +1,7 @@
<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
<rect width="48" height="48" rx="12" fill="#1CA0E2"/>
<g transform="translate(12 12)">
<path d="M14.4501 0.922337C14.4249 0.922337 14.3996 0.922337 14.3749 0.922337C13.9177 0.865759 13.4564 0.848106 12.9962 0.869568C12.3937 0.891042 11.7968 0.992415 11.2211 1.17103C10.5799 1.36599 9.98324 1.6851 9.46511 2.11021C9.27918 2.26684 9.10383 2.43563 8.94023 2.61545C8.62473 2.95789 8.39401 3.35478 8.19696 3.77245C8.09086 3.997 7.99543 4.22773 7.8955 4.45565C7.88203 4.48764 7.8708 4.5202 7.86014 4.55333C7.82589 4.66167 7.79558 4.77114 7.75853 4.87836C7.65492 5.2025 7.5737 5.53337 7.51545 5.86863C7.45552 6.17826 7.41539 6.4914 7.39532 6.80613C7.37904 7.03574 7.36669 7.2659 7.36613 7.49607C7.36593 7.89339 7.3888 8.29039 7.43461 8.68506C7.49075 9.19592 7.58787 9.70059 7.69341 10.2036C7.81298 10.7756 7.99094 11.3303 8.1644 11.8877C8.33787 12.4452 8.5394 12.9847 8.73757 13.5297C8.89756 13.9716 9.04576 14.4167 9.16702 14.8709C9.24027 15.1385 9.29245 15.4114 9.32309 15.6871C9.37053 16.0792 9.35422 16.4763 9.27481 16.8632C9.26358 16.9126 9.25179 16.9614 9.23719 17.0097C9.17854 17.206 9.10843 17.3987 9.02724 17.5868C8.97171 17.7142 8.90383 17.8359 8.82458 17.95C8.54294 18.3624 8.19617 18.7262 7.79782 19.0273C7.33066 19.3746 6.78803 19.6066 6.21418 19.7043C5.97198 19.7479 5.72653 19.7708 5.48046 19.7728C4.65255 19.785 3.84735 19.5021 3.20913 18.9745C3.06738 18.8636 2.93586 18.7402 2.81616 18.6057C2.79988 18.5866 2.78024 18.5704 2.76003 18.553C2.73982 18.5355 2.73701 18.5479 2.72578 18.553C2.70445 18.5423 2.69715 18.5198 2.68536 18.5019C2.53435 18.2655 2.37492 18.0348 2.23289 17.7923C2.02466 17.4393 1.83484 17.0758 1.66422 16.7032C1.4634 16.2612 1.29071 15.8068 1.14719 15.343C1.028 14.9577 0.929988 14.5662 0.853591 14.1703C0.802506 13.9081 0.760402 13.6437 0.730649 13.3776C0.707633 13.171 0.686862 12.9644 0.674512 12.7567C0.663846 12.6024 0.663846 12.448 0.655425 12.2942C0.647566 12.1645 0.644197 12.0354 0.647004 11.9062C0.650934 11.7204 0.654302 11.5341 0.666091 11.3488C0.679564 11.1349 0.696405 10.921 0.722229 10.7088C0.800805 10.0199 0.942301 9.33971 1.14495 8.67664C1.27499 8.25508 1.42887 7.84124 1.60584 7.43712C1.89207 6.78413 2.23982 6.15987 2.64438 5.57279C3.12563 4.87288 3.68354 4.22892 4.30774 3.65288C5.11591 2.9082 6.02747 2.28423 7.01414 1.80033C7.73201 1.44668 8.48602 1.17169 9.26302 0.980159C9.59984 0.898198 9.93667 0.829149 10.2814 0.776941C10.4554 0.750369 10.6303 0.728288 10.8062 0.710698C10.9943 0.691611 11.1829 0.681506 11.371 0.663542C11.4367 0.657367 11.5035 0.65849 11.5697 0.657367C11.9065 0.649508 12.2383 0.649508 12.5723 0.661297C12.7015 0.665788 12.83 0.681506 12.9586 0.69105C13.0338 0.696664 13.109 0.703962 13.1831 0.711259C13.4533 0.737083 13.7213 0.774508 13.987 0.823535C14.1229 0.848797 14.2587 0.875743 14.3951 0.901566C14.4154 0.901603 14.4349 0.908983 14.4501 0.922337Z" fill="#ffffff"/>
<path d="M5.25874 21.1173C5.27981 21.122 5.29921 21.1323 5.31488 21.1471C5.63283 21.3639 5.96476 21.5595 6.30852 21.7326C6.92863 22.0651 7.58142 22.3326 8.2565 22.5309C8.68006 22.6535 9.11143 22.7472 9.54766 22.8116C10.1444 22.8977 10.748 22.9264 11.3502 22.8974C11.7252 22.8804 12.0987 22.8397 12.4685 22.7756C12.6768 22.7403 12.8834 22.6976 13.0894 22.6516C13.6547 22.5202 14.2077 22.3411 14.7426 22.116C15.2004 21.927 15.6441 21.7057 16.0703 21.4536C16.5961 21.1443 17.0675 20.7507 17.4659 20.2887C17.8669 19.8343 18.2251 19.3438 18.5359 18.8235C19.0119 18.0108 19.35 17.1247 19.5362 16.2013C19.5979 15.8984 19.6419 15.5921 19.6682 15.2841C19.6987 14.9384 19.7084 14.5912 19.6974 14.2444C19.6623 13.1958 19.4489 12.1608 19.0664 11.1838C18.9917 10.9929 18.9131 10.8037 18.8351 10.614C18.8194 10.5763 18.8008 10.5399 18.7818 10.5017C18.4002 9.77858 17.9286 9.1067 17.3783 8.50205C17.0213 8.10516 16.6334 7.7397 16.2449 7.37481C15.9642 7.1132 15.6661 6.87687 15.3658 6.64109C15.1553 6.47267 14.938 6.31829 14.7365 6.1409C14.6708 6.07719 14.6006 6.01828 14.5265 5.96463C14.5033 5.94836 14.482 5.92953 14.4631 5.90849C14.3716 5.81306 14.2778 5.71931 14.1897 5.62106C13.9048 5.30938 13.7133 4.9238 13.6373 4.50841C13.5599 4.04993 13.605 3.57914 13.7681 3.14371C14.0347 2.46051 14.5209 2.00355 15.2063 1.7571C15.6623 1.58876 16.1576 1.55753 16.6311 1.66728C16.6586 1.67346 16.6873 1.67683 16.7148 1.68132C16.716 1.68322 16.7176 1.68484 16.7195 1.68607C16.7214 1.68729 16.7235 1.68809 16.7258 1.68841C16.728 1.68873 16.7303 1.68856 16.7325 1.68792C16.7346 1.68728 16.7366 1.68617 16.7383 1.68469C16.8039 1.70602 16.8668 1.73484 16.9258 1.77058C17.6094 2.10085 18.2582 2.4986 18.8626 2.95789C19.1186 3.1525 19.366 3.35834 19.6047 3.57541C19.8577 3.8037 20.1001 4.04303 20.3317 4.29341C21.5814 5.64007 22.4838 7.27123 22.9606 9.04547C23.0482 9.37163 23.1201 9.70059 23.1801 10.0324C23.2149 10.2277 23.2434 10.424 23.2655 10.6213C23.2885 10.8312 23.3087 11.0412 23.3216 11.2517C23.3312 11.3836 23.3345 11.5161 23.339 11.6486C23.3424 11.7608 23.3508 11.8686 23.3491 11.9792C23.3463 12.1998 23.3441 12.421 23.33 12.6411C23.3147 12.8858 23.2926 13.1304 23.2638 13.3748C23.0982 14.7647 22.6752 16.1116 22.0164 17.3466C21.8345 17.6892 21.6334 18.0213 21.4141 18.3413C21.3957 18.3665 21.3825 18.3952 21.3754 18.4255C21.3682 18.4559 21.3673 18.4874 21.3725 18.5181C21.3966 18.677 21.4185 18.8359 21.4404 18.9953C21.4623 19.1547 21.4837 19.3198 21.505 19.482C21.528 19.6566 21.551 19.8318 21.5735 20.0064C21.5886 20.1287 21.6016 20.2506 21.6167 20.3724C21.633 20.5071 21.6509 20.6413 21.6672 20.7754C21.6835 20.9096 21.6975 21.032 21.7127 21.16C21.7279 21.288 21.7413 21.4042 21.7565 21.526C21.7722 21.6574 21.789 21.7887 21.8053 21.919C21.8233 22.0627 21.8407 22.207 21.8581 22.3507C21.8733 22.4759 21.8873 22.6005 21.9019 22.7257C21.9097 22.7913 21.9182 22.857 21.926 22.9227C21.9339 22.9884 21.9182 23.0064 21.8463 22.9884C21.7851 22.9732 21.7245 22.9558 21.6639 22.9396L20.2486 22.5612C19.7995 22.4416 19.3538 22.3232 18.9069 22.2025C18.5662 22.111 18.226 22.0166 17.8858 21.9218C17.8224 21.9044 17.7578 21.8881 17.6949 21.8656C17.6773 21.8594 17.6585 21.8573 17.6399 21.8594C17.6213 21.8616 17.6035 21.8679 17.5877 21.878C17.3474 22.0172 17.0993 22.1424 16.8489 22.262C16.493 22.4309 16.1283 22.5808 15.7565 22.7111C15.361 22.8498 14.958 22.9664 14.5495 23.0602C14.3008 23.1164 14.051 23.1686 13.7984 23.204C13.6395 23.2264 13.4812 23.255 13.3218 23.2724C13.1467 23.291 12.9709 23.3073 12.7947 23.319C12.4674 23.3404 12.1395 23.3544 11.8117 23.3482C11.6444 23.3449 11.4775 23.3385 11.3109 23.3291C11.1599 23.3202 11.0089 23.3089 10.8585 23.2921C10.6429 23.2674 10.4273 23.241 10.2129 23.2068C9.96701 23.1675 9.72281 23.122 9.4831 23.067C8.84985 22.9227 8.23008 22.7246 7.63056 22.4747C7.28999 22.3321 6.9571 22.1735 6.63187 21.9987C6.17367 21.752 5.73289 21.4742 5.31264 21.1673C5.28962 21.1555 5.26492 21.1448 5.25874 21.1173Z" fill="#ffffff"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.7 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 256"><defs><linearGradient id="SVG6DaOZcwt" x1="50%" x2="50%" y1="0%" y2="100%"><stop offset="0%" stop-color="#2aabee"/><stop offset="100%" stop-color="#229ed9"/></linearGradient></defs><path fill="url(#SVG6DaOZcwt)" d="M128 0C94.06 0 61.48 13.494 37.5 37.49A128.04 128.04 0 0 0 0 128c0 33.934 13.5 66.514 37.5 90.51C61.48 242.506 94.06 256 128 256s66.52-13.494 90.5-37.49c24-23.996 37.5-56.576 37.5-90.51s-13.5-66.514-37.5-90.51C194.52 13.494 161.94 0 128 0"/><path fill="#fff" d="M57.94 126.648q55.98-24.384 74.64-32.152c35.56-14.786 42.94-17.354 47.76-17.441c1.06-.017 3.42.245 4.96 1.49c1.28 1.05 1.64 2.47 1.82 3.467c.16.996.38 3.266.2 5.038c-1.92 20.24-10.26 69.356-14.5 92.026c-1.78 9.592-5.32 12.808-8.74 13.122c-7.44.684-13.08-4.912-20.28-9.63c-11.26-7.386-17.62-11.982-28.56-19.188c-12.64-8.328-4.44-12.906 2.76-20.386c1.88-1.958 34.64-31.748 35.26-34.45c.08-.338.16-1.598-.6-2.262c-.74-.666-1.84-.438-2.64-.258c-1.14.256-19.12 12.152-54 35.686c-5.1 3.508-9.72 5.218-13.88 5.128c-4.56-.098-13.36-2.584-19.9-4.708c-8-2.606-14.38-3.984-13.82-8.41c.28-2.304 3.46-4.662 9.52-7.072"/></svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 256 258"><defs><linearGradient id="SVGK3KZq49U" x1="50%" x2="50%" y1="100%" y2="0%"><stop offset="0%" stop-color="#1faf38"/><stop offset="100%" stop-color="#60d669"/></linearGradient><linearGradient id="SVGefMkoEOd" x1="50%" x2="50%" y1="100%" y2="0%"><stop offset="0%" stop-color="#f9f9f9"/><stop offset="100%" stop-color="#fff"/></linearGradient></defs><path fill="url(#SVGK3KZq49U)" d="M5.463 127.456c-.006 21.677 5.658 42.843 16.428 61.499L4.433 252.697l65.232-17.104a123 123 0 0 0 58.8 14.97h.054c67.815 0 123.018-55.183 123.047-123.01c.013-32.867-12.775-63.773-36.009-87.025c-23.23-23.25-54.125-36.061-87.043-36.076c-67.823 0-123.022 55.18-123.05 123.004"/><path fill="url(#SVGefMkoEOd)" d="M1.07 127.416c-.007 22.457 5.86 44.38 17.014 63.704L0 257.147l67.571-17.717c18.618 10.151 39.58 15.503 60.91 15.511h.055c70.248 0 127.434-57.168 127.464-127.423c.012-34.048-13.236-66.065-37.3-90.15C194.633 13.286 162.633.014 128.536 0C58.276 0 1.099 57.16 1.071 127.416m40.24 60.376l-2.523-4.005c-10.606-16.864-16.204-36.352-16.196-56.363C22.614 69.029 70.138 21.52 128.576 21.52c28.3.012 54.896 11.044 74.9 31.06c20.003 20.018 31.01 46.628 31.003 74.93c-.026 58.395-47.551 105.91-105.943 105.91h-.042c-19.013-.01-37.66-5.116-53.922-14.765l-3.87-2.295l-40.098 10.513z"/><path fill="#fff" d="M96.678 74.148c-2.386-5.303-4.897-5.41-7.166-5.503c-1.858-.08-3.982-.074-6.104-.074c-2.124 0-5.575.799-8.492 3.984c-2.92 3.188-11.148 10.892-11.148 26.561s11.413 30.813 13.004 32.94c1.593 2.123 22.033 35.307 54.405 48.073c26.904 10.609 32.379 8.499 38.218 7.967c5.84-.53 18.844-7.702 21.497-15.139c2.655-7.436 2.655-13.81 1.859-15.142c-.796-1.327-2.92-2.124-6.105-3.716s-18.844-9.298-21.763-10.361c-2.92-1.062-5.043-1.592-7.167 1.597c-2.124 3.184-8.223 10.356-10.082 12.48c-1.857 2.129-3.716 2.394-6.9.801c-3.187-1.598-13.444-4.957-25.613-15.806c-9.468-8.442-15.86-18.867-17.718-22.056c-1.858-3.184-.199-4.91 1.398-6.497c1.431-1.427 3.186-3.719 4.78-5.578c1.588-1.86 2.118-3.187 3.18-5.311c1.063-2.126.531-3.986-.264-5.579c-.798-1.593-6.987-17.343-9.819-23.64"/></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

@@ -26,7 +26,7 @@ const _attrs = computed(() => {
const props = withDefaults(defineProps<Props>(), {
value: '',
format: 'YYYY/MM/DD'
format: 'YYYY-MM-DD'
})
const emit = defineEmits<{
@@ -41,11 +41,6 @@ const _class = computed(() => {
return ''
})
const _loading = computed(() => {
if (props.loading){
return 'flex'
} else return 'unset'
})
const { prefixCls } = usePrefix('base-button')
const props = withDefaults(defineProps<Props>(), {
@@ -58,9 +53,6 @@ const props = withDefaults(defineProps<Props>(), {
<style lang="less">
@prefix:~'@{prefixCls}-base-button';
.@{prefix}{
//width: fit-content;
height: auto;
/*padding: 8px;*/
display: v-bind(_loading);
}
</style>
+47 -22
View File
@@ -14,6 +14,7 @@
:type="props.type"
class=""
@change="handlerChange"
@input="handlerChange"
/>
<a-input
v-else
@@ -28,6 +29,7 @@
:pattern="props.pattern"
class=""
@change="handlerChange"
@input="handlerChange"
/>
</div>
</template>
@@ -36,6 +38,12 @@
import {usePrefix} from "@/utils/usePrefix";
import {computed} from "vue";
import {usePrice} from "@/components/BasicPacks/BasicPriceInput/src/utils/usePrice";
import {
normalizeDecimalInput,
persianToEnglishDigits,
shouldNormalizeDecimalSeparators,
shouldNormalizeInputDigits,
} from '@/utils/persianDigits';
//Props
interface Prop {
@@ -56,29 +64,51 @@ interface Prop {
const addonBgColor = computed(() => props.addonBgColor)
const addonTextColor = computed(() => props.addonTextColor)
//emits
const localValue = computed({
set(value) {
// console.log(value?.toString().replaceAll(',', ''))
props.type === 'price' ? emits('update:value', value?.toString().replaceAll(',', '')) : emits('update:value', value)
},
get() {
let a = props.type === 'price' ? props.value ? usePrice(props.value as number, true, '').trim() : '' : props.value
// console.log(props.value)
return a
},
})
const props = withDefaults(defineProps<Prop>(), {
isPassword: false
})
const emits = defineEmits(['update:value', 'onchange'])
const handlerChange = (e: any) => {
// emits('onchange', e.target.value)
props.type === 'price' ? emits('update:value', e.target.value?.toString().replaceAll(',', '')) : emits('update:value', e.target.value)
props.type === 'price' ? emits('onchange', e.target.value?.toString().replaceAll(',', '')) : emits('onchange', e.target.value)
// console.log('sas')
const localValue = computed({
set(value) {
emits('update:value', normalizeValue(value))
},
get() {
return props.type === 'price'
? props.value ? usePrice(props.value as number, true, '').trim() : ''
: props.value
},
})
function normalizeValue(value: unknown) {
if (value == null || value === '') {
return value
}
if (shouldNormalizeDecimalSeparators(props)) {
const isPrice = String(props.type ?? '').trim().toLowerCase() === 'price'
return normalizeDecimalInput(value as string | number, {
commaAsThousand: isPrice,
})
}
let normalized = String(value)
if (shouldNormalizeInputDigits(props)) {
normalized = persianToEnglishDigits(normalized)
}
return normalized
}
const handlerChange = (e: Event | string) => {
const target = typeof e === 'string' ? null : (e.target as HTMLInputElement | null)
const raw = typeof e === 'string' ? e : target?.value
const normalized = normalizeValue(raw)
if (target && typeof normalized === 'string' && target.value !== normalized) {
target.value = normalized
}
emits('update:value', normalized)
emits('onchange', normalized)
}
//css style
@@ -89,11 +119,6 @@ const {prefixCls} = usePrefix('input')
@prefix: ~'@{prefixCls}-input';
.@{prefix} {
/* .ant-input-group-addon:first-child {
!* border: #d9d9d9 1px solid;
border-radius: 0 6px 6px 0;*!
}*/
.ant-input-group {
direction: ltr;
}
@@ -1,5 +1,5 @@
<template>
<BasicInput v-model:value="_val">
<BasicInput v-model:value="_val" type="price">
<template v-for="(_, slotKey) in $slots" #[slotKey]="data">
<slot :name="slotKey" v-bind="data || {}"></slot>
</template>
@@ -10,6 +10,7 @@
import {usePrice} from './utils/usePrice'
import {computed} from "vue";
import BasicInput from "../../BasicInput.vue";
import {normalizeDecimalInput} from '@/utils/persianDigits'
interface Props {
value?: string | number
@@ -23,9 +24,7 @@ const props = withDefaults(defineProps<Props>(), {})
const _val = computed({
set(val: string) {
// const temp = val.toString().replaceAll(',', '')
const temp = val.toString().replaceAll(',', '')
emit('update:value', temp)
emit('update:value', normalizeDecimalInput(val))
},
get() {
return props.value ? usePrice(props.value as number, true, '').trim() : ''
@@ -1,17 +1 @@
export function usePrice(price: number, digit = true, unit = 'ریال') {
let _price = price.toString()
if (digit) {
_price = _price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
return `${_price} ${unit}`
}
export function useTowDecimal(num: string | number): string | number {
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
if (temp && temp.length > 0) return temp[0]
return Math.round(+num * 100) / 100
}
export function useFormat(num: string | number, unit = '') {
return usePrice(Math.abs(+useTowDecimal(num)), true, unit)
}
export { usePrice, usePriceWithoutType, useTowDecimal, useFormat } from '@/utils/usePrice'
File diff suppressed because one or more lines are too long
+27 -18
View File
@@ -1,9 +1,12 @@
<template>
<van-dialog
class="updateButton"
confirm-button-text="متوجه شدم"
v-model:show="show"
class="gold-loading-dialog updateButton"
teleport="body"
:z-index="zIndex"
:show-confirm-button="false"
@confirm="update()"
:close-on-click-overlay="false"
:close-on-popstate="false"
>
<div class="flex flex-col items-center p-2">
<DotLottieVue class="w-15rem h-15rem" autoplay loop src="/animIsTracking.json" />
@@ -16,21 +19,27 @@
</template>
<script setup lang="ts">
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import { update } from 'lodash'
import { ref } from 'vue'
import anim from '@/assets/img/anim/anim1.json'
import { computed } from 'vue'
import { DotLottieVue } from '@lottiefiles/dotlottie-vue'
interface Prop {
title: string
info?: string
infoHead?: string
isLine?: boolean
value?: string | number
}
const props = withDefaults(defineProps<Prop>(), {
isLine: false
import { APP_Z_OVERLAY } from '@/utils/zIndex'
const props = withDefaults(
defineProps<{
show?: boolean
zIndex?: number
}>(),
{
show: false,
zIndex: APP_Z_OVERLAY,
},
)
const emit = defineEmits<{
'update:show': [value: boolean]
}>()
const show = computed({
get: () => props.show,
set: (value: boolean) => emit('update:show', value),
})
</script>
<style scoped lang="less"></style>
+42
View File
@@ -0,0 +1,42 @@
<template>
<div v-if="showInstallEntry" class="mt-2 w-full">
<BasicButton class="!w-full" @click="onClick">
{{ canNativeInstall ? 'نصب اپلیکیشن' : 'آموزش نصب' }}
</BasicButton>
</div>
</template>
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import { usePwaInstall } from '@/composables/usePwaInstall'
import { PWA_MANIFEST_READY_EVENT } from '@/modules/pwa/manifest'
import {
hasNativeInstallPrompt,
initPwaInstallPromptListener,
} from '@/modules/pwa/pwaInstall'
const { tryInstallOrOpenGuide, showInstallEntry } = usePwaInstall()
const canNativeInstall = ref(false)
function refreshCanInstall() {
canNativeInstall.value = hasNativeInstallPrompt()
}
async function onClick() {
await tryInstallOrOpenGuide()
refreshCanInstall()
}
onMounted(() => {
initPwaInstallPromptListener()
refreshCanInstall()
window.addEventListener(PWA_MANIFEST_READY_EVENT, refreshCanInstall)
window.addEventListener('appinstalled', refreshCanInstall)
})
onUnmounted(() => {
window.removeEventListener(PWA_MANIFEST_READY_EVENT, refreshCanInstall)
window.removeEventListener('appinstalled', refreshCanInstall)
})
</script>
+56
View File
@@ -0,0 +1,56 @@
<template>
<img
:src="currentSrc"
:class="[imgClass, dimmed && 'product-image--dimmed']"
:alt="alt"
@error="handleError"
/>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue'
import {
getProductFallbackImage,
resolveProductImageSrc,
type ProductImageSource
} from '@/utils/productImage'
const props = withDefaults(
defineProps<{
product?: ProductImageSource
imgClass?: string
alt?: string
dimmed?: boolean
}>(),
{
imgClass: 'max-h-full max-w-full object-contain',
alt: '',
dimmed: false
}
)
const currentSrc = ref(resolveProductImageSrc(props.product))
const usingFallback = ref(false)
watch(
() => props.product,
(product) => {
usingFallback.value = false
currentSrc.value = resolveProductImageSrc(product)
},
{ deep: true }
)
function handleError() {
if (usingFallback.value) return
usingFallback.value = true
currentSrc.value = getProductFallbackImage(props.product)
}
</script>
<style scoped>
.product-image--dimmed {
opacity: 0.45;
filter: grayscale(1);
}
</style>
+89
View File
@@ -0,0 +1,89 @@
<template>
<div :class="variant === 'desktop' ? desktopRootClass : mobileRootClass">
<button
ref="triggerEl"
type="button"
class="support-contact-bar__btn"
:disabled="!canContactSupport"
@click="onSupportClick"
>
<BasicIcon icon="vuesax-linear:messages-2" size="20" color="#fff" />
<span>ارتباط با پشتیبانی</span>
</button>
</div>
</template>
<script lang="ts" setup>
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import { useSupportMessenger } from '@/composables/useSupportMessenger'
import { computed, ref } from 'vue'
withDefaults(
defineProps<{
variant?: 'mobile' | 'desktop'
mobileRootClass?: string
desktopRootClass?: string
}>(),
{
variant: 'mobile',
mobileRootClass: 'wrap-fix bottom-0 px-10 pb-3rem flex bg-white',
desktopRootClass: 'dpage-support',
},
)
const {
supportPhoneLink,
hasMessengerLink,
hasSupportPhoneLink,
openSupportMessenger,
} = useSupportMessenger()
const triggerEl = ref<HTMLElement | null>(null)
const canContactSupport = computed(() => hasMessengerLink.value || hasSupportPhoneLink.value)
async function onSupportClick() {
// همان رفتار دکمه شناور پشتیبانی — بدون پیش‌نویس واریز
if (hasMessengerLink.value) {
await openSupportMessenger(triggerEl.value)
return
}
if (hasSupportPhoneLink.value && supportPhoneLink.value) {
window.location.href = supportPhoneLink.value
}
}
</script>
<style scoped lang="less">
.support-contact-bar__btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5rem;
width: 100%;
min-height: 2.75rem;
padding: 0.65rem 1rem;
border: 0;
border-radius: 0.75rem;
background: var(--App-primary, @App-primary-color);
color: #fff;
font-size: 0.9375rem;
font-weight: 600;
cursor: pointer;
transition: opacity 0.15s ease, transform 0.15s ease;
&:active {
transform: scale(0.98);
}
&:disabled {
opacity: 0.55;
cursor: not-allowed;
}
}
.dpage-support {
width: 100%;
}
</style>
@@ -0,0 +1,72 @@
<template>
<span
class="support-brand-icon"
:class="{ 'support-brand-icon--eitaa': normalized === 'eitaa' }"
aria-hidden="true"
>
<img
v-if="logoSrc"
:src="logoSrc"
:alt="normalized"
class="support-brand-icon__img"
draggable="false"
/>
<svg v-else viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" class="support-brand-icon__svg">
<circle cx="24" cy="24" r="24" fill="#64748B" />
<path fill="#fff" d="M16 18h16v2H16v-2zm0 5h16v2H16v-2zm0 5h10v2H16v-2z" />
</svg>
</span>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import baleLogo from '@/assets/messengers/bale.png'
import callLogo from '@/assets/messengers/call.svg'
import eitaaLogo from '@/assets/messengers/eitaa.png'
import rubikaLogo from '@/assets/messengers/rubika.png'
import smsLogo from '@/assets/messengers/sms.svg'
import soroushLogo from '@/assets/messengers/soroush.svg'
import telegramLogo from '@/assets/messengers/telegram.svg'
import whatsappLogo from '@/assets/messengers/whatsapp.svg'
const LOGOS: Record<string, string> = {
bale: baleLogo,
telegram: telegramLogo,
whatsapp: whatsappLogo,
rubika: rubikaLogo,
eitaa: eitaaLogo,
soroush: soroushLogo,
call: callLogo,
sms: smsLogo,
}
const props = defineProps<{ messenger: string }>()
const normalized = computed(() => (props.messenger ?? '').trim().toLowerCase())
const logoSrc = computed(() => LOGOS[normalized.value])
</script>
<style scoped lang="less">
.support-brand-icon {
display: block;
width: 100%;
height: 100%;
border-radius: 50%;
overflow: hidden;
}
.support-brand-icon--eitaa {
background: #e37600;
.support-brand-icon__img {
filter: brightness(0) invert(1);
}
}
.support-brand-icon__img,
.support-brand-icon__svg {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
+300
View File
@@ -0,0 +1,300 @@
<template>
<Teleport to="body">
<Transition name="support-picker-backdrop">
<div
v-if="open"
class="support-messenger-picker__backdrop"
:class="{ 'is-active': backdropActive }"
@click="onBackdropClick"
/>
</Transition>
<div
v-show="open || closing"
class="support-messenger-picker__stack"
:class="[
{ 'is-open': open },
expandUp ? 'support-messenger-picker__stack--up' : 'support-messenger-picker__stack--down',
]"
:style="stackStyle"
role="menu"
aria-label="انتخاب پیام‌رسان"
>
<button
v-for="(entry, index) in entries"
:key="`${entry.messenger}-${entry.id}`"
type="button"
class="support-messenger-picker__btn"
:style="{ '--i': index, '--total': entries.length }"
:title="entry.label"
:aria-label="entry.label"
@click.stop="select(entry)"
>
<SupportMessengerBrandIcon v-if="entry.messenger !== 'chat'" :messenger="entry.messenger" />
<BasicIcon
v-else
:icon="entry.icon || 'vuesax-linear:messages-2'"
size="22"
:color="entry.accent || '#16a34a'"
/>
</button>
</div>
</Teleport>
</template>
<script lang="ts" setup>
import { nextTick, onBeforeUnmount, ref, watch } from 'vue'
import SupportMessengerBrandIcon from '@/components/SupportMessengerBrandIcon.vue'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import type { ResolvedSupportMessengerEntry } from '@/utils/supportMessenger'
const props = withDefaults(
defineProps<{
open: boolean
entries: ResolvedSupportMessengerEntry[]
anchorEl?: HTMLElement | null
}>(),
{
anchorEl: null,
},
)
const emit = defineEmits<{
'update:open': [value: boolean]
select: [entry: ResolvedSupportMessengerEntry]
}>()
const BTN_SIZE = 46
const GAP = 12
const STACK_GAP = 10
const CLOSE_MS = 220
const BACKDROP_GUARD_MS = 380
const stackStyle = ref<Record<string, string>>({})
const closing = ref(false)
const expandUp = ref(true)
const backdropActive = ref(false)
let closeTimer: ReturnType<typeof setTimeout> | null = null
let backdropTimer: ReturnType<typeof setTimeout> | null = null
function close() {
emit('update:open', false)
}
function select(entry: ResolvedSupportMessengerEntry) {
emit('select', entry)
close()
}
function clearTimers() {
if (closeTimer) {
clearTimeout(closeTimer)
closeTimer = null
}
if (backdropTimer) {
clearTimeout(backdropTimer)
backdropTimer = null
}
}
function onBackdropClick() {
if (!backdropActive.value) return
close()
}
function armBackdropGuard() {
backdropActive.value = false
if (backdropTimer) clearTimeout(backdropTimer)
backdropTimer = setTimeout(() => {
backdropActive.value = true
backdropTimer = null
}, BACKDROP_GUARD_MS)
}
async function reposition() {
await nextTick()
const anchor = props.anchorEl
const count = props.entries.length
if (!anchor || count === 0) {
expandUp.value = true
stackStyle.value = {
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
right: 'auto',
bottom: 'auto',
'--stack-rise': '56px',
}
return
}
const rect = anchor.getBoundingClientRect()
const stackHeight = count * BTN_SIZE + Math.max(0, count - 1) * GAP
const anchorCenterX = rect.left + rect.width / 2
const anchorCenterY = rect.top + rect.height / 2
const right = Math.max(12, window.innerWidth - anchorCenterX - BTN_SIZE / 2)
expandUp.value = anchorCenterY > window.innerHeight / 2
if (expandUp.value) {
const bottom = Math.max(12, window.innerHeight - rect.top + STACK_GAP)
stackStyle.value = {
right: `${right}px`,
bottom: `${bottom}px`,
left: 'auto',
top: 'auto',
transform: 'none',
'--stack-rise': `${Math.min(stackHeight + 6, 220)}px`,
}
} else {
const top = Math.max(12, rect.bottom + STACK_GAP)
stackStyle.value = {
right: `${right}px`,
top: `${top}px`,
left: 'auto',
bottom: 'auto',
transform: 'none',
'--stack-rise': `${Math.min(stackHeight + 6, 220)}px`,
}
}
}
watch(
() => props.open,
(isOpen) => {
clearTimers()
if (isOpen) {
closing.value = false
armBackdropGuard()
void reposition()
return
}
backdropActive.value = false
closing.value = true
const delay = CLOSE_MS + Math.max(0, props.entries.length - 1) * 28
closeTimer = setTimeout(() => {
closing.value = false
closeTimer = null
}, delay)
},
{ flush: 'post' },
)
watch(
() => [props.entries.length, props.anchorEl] as const,
() => {
if (props.open) void reposition()
},
)
function onViewportChange() {
if (props.open || closing.value) void reposition()
}
if (typeof window !== 'undefined') {
window.addEventListener('resize', onViewportChange, { passive: true })
window.addEventListener('scroll', onViewportChange, { passive: true, capture: true })
}
onBeforeUnmount(() => {
clearTimers()
if (typeof window === 'undefined') return
window.removeEventListener('resize', onViewportChange, { capture: true })
window.removeEventListener('scroll', onViewportChange, { capture: true })
})
</script>
<style scoped lang="less">
.support-messenger-picker__backdrop {
position: fixed;
inset: 0;
z-index: 5195;
background: rgba(15, 23, 42, 0.2);
pointer-events: none;
&.is-active {
pointer-events: auto;
}
}
.support-messenger-picker__stack {
position: fixed;
z-index: 5205;
display: flex;
align-items: center;
gap: 12px;
pointer-events: none;
}
.support-messenger-picker__stack--up {
flex-direction: column-reverse;
}
.support-messenger-picker__stack--down {
flex-direction: column;
}
.support-messenger-picker__btn {
--i: 0;
--total: 1;
--stack-rise: 56px;
pointer-events: auto;
width: 46px;
height: 46px;
padding: 0;
border: 0;
border-radius: 50%;
background: transparent;
cursor: pointer;
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2);
opacity: 0;
will-change: transform, opacity;
transition:
transform 0.22s cubic-bezier(0.2, 1, 0.3, 1),
opacity 0.16s ease,
box-shadow 0.16s ease;
transition-delay: calc(var(--i) * 38ms);
}
.support-messenger-picker__stack--up .support-messenger-picker__btn {
transform-origin: center bottom;
transform: translateY(calc(var(--stack-rise) * 0.55)) scale(0.2);
}
.support-messenger-picker__stack--down .support-messenger-picker__btn {
transform-origin: center top;
transform: translateY(calc(var(--stack-rise) * -0.55)) scale(0.2);
}
.support-messenger-picker__stack.is-open .support-messenger-picker__btn {
opacity: 1;
transform: translateY(0) scale(1);
}
.support-messenger-picker__stack:not(.is-open) .support-messenger-picker__btn {
transition-delay: calc((var(--total) - 1 - var(--i)) * 24ms);
transition-duration: 0.18s, 0.14s, 0.14s;
opacity: 0;
pointer-events: none;
}
.support-messenger-picker__stack--up:not(.is-open) .support-messenger-picker__btn {
transform: translateY(calc(var(--stack-rise) * 0.4)) scale(0.15);
}
.support-messenger-picker__stack--down:not(.is-open) .support-messenger-picker__btn {
transform: translateY(calc(var(--stack-rise) * -0.4)) scale(0.15);
}
.support-picker-backdrop-enter-active,
.support-picker-backdrop-leave-active {
transition: opacity 0.16s ease;
}
.support-picker-backdrop-enter-from,
.support-picker-backdrop-leave-to {
opacity: 0;
}
</style>
+102
View File
@@ -0,0 +1,102 @@
<template>
<div class="w-full rounded-lg bg-gray-50 p-3 trade-fee-summary">
<div class="flex justify-between items-center pb-3 border-b border-gray-200">
<div class="text-sm text-gray-600">مظنه هر {{ weightUnit }}</div>
<div class="flex items-center font-bold">
<span>{{ formattedUnitPrice }}</span>
<span class="text-xs mr-1 font-normal">ریال</span>
</div>
</div>
<div
v-for="(section, index) in breakdown.sections"
:key="section.heading"
class="mt-3"
:class="{ 'pt-3 border-t border-gray-200': index > 0 }"
>
<div class="text-sm font-bold text-gray-800 mb-2">{{ section.heading }}</div>
<div
v-for="(row, rowIndex) in section.rows"
:key="`${section.heading}-${rowIndex}`"
class="flex justify-between items-center py-1"
:class="{
'border-t border-dashed border-gray-300 mt-1 pt-2': row.dividerBefore,
'font-bold text-base': row.bold,
}"
>
<div class="text-sm" :class="row.bold ? 'text-gray-900' : 'text-gray-700'">
<span v-if="row.plus" class="text-green-700 ml-1">+</span>
<span v-else-if="row.minus && !row.bold" class="text-red-600 ml-1">−</span>
{{ row.label }}
</div>
<div
class="text-left text-sm"
:class="{
'text-red-600': row.minus && !row.bold,
'text-green-700': row.plus,
}"
>
<template v-if="row.gram != null">
<span>{{ formatTradeGramDisplay(row.gram) }}</span>
<span class="text-xs mr-1">{{ weightUnit }}</span>
</template>
<template v-else-if="row.rial != null">
<span v-if="row.minus && row.bold">−</span>
<span>{{ formatRial(row.rial) }}</span>
<span class="text-xs mr-1">ریال</span>
</template>
</div>
</div>
<div v-if="section.footnote" class="text-xs text-gray-600 mt-2 leading-relaxed bg-white rounded-lg px-2 py-1.5">
{{ section.footnote }}
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import { usePriceWithoutType } from '@/utils/usePrice'
import {
buildTradeConfirmBreakdown,
formatTradeGramDisplay,
type TradeInputLock,
} from '@/utils/serviceFee'
const props = defineProps<{
isBuy: boolean
inputLock: TradeInputLock
displayTradeGoldAmount: number
weightUnit: string
unitPriceRial: number
feeInGrams: number
equivalentPrice: string
payablePrice: number
orderGoldAmount: number
feeInRial: number
sellGoldDebit?: number
}>()
const formattedUnitPrice = computed(() =>
usePriceWithoutType(Math.round(props.unitPriceRial))
)
function formatRial(value: number) {
return usePriceWithoutType(Math.round(value))
}
const breakdown = computed(() =>
buildTradeConfirmBreakdown({
isBuy: props.isBuy,
inputLock: props.inputLock,
orderGoldAmount: props.orderGoldAmount,
feeInGrams: props.feeInGrams,
feeInRial: props.feeInRial,
payablePrice: props.payablePrice,
unitPriceRial: props.unitPriceRial,
sellGoldDebit: props.sellGoldDebit,
})
)
</script>
+375
View File
@@ -0,0 +1,375 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import {
PWA_GUIDE_STEP_LABELS,
PWA_INSTALL_GUIDE,
type PwaPlatform,
} from '@/modules/pwa/pwaInstallGuideSteps'
import { getDefaultPwaPlatform } from '@/modules/pwa/pwaInstall'
import PwaInstallStepIllustration from '@/components/pwa/PwaInstallStepIllustration.vue'
const props = defineProps<{
open: boolean
platform?: PwaPlatform
}>()
const emit = defineEmits<{
'update:open': [value: boolean]
complete: []
close: []
}>()
const activePlatform = ref<PwaPlatform>(props.platform ?? getDefaultPwaPlatform())
const stepIndex = ref(0)
const guide = computed(() => PWA_INSTALL_GUIDE[activePlatform.value])
const currentStep = computed(() => guide.value.steps[stepIndex.value])
const totalSteps = computed(() => guide.value.steps.length)
const isFirstStep = computed(() => stepIndex.value === 0)
const isLastStep = computed(() => stepIndex.value === totalSteps.value - 1)
const stepLabel = computed(() => PWA_GUIDE_STEP_LABELS[stepIndex.value] ?? String(stepIndex.value + 1))
watch(
() => props.open,
(visible) => {
if (!visible) return
activePlatform.value = props.platform ?? getDefaultPwaPlatform()
stepIndex.value = 0
},
)
watch(
() => props.platform,
(value) => {
if (value) activePlatform.value = value
},
)
function close() {
emit('update:open', false)
emit('close')
}
function selectPlatform(next: PwaPlatform) {
if (activePlatform.value === next) return
activePlatform.value = next
stepIndex.value = 0
}
function goNext() {
if (isLastStep.value) {
emit('complete')
close()
return
}
stepIndex.value += 1
}
function goPrev() {
if (isFirstStep.value) return
stepIndex.value -= 1
}
function completeGuide() {
emit('complete')
close()
}
</script>
<template>
<Teleport to="body">
<div
v-if="open"
class="pwa-install-guide"
role="dialog"
aria-modal="true"
aria-labelledby="pwa-install-guide-title"
@click.self="close"
>
<div class="pwa-install-guide__card">
<div class="pwa-install-guide__tabs">
<button
type="button"
class="pwa-install-guide__tab"
:class="{ 'pwa-install-guide__tab--active': activePlatform === 'ios' }"
@click="selectPlatform('ios')"
>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<rect x="7" y="2" width="10" height="20" rx="2.5" stroke="currentColor" stroke-width="1.5" />
<circle cx="12" cy="18.5" r="1" fill="currentColor" />
</svg>
<span>آیفون</span>
</button>
<button
type="button"
class="pwa-install-guide__tab"
:class="{ 'pwa-install-guide__tab--active': activePlatform === 'android' }"
@click="selectPlatform('android')"
>
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true">
<path d="M12 4v12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
<path d="M8.5 8.5 12 5l3.5 3.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
<path d="M6 16h12v3a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1v-3Z" stroke="currentColor" stroke-width="1.5" />
</svg>
<span>اندروید</span>
</button>
</div>
<div class="pwa-install-guide__header">
<span class="pwa-install-guide__progress">
مرحله {{ stepLabel }} از {{ PWA_GUIDE_STEP_LABELS.length }}
</span>
<h2 id="pwa-install-guide-title" class="pwa-install-guide__title">
{{ guide.title }}
</h2>
</div>
<div class="pwa-install-guide__content">
<span class="pwa-install-guide__badge">{{ stepLabel }}</span>
<PwaInstallStepIllustration :type="currentStep.illustration" />
<p class="pwa-install-guide__text">{{ currentStep.text }}</p>
<p v-if="currentStep.hint" class="pwa-install-guide__hint">{{ currentStep.hint }}</p>
</div>
<div class="pwa-install-guide__nav">
<template v-if="isLastStep">
<BasicButton class="pwa-install-guide__primary" type="primary" @click="completeGuide">
متوجه شدم
</BasicButton>
</template>
<template v-else>
<button
type="button"
class="pwa-install-guide__nav-btn"
:disabled="isFirstStep"
aria-label="مرحله قبل"
@click="goPrev"
>
‹
</button>
<div class="pwa-install-guide__dots" aria-hidden="true">
<span
v-for="(_, index) in totalSteps"
:key="index"
class="pwa-install-guide__dot"
:class="{ 'pwa-install-guide__dot--active': index === stepIndex }"
/>
</div>
<button
type="button"
class="pwa-install-guide__nav-btn"
aria-label="مرحله بعد"
@click="goNext"
>
›
</button>
</template>
</div>
<template v-if="!isLastStep">
<BasicButton class="pwa-install-guide__primary" type="primary" @click="goNext">
بعدی
<span class="pwa-install-guide__primary-chevron">›</span>
</BasicButton>
<button type="button" class="pwa-install-guide__close" @click="close">
بستن
</button>
</template>
</div>
</div>
</Teleport>
</template>
<style scoped lang="less">
.pwa-install-guide {
position: fixed;
inset: 0;
z-index: var(--app-z-modal, 5500);
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
background: rgba(15, 23, 42, 0.45);
}
.pwa-install-guide__card {
width: min(100%, 360px);
background: #fff;
border-radius: 24px;
padding: 14px 16px 18px;
box-shadow: 0 24px 48px rgba(15, 23, 42, 0.18);
}
.pwa-install-guide__tabs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4px;
padding: 4px;
border-radius: 14px;
background: #f1f5f9;
}
.pwa-install-guide__tab {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
border: none;
border-radius: 10px;
padding: 10px 8px;
font-size: 13px;
font-weight: 600;
color: #64748b;
background: transparent;
cursor: pointer;
transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
&--active {
color: #0f172a;
background: #fff;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
}
.pwa-install-guide__header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 14px 2px 10px;
}
.pwa-install-guide__progress {
font-size: 12px;
color: #94a3b8;
white-space: nowrap;
}
.pwa-install-guide__title {
margin: 0;
font-size: 14px;
font-weight: 700;
color: #0f172a;
text-align: right;
}
.pwa-install-guide__content {
position: relative;
border: 1px solid #e2e8f0;
border-radius: 18px;
background: #f8fafc;
padding: 14px 14px 16px;
min-height: 280px;
}
.pwa-install-guide__badge {
position: absolute;
top: 12px;
right: 12px;
width: 28px;
height: 28px;
border-radius: 999px;
background: #2563eb;
color: #fff;
font-size: 13px;
font-weight: 700;
display: inline-flex;
align-items: center;
justify-content: center;
}
.pwa-install-guide__text {
margin: 10px 0 0;
font-size: 13px;
line-height: 1.8;
color: #334155;
text-align: center;
}
.pwa-install-guide__hint {
margin: 8px 0 0;
font-size: 11px;
line-height: 1.7;
color: #64748b;
text-align: center;
}
.pwa-install-guide__nav {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
margin: 14px 0 12px;
.pwa-install-guide__primary {
width: 100%;
margin: 0;
}
}
.pwa-install-guide__nav-btn {
width: 34px;
height: 34px;
border: 1px solid #e2e8f0;
border-radius: 10px;
background: #fff;
color: #334155;
font-size: 20px;
line-height: 1;
cursor: pointer;
&:disabled {
opacity: 0.35;
cursor: not-allowed;
}
}
.pwa-install-guide__dots {
display: flex;
align-items: center;
gap: 6px;
}
.pwa-install-guide__dot {
width: 7px;
height: 7px;
border-radius: 999px;
background: #cbd5e1;
transition: width 0.15s ease, background 0.15s ease;
&--active {
width: 22px;
background: #2563eb;
}
}
.pwa-install-guide__primary {
width: 100%;
height: 44px;
border-radius: 14px !important;
font-weight: 700;
}
.pwa-install-guide__primary-chevron {
margin-right: 4px;
font-size: 16px;
}
.pwa-install-guide__close {
display: block;
width: 100%;
margin-top: 10px;
border: none;
background: transparent;
color: #64748b;
font-size: 13px;
cursor: pointer;
}
</style>
@@ -0,0 +1,413 @@
<script setup lang="ts">
import type { PwaGuideIllustration } from '@/modules/pwa/pwaInstallGuideSteps'
import shareAppleIcon from '@/assets/img/share-apple.png'
import addToHomeScreenIcon from '@/assets/img/Add-to-homeScreen.png'
defineProps<{
type: PwaGuideIllustration
}>()
</script>
<template>
<div
class="pwa-step-illustration"
:class="{
'pwa-step-illustration--android-menu': type === 'android-menu',
'pwa-step-illustration--ios-safari': type === 'ios-safari',
}"
>
<div
class="pwa-step-illustration__phone"
:class="{
'pwa-step-illustration__phone--android-menu': type === 'android-menu',
'pwa-step-illustration__phone--ios-safari': type === 'ios-safari',
}"
>
<div
class="pwa-step-illustration__screen"
:class="{
'pwa-step-illustration__screen--android-menu': type === 'android-menu',
'pwa-step-illustration__screen--ios-safari': type === 'ios-safari',
}"
>
<template v-if="type === 'android-chrome'">
<div class="pwa-step-illustration__browser-bar">
<span class="pwa-step-illustration__dot pwa-step-illustration__dot--red" />
<span class="pwa-step-illustration__dot pwa-step-illustration__dot--yellow" />
<span class="pwa-step-illustration__dot pwa-step-illustration__dot--green" />
</div>
<div class="pwa-step-illustration__chrome-body" />
<div class="pwa-step-illustration__chrome-label">باز در Chrome</div>
</template>
<template v-else-if="type === 'android-menu'">
<div class="android-menu-scene">
<div class="android-menu-scene__toolbar">
<div class="android-menu-scene__url-bar" />
<div class="android-menu-scene__menu-target" aria-hidden="true">
<span class="android-menu-scene__menu-dots">⋮</span>
</div>
</div>
<div class="android-menu-scene__viewport">
<div class="android-menu-scene__dropdown">
<div class="android-menu-scene__dropdown-line" />
<div class="android-menu-scene__dropdown-line android-menu-scene__dropdown-line--short" />
<div class="android-menu-scene__dropdown-install">
Install app
</div>
</div>
</div>
</div>
</template>
<template v-else-if="type === 'android-install'">
<div class="pwa-step-illustration__install-btn">Install</div>
</template>
<template v-else-if="type === 'android-confirm'">
<div class="pwa-step-illustration__app-icon" />
<div class="pwa-step-illustration__home-label">روی صفحه اصلی</div>
</template>
<template v-else-if="type === 'ios-safari'">
<div class="ios-safari-scene">
<div class="ios-safari-scene__toolbar">
<span class="ios-safari-scene__toolbar-label">Safari</span>
</div>
<div class="ios-safari-scene__viewport">
<div class="ios-safari-scene__placeholder" />
</div>
<div class="ios-safari-scene__caption">باز در Safari</div>
</div>
</template>
<template v-else-if="type === 'ios-share'">
<div class="pwa-step-illustration__share-wrap">
<img :src="shareAppleIcon" alt="" class="pwa-step-illustration__share-icon" />
</div>
</template>
<template v-else-if="type === 'ios-add-home'">
<div class="pwa-step-illustration__sheet">
<div class="pwa-step-illustration__sheet-item">Share</div>
<div class="pwa-step-illustration__sheet-item pwa-step-illustration__sheet-item--active">
<img :src="addToHomeScreenIcon" alt="" class="pwa-step-illustration__sheet-icon" />
Add to Home Screen
</div>
</div>
</template>
<template v-else-if="type === 'ios-confirm'">
<div class="pwa-step-illustration__app-icon" />
<div class="pwa-step-illustration__home-label">روی صفحه اصلی</div>
</template>
</div>
</div>
</div>
</template>
<style scoped lang="less">
.pwa-step-illustration {
display: flex;
justify-content: center;
padding: 8px 0 4px;
}
.pwa-step-illustration__phone {
width: 148px;
height: 220px;
border: 2px solid #cbd5e1;
border-radius: 22px;
padding: 10px 8px;
background: #fff;
}
.pwa-step-illustration__screen {
position: relative;
width: 100%;
height: 100%;
border: 1px solid #e2e8f0;
border-radius: 14px;
background: #f8fafc;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
}
.pwa-step-illustration__browser-bar {
position: absolute;
top: 10px;
left: 12px;
display: flex;
gap: 4px;
}
.pwa-step-illustration__dot {
width: 7px;
height: 7px;
border-radius: 999px;
&--red { background: #ef4444; }
&--yellow { background: #f59e0b; }
&--green { background: #22c55e; }
}
.pwa-step-illustration__chrome-body {
width: 78%;
height: 42%;
border-radius: 8px;
background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
margin-top: 18px;
}
.pwa-step-illustration__chrome-label,
.pwa-step-illustration__home-label {
font-size: 10px;
color: #64748b;
}
.pwa-step-illustration--android-menu,
.pwa-step-illustration--ios-safari {
padding: 12px 0 0;
}
.pwa-step-illustration__phone--android-menu,
.pwa-step-illustration__phone--ios-safari {
width: 132px;
height: 208px;
padding: 0;
border-width: 1.5px;
border-color: #cbd5e1;
border-radius: 20px;
box-shadow: none;
}
.pwa-step-illustration__screen--android-menu,
.pwa-step-illustration__screen--ios-safari {
border: none;
border-radius: 18px;
background: #fff;
display: block;
overflow: hidden;
}
.ios-safari-scene {
position: relative;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
.ios-safari-scene__toolbar {
display: flex;
align-items: center;
justify-content: center;
min-height: 28px;
padding: 8px 10px 6px;
border-bottom: 1px solid #eef2f7;
background: #fff;
}
.ios-safari-scene__toolbar-label {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 72px;
padding: 4px 10px;
border-radius: 999px;
background: #eef2f7;
color: #64748b;
font-size: 9px;
font-weight: 600;
}
.ios-safari-scene__viewport {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 14px 12px 8px;
background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}
.ios-safari-scene__placeholder {
width: 78%;
height: 58%;
border-radius: 12px;
background: linear-gradient(180deg, #dbeafe 0%, #bfdbfe 100%);
box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}
.ios-safari-scene__caption {
padding: 0 10px 10px;
text-align: center;
font-size: 9px;
color: #64748b;
background: #fff;
}
.android-menu-scene {
position: relative;
width: 100%;
height: 100%;
}
.android-menu-scene__toolbar {
position: relative;
z-index: 2;
display: flex;
align-items: center;
justify-content: space-between;
gap: 6px;
padding: 10px 8px 8px;
border-bottom: 1px solid #eef2f7;
}
.android-menu-scene__url-bar {
flex: 1;
height: 8px;
border-radius: 999px;
background: #e8edf5;
}
.android-menu-scene__menu-target {
flex: 0 0 auto;
width: 24px;
height: 24px;
border: 1.5px dashed #2563eb;
border-radius: 999px;
display: flex;
align-items: center;
justify-content: center;
background: rgba(37, 99, 235, 0.04);
}
.android-menu-scene__menu-dots {
font-size: 14px;
line-height: 1;
font-weight: 700;
color: #334155;
transform: translateY(-1px);
}
.android-menu-scene__viewport {
position: relative;
height: calc(100% - 41px);
background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}
.android-menu-scene__dropdown {
position: absolute;
top: 6px;
right: 8px;
width: 78px;
padding: 8px 8px 10px;
border-radius: 10px;
background: #fff;
border: 1px solid #e2e8f0;
box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.android-menu-scene__dropdown-line {
height: 4px;
border-radius: 999px;
background: #e2e8f0;
margin-bottom: 6px;
&--short {
width: 72%;
margin-bottom: 8px;
}
}
.android-menu-scene__dropdown-install {
display: flex;
align-items: center;
justify-content: center;
min-height: 22px;
padding: 4px 6px;
border-radius: 6px;
background: #eff6ff;
border: 1px solid #bfdbfe;
color: #2563eb;
font-size: 8px;
font-weight: 700;
line-height: 1.2;
text-align: center;
}
.pwa-step-illustration__install-btn {
font-size: 11px;
font-weight: 600;
color: #2563eb;
border: 1px solid #2563eb;
border-radius: 8px;
padding: 6px 14px;
background: #eff6ff;
}
.pwa-step-illustration__app-icon {
width: 42px;
height: 42px;
border-radius: 12px;
background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}
.pwa-step-illustration__share-wrap {
position: absolute;
bottom: 14px;
width: 34px;
height: 34px;
border: 2px dashed #2563eb;
border-radius: 999px;
display: flex;
align-items: center;
justify-content: center;
background: #fff;
}
.pwa-step-illustration__share-icon {
width: 18px;
height: 18px;
object-fit: contain;
}
.pwa-step-illustration__sheet {
width: 88%;
border-radius: 10px;
background: #fff;
border: 1px solid #e2e8f0;
overflow: hidden;
}
.pwa-step-illustration__sheet-item {
padding: 8px 10px;
font-size: 9px;
color: #64748b;
border-bottom: 1px solid #f1f5f9;
display: flex;
align-items: center;
gap: 6px;
&--active {
color: #2563eb;
border: 1px solid #2563eb;
border-radius: 8px;
margin: 6px;
font-weight: 600;
}
}
.pwa-step-illustration__sheet-icon {
width: 14px;
height: 14px;
object-fit: contain;
}
</style>
+220
View File
@@ -0,0 +1,220 @@
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
import { notification } from 'ant-design-vue'
import { getAppNotificationsUnreadCount } from '@/api/appNotifications'
import { useSettingsStore } from '@/store/settingsStore'
import { getToken } from '@/utils'
import { showBrowserNotification } from '@/utils/browserNotification'
import { priceSocketConnected, priceWssEnabled } from '@/utils/priceSocketState'
import { APP_Z_TOAST } from '@/utils/zIndex'
const unreadCount = ref(0)
let started = false
let lastStreamNotifId = 0
let hydratedUnread = false
let lastShownNotifId = 0
let toastConfigured = false
let hydrateFallbackTimer: ReturnType<typeof setTimeout> | null = null
function ensureNotifToastConfig() {
if (toastConfigured) return
toastConfigured = true
notification.config({
placement: 'topRight',
top: 'calc(var(--app-home-header-offset, 4.25rem) + 0.5rem)',
duration: 5,
})
}
function notificationsEnabled(): boolean {
return Boolean(getToken()) && useSettingsStore().isSettingTruthy('has_page_notification')
}
function clearHydrateFallback() {
if (hydrateFallbackTimer) {
clearTimeout(hydrateFallbackTimer)
hydrateFallbackTimer = null
}
}
/** از SSE رویداد unread-count — بدون HTTP */
function applyUnreadCountFromStream(payload: Record<string, unknown>) {
if (!notificationsEnabled()) {
unreadCount.value = 0
hydratedUnread = false
return
}
const next = Number(payload.unread_count ?? 0) || 0
unreadCount.value = Math.max(0, next)
hydratedUnread = true
clearHydrateFallback()
}
/** فقط وقتی SSE در دسترس نیست یا برای ریفرش دستی صفحه اعلان‌ها */
async function refreshUnreadCount() {
if (!notificationsEnabled()) {
unreadCount.value = 0
hydratedUnread = false
return
}
try {
const data = await getAppNotificationsUnreadCount()
unreadCount.value = Number(data?.unread_count ?? 0) || 0
hydratedUnread = true
} catch {
// silent — badge optional
}
}
function clearUnreadLocally() {
unreadCount.value = 0
}
function showInAppToast(title: string, body: string) {
try {
ensureNotifToastConfig()
notification.open({
message: title || 'اعلان جدید',
description: body || undefined,
placement: 'topRight',
duration: 5,
class: 'app-notif-toast',
style: { zIndex: APP_Z_TOAST },
onClick: () => {
void import('@/router').then((mod) => {
mod.default.push({ name: 'appNotifications' }).catch(() => undefined)
})
},
})
} catch {
// ignore
}
}
async function presentNotification(payload: {
id?: number
title?: string
body?: string
}) {
const id = Number(payload.id ?? 0)
if (id > 0 && id === lastShownNotifId) {
return
}
if (id > 0) {
lastShownNotifId = id
}
const title = String(payload.title ?? '').trim() || 'اعلان جدید'
const body = String(payload.body ?? '').trim()
showInAppToast(title, body)
await showBrowserNotification({
title,
body,
tag: id > 0 ? `app-notification-${id}` : undefined,
url: '/appNotifications',
})
}
/** از SSE رویداد app_notification — بدون polling HTTP */
function bumpUnreadFromStream(payload: Record<string, unknown>) {
if (!notificationsEnabled()) {
return
}
const id = Number(payload.id ?? 0)
if (id > 0 && id === lastStreamNotifId) {
return
}
if (id > 0) {
lastStreamNotifId = id
}
if (payload.unread_count !== undefined && payload.unread_count !== null) {
applyUnreadCountFromStream(payload)
} else {
unreadCount.value = Math.max(0, unreadCount.value) + 1
hydratedUnread = true
clearHydrateFallback()
}
void presentNotification({
id,
title: String(payload.title ?? ''),
body: String(payload.body ?? ''),
})
}
/**
* بدون interval: اگر استریم قیمت روشن است منتظر رویداد SSE می‌مانیم؛
* فقط وقتی wss خاموش است یا SSE تا ۱۲ثانیه نیامد، یک‌بار HTTP می‌زنیم.
*/
function scheduleHydrate() {
if (!notificationsEnabled()) {
unreadCount.value = 0
hydratedUnread = false
clearHydrateFallback()
return
}
if (!priceWssEnabled.value) {
void refreshUnreadCount()
return
}
if (priceSocketConnected.value || hydratedUnread) {
clearHydrateFallback()
return
}
clearHydrateFallback()
hydrateFallbackTimer = setTimeout(() => {
hydrateFallbackTimer = null
if (!hydratedUnread && notificationsEnabled() && !priceSocketConnected.value) {
void refreshUnreadCount()
}
}, 12000)
}
export function useAppNotificationBadge() {
const settingsStore = useSettingsStore()
const enabled = computed(() => settingsStore.isSettingTruthy('has_page_notification'))
onMounted(() => {
started = true
scheduleHydrate()
})
onUnmounted(() => {
// module-level badge — keep state for other headers
})
watch(enabled, (on) => {
if (!on) {
unreadCount.value = 0
hydratedUnread = false
clearHydrateFallback()
} else {
scheduleHydrate()
}
})
watch([priceSocketConnected, priceWssEnabled], () => {
if (!started) return
scheduleHydrate()
})
return {
enabled,
unreadCount,
refreshUnreadCount,
clearUnreadLocally,
}
}
export {
refreshUnreadCount,
clearUnreadLocally,
bumpUnreadFromStream,
applyUnreadCountFromStream,
}
+55
View File
@@ -0,0 +1,55 @@
import { ref } from 'vue'
import { getProducts } from '@/api/products'
import type { Product } from '@/models/products'
import { getLastStreamProductsList } from '@/utils/productStreamBridge'
/** کش مشترک لیست محصولات — dedupe درخواست‌های polling */
const catalogProducts = ref<Product[]>([])
let catalogPromise: Promise<Product[]> | null = null
export function getProductsCatalogRef() {
return catalogProducts
}
export function findProductInCatalog(id: number): Product | undefined {
const cached = catalogProducts.value.find((p) => p.id === id)
if (cached) {
return cached
}
return getLastStreamProductsList()?.find((p) => p.id === id)
}
export function getProductsCatalog(force = false): Promise<Product[]> {
if (!force) {
const streamed = getLastStreamProductsList()
if (streamed?.length) {
catalogProducts.value = streamed
return Promise.resolve(streamed)
}
if (catalogProducts.value.length > 0) {
return Promise.resolve(catalogProducts.value)
}
}
if (!force && catalogPromise) {
return catalogPromise
}
catalogPromise = getProducts()
.then((products) => {
catalogProducts.value = products ?? []
return catalogProducts.value
})
.finally(() => {
catalogPromise = null
})
return catalogPromise
}
export function clearProductsCatalog() {
catalogProducts.value = []
catalogPromise = null
}
+132
View File
@@ -0,0 +1,132 @@
import { computed, onMounted, ref } from 'vue'
import type { PwaPlatform } from '@/modules/pwa/pwaInstallGuideSteps'
import {
getDefaultPwaPlatform,
initPwaInstallPromptListener,
isPwaInstallBannerDismissed,
markPwaInstallBannerAsShown,
shouldOfferPwaInstall,
shouldShowPwaInstallPrompt,
triggerNativePwaInstall,
} from '@/modules/pwa/pwaInstall'
const guideOpen = ref(false)
const bannerVisible = ref(false)
const platform = ref<PwaPlatform>(getDefaultPwaPlatform())
const installBannerConsumed = ref(isPwaInstallBannerDismissed())
/** false وقتی اپ به‌صورت PWA/TWA باز شده یا همین الان نصب شده */
const offerInstall = ref(shouldOfferPwaInstall())
let listenerReady = false
let offerListenersBound = false
function refreshOfferInstall() {
offerInstall.value = shouldOfferPwaInstall()
}
function bindOfferInstallListeners() {
if (offerListenersBound || typeof window === 'undefined') return
offerListenersBound = true
refreshOfferInstall()
const onInstalled = () => {
offerInstall.value = false
}
window.addEventListener('appinstalled', onInstalled)
const modes = ['standalone', 'fullscreen', 'minimal-ui', 'window-controls-overlay'] as const
const mediaLists = modes.map((mode) => window.matchMedia(`(display-mode: ${mode})`))
const onDisplayModeChange = () => refreshOfferInstall()
for (const mql of mediaLists) {
mql.addEventListener('change', onDisplayModeChange)
}
}
function ensureListener() {
if (listenerReady) return
listenerReady = true
initPwaInstallPromptListener()
bindOfferInstallListeners()
}
export function usePwaInstall() {
ensureListener()
onMounted(() => {
refreshOfferInstall()
})
const canPrompt = computed(() => {
if (installBannerConsumed.value) return false
return shouldShowPwaInstallPrompt()
})
const showInstallEntry = computed(() => offerInstall.value)
function consumeInstallBanner() {
if (installBannerConsumed.value) return
markPwaInstallBannerAsShown()
installBannerConsumed.value = true
bannerVisible.value = false
}
function openGuide(nextPlatform?: PwaPlatform) {
if (!offerInstall.value) return
consumeInstallBanner()
platform.value = nextPlatform ?? getDefaultPwaPlatform()
guideOpen.value = true
}
function closeGuide() {
guideOpen.value = false
}
function showBanner() {
if (!canPrompt.value) return
bannerVisible.value = true
markPwaInstallBannerAsShown()
installBannerConsumed.value = true
}
function hideBanner() {
bannerVisible.value = false
}
function dismissBanner() {
consumeInstallBanner()
}
async function completeGuide() {
await triggerNativePwaInstall()
consumeInstallBanner()
closeGuide()
}
/** نصب مستقیم مرورگر؛ اگر ممکن نبود مدال آموزش. */
async function tryInstallOrOpenGuide(nextPlatform?: PwaPlatform) {
if (!offerInstall.value) return false
const installed = await triggerNativePwaInstall()
if (installed) {
offerInstall.value = false
consumeInstallBanner()
return true
}
openGuide(nextPlatform)
return false
}
return {
guideOpen,
bannerVisible,
platform,
canPrompt,
showInstallEntry,
openGuide,
closeGuide,
showBanner,
hideBanner,
dismissBanner,
completeGuide,
tryInstallOrOpenGuide,
}
}
+291
View File
@@ -0,0 +1,291 @@
import { computed, ref } from 'vue'
import { message } from 'ant-design-vue'
import { useRouter } from 'vue-router'
import {
buildDepositSmsUrl,
buildSupportPhoneUrl,
loadSupportMessengerFromSettings,
messengerNeedsClipboardCopy,
openSupportMessengerEntry,
resolveDepositGuideText,
resolveDepositSupportMessage,
resolveSupportMessengerEntries,
resolveSupportMessengerLink,
resolveSupportMessengerMeta,
supportMessengerPickerAnchor,
supportMessengerPickerOpen,
supportMessengerSettings,
type ResolvedSupportMessengerEntry,
} from '@/utils/supportMessenger'
import {
copyDepositFieldValue,
displayDepositCardNumber,
displayDepositSheba,
getDepositGuideVarsFromSettings,
getDepositSettingLabel,
hasDepositFieldValue,
} from '@/utils/depositGuideText'
import { useSettingsStore } from '@/store/settingsStore'
import { isUserSupportChatEnabled } from '@/utils/chat'
/** plain: منوی شناور / درباره ما — بدون پیش‌متن | deposit: مودال واریز — با deposit_support_message_text */
type SupportPickerIntent = 'plain' | 'deposit'
const CHAT_PICKER_ENTRY: ResolvedSupportMessengerEntry = {
messenger: 'chat',
id: 'support-chat',
label: 'چت پشتیبانی',
icon: 'vuesax-linear:messages-2',
accent: '#16a34a',
url: '',
}
export function useSupportMessenger() {
const settingsStore = useSettingsStore()
const router = useRouter()
const supportPickerOpen = supportMessengerPickerOpen
const supportPickerIntent = ref<SupportPickerIntent>('plain')
const isChatEnabled = computed(() => isUserSupportChatEnabled())
const legacySupportLink = computed(() => '')
const depositSupportMessage = computed(() => resolveDepositSupportMessage())
const supportMessengerEntries = computed(() =>
resolveSupportMessengerEntries(supportMessengerSettings.value),
)
const pickerEntries = computed(() => {
const list = [...supportMessengerEntries.value]
if (isChatEnabled.value) {
list.unshift(CHAT_PICKER_ENTRY)
}
return list
})
const primaryMessengerEntry = computed(() => supportMessengerEntries.value[0] ?? null)
const messengerType = computed(
() => (primaryMessengerEntry.value?.messenger ?? supportMessengerSettings.value.messenger ?? '').trim().toLowerCase(),
)
const messengerMeta = computed(() => {
if (isChatEnabled.value && supportMessengerEntries.value.length === 0) {
return {
label: CHAT_PICKER_ENTRY.label,
icon: CHAT_PICKER_ENTRY.icon,
accent: CHAT_PICKER_ENTRY.accent,
}
}
return primaryMessengerEntry.value
? {
label: primaryMessengerEntry.value.label,
icon: primaryMessengerEntry.value.icon,
accent: primaryMessengerEntry.value.accent,
}
: resolveSupportMessengerMeta(messengerType.value)
})
const messengerLink = computed(() =>
primaryMessengerEntry.value?.url
|| resolveSupportMessengerLink(
supportMessengerSettings.value.messenger,
supportMessengerSettings.value.messengerId,
legacySupportLink.value,
),
)
function goToSupportChat() {
void router.push({ name: 'support' })
return true
}
async function openMessengerEntry(entry: ResolvedSupportMessengerEntry, text?: string) {
if (entry.messenger === 'chat') {
return goToSupportChat()
}
const messageText =
text !== undefined
? text.trim()
: supportPickerIntent.value === 'deposit'
? depositSupportMessage.value.trim()
: ''
const opened = await openSupportMessengerEntry(entry, messageText, legacySupportLink.value)
if (!opened) return false
if (messageText && messengerNeedsClipboardCopy(entry.messenger)) {
message.success('متن پیام کپی شد — در پیام‌رسان paste کنید')
}
return true
}
let supportPickerOpenedAt = 0
async function openSupportPicker(
intent: SupportPickerIntent,
anchorEl?: HTMLElement | null,
) {
supportPickerIntent.value = intent
if (anchorEl !== undefined) {
supportMessengerPickerAnchor.value = anchorEl
}
const draft =
intent === 'deposit' ? depositSupportMessage.value.trim() : ''
const messengerEntries = supportMessengerEntries.value
const entries = pickerEntries.value
// لیست خالی + چت خاموش → هیچ‌کار
if (entries.length === 0) {
return false
}
// فقط چت (لیست پیام‌رسان خالی) → مستقیم چت
if (isChatEnabled.value && messengerEntries.length === 0) {
return goToSupportChat()
}
// فقط یک گزینه (چت یا یک پیام‌رسان) → مستقیم همان
if (entries.length === 1) {
return openMessengerEntry(entries[0], draft)
}
// چند گزینه (چت + لینک‌ها یا چند پیام‌رسان) → منوی انتخاب
const now = Date.now()
if (supportPickerOpen.value) {
if (now - supportPickerOpenedAt < 450) return true
supportPickerOpen.value = false
return true
}
supportPickerOpen.value = true
supportPickerOpenedAt = now
return true
}
async function openSupportMessenger(anchorEl?: HTMLElement | null) {
return openSupportPicker('plain', anchorEl)
}
async function openDepositSupportMessenger(anchorEl?: HTMLElement | null) {
return openSupportPicker('deposit', anchorEl)
}
function handleSupportMessengerClick(event?: Event) {
const target = event?.currentTarget
const anchor = target instanceof HTMLElement ? target : null
void openSupportMessenger(anchor)
}
const depositSmsLink = computed(() =>
buildDepositSmsUrl(
supportMessengerSettings.value.depositSmsSupportNumber,
depositSupportMessage.value,
),
)
const supportPhoneLink = computed(() => {
const fromSettings = buildSupportPhoneUrl(
supportMessengerSettings.value.depositSmsSupportNumber,
)
if (fromSettings) return fromSettings
const legacy = legacySupportLink.value
if (legacy.startsWith('tel:') && legacy.length > 4) return legacy
return ''
})
const supportMessengerText = computed(() => resolveDepositGuideText())
const depositCardNumberRaw = computed(() => {
void settingsStore.settings
const fromMessenger = supportMessengerSettings.value.depositCardNumber?.trim()
if (fromMessenger) return fromMessenger
return String(getDepositGuideVarsFromSettings().cardNumber ?? '').trim()
})
const depositShebaRaw = computed(() => {
void settingsStore.settings
const fromMessenger = supportMessengerSettings.value.depositSheba?.trim()
if (fromMessenger) return fromMessenger
return String(getDepositGuideVarsFromSettings().sheba ?? '').trim()
})
const depositCardNumber = computed(() => displayDepositCardNumber(depositCardNumberRaw.value))
const depositSheba = computed(() => displayDepositSheba(depositShebaRaw.value))
const depositCardLabel = computed(() => {
void settingsStore.settings
return getDepositSettingLabel('deposit_card_number', 'شماره کارت واریز')
})
const depositShebaLabel = computed(() => {
void settingsStore.settings
return getDepositSettingLabel('deposit_sheba', 'شبا واریز')
})
const hasDepositCardValue = computed(() => hasDepositFieldValue(depositCardNumberRaw.value))
const hasDepositShebaValue = computed(() => hasDepositFieldValue(depositShebaRaw.value))
async function copyDepositCardNumber() {
await copyDepositFieldValue(
depositCardNumberRaw.value,
'card',
'شماره کارت ثبت نشده است',
)
}
async function copyDepositShebaNumber() {
await copyDepositFieldValue(
depositShebaRaw.value,
'sheba',
'شماره شبا ثبت نشده است',
)
}
const hasMessengerLink = computed(
() => isChatEnabled.value || supportMessengerEntries.value.length > 0,
)
const hasMultipleMessengers = computed(() => pickerEntries.value.length > 1)
const hasSupportPhoneLink = computed(() => !!supportPhoneLink.value)
const hasSupportActions = computed(() => hasSupportPhoneLink.value || hasMessengerLink.value)
const opensInNewTab = computed(() => /^https?:\/\//i.test(messengerLink.value))
return {
supportPickerOpen,
supportPickerAnchor: supportMessengerPickerAnchor,
supportMessengerEntries: pickerEntries,
isChatEnabled,
messengerType,
messengerMeta,
messengerLink,
supportPhoneLink,
depositSmsLink,
supportMessengerText,
depositSupportMessage,
depositCardNumber,
depositSheba,
depositCardNumberRaw,
depositShebaRaw,
depositCardLabel,
depositShebaLabel,
hasDepositCardValue,
hasDepositShebaValue,
copyDepositCardNumber,
copyDepositShebaNumber,
openSupportMessenger,
openDepositSupportMessenger,
openMessengerEntry,
handleSupportMessengerClick,
goToSupportChat,
hasMessengerLink,
hasMultipleMessengers,
hasSupportPhoneLink,
hasSupportActions,
opensInNewTab,
loadSupportMessengerFromSettings,
}
}
@@ -0,0 +1,21 @@
import { onMounted, ref } from 'vue'
import { fetchTrackingSettings, isTrackingSystemsEnabled } from '@/utils/trackingSystemsSettings'
export function useTrackingSystemsFeature() {
const trackingSystemsEnabled = ref(false)
const trackingSystemsReady = ref(false)
onMounted(async () => {
try {
const settings = await fetchTrackingSettings()
trackingSystemsEnabled.value = isTrackingSystemsEnabled(settings)
} finally {
trackingSystemsReady.value = true
}
})
return {
trackingSystemsEnabled,
trackingSystemsReady,
}
}
+70
View File
@@ -0,0 +1,70 @@
import { ref } from 'vue'
import { getWalletAssets } from '@/api/wallet'
import { getProductsCatalog, getProductsCatalogRef } from '@/composables/useProductsCatalog'
import { useWalletStore } from '@/store/walletStore'
import type { WalletAssetsSummary } from '@/models/walletAssets'
import { enrichInventoryCardsWithCatalog } from '@/utils/productAssets'
const assetsSummary = ref<WalletAssetsSummary | null>(null)
let assetsPromise: Promise<WalletAssetsSummary> | null = null
function enrichAssetsSummary(data: WalletAssetsSummary): WalletAssetsSummary {
const catalog = getProductsCatalogRef().value
return {
...data,
inventory_cards: enrichInventoryCardsWithCatalog(data.inventory_cards ?? [], catalog ?? []),
count_products: enrichInventoryCardsWithCatalog(data.count_products ?? [], catalog ?? []),
}
}
function syncWalletStoreFromAssets(data: WalletAssetsSummary) {
const walletStore = useWalletStore()
if (!walletStore.walletInfo) {
return
}
const goldMetal = data.metal_totals?.find((metal) => metal.metal_id === 1) ?? data.metal_totals?.[0]
walletStore.walletInfo.cash = data.cash_wallet ?? walletStore.walletInfo.cash
if (goldMetal) {
walletStore.walletInfo.gold = goldMetal.melted_weight ?? walletStore.walletInfo.gold
walletStore.walletInfo.gold_sum = goldMetal.total_weight ?? walletStore.walletInfo.gold_sum
}
}
export function useWalletAssets() {
async function loadWalletAssets(force = false) {
if (!force && assetsSummary.value) {
return assetsSummary.value
}
if (!force && assetsPromise) {
return assetsPromise
}
assetsPromise = Promise.all([getWalletAssets(), getProductsCatalog(force)])
.then(([data]) => {
assetsSummary.value = enrichAssetsSummary(data)
syncWalletStoreFromAssets(assetsSummary.value)
return assetsSummary.value
})
.finally(() => {
assetsPromise = null
})
return assetsPromise
}
function clearWalletAssets() {
assetsSummary.value = null
assetsPromise = null
}
return {
assetsSummary,
loadWalletAssets,
clearWalletAssets,
}
}
+83
View File
@@ -0,0 +1,83 @@
import type { AppConfig } from './types'
type RawAppConfig = AppConfig & {
user?: Record<string, any>
}
const EMPTY_STRING_CONFIG_KEYS = new Set([
'color',
'secondary_color',
'background_color',
'theme_config',
])
function emptyStringToNull(value: unknown) {
if (typeof value === 'string' && value.trim() === '') {
return null
}
return value
}
function normalizeUserConfig(user?: Record<string, any>) {
if (!user || typeof user !== 'object') {
return user
}
const normalized: Record<string, any> = { ...user }
for (const key of EMPTY_STRING_CONFIG_KEYS) {
if (key in normalized) {
normalized[key] = emptyStringToNull(normalized[key])
}
}
return normalized
}
export function normalizeAppConfig(config: RawAppConfig): RawAppConfig {
if (!config || typeof config !== 'object') {
return {}
}
if (!config.user || typeof config.user !== 'object') {
return config
}
return {
...config,
user: normalizeUserConfig(config.user),
}
}
let appConfig: RawAppConfig | null = null
export function setAppConfig(config: RawAppConfig) {
appConfig = normalizeAppConfig(config || {})
window.__APP_CONFIG__ = appConfig
}
export function getRawAppConfig() {
return appConfig ?? window.__APP_CONFIG__ ?? null
}
export function getTenantConfig() {
const rawConfig = getRawAppConfig()
if (rawConfig?.user && typeof rawConfig.user === 'object') {
return rawConfig.user
}
if (rawConfig && Object.keys(rawConfig).length > 0) {
return rawConfig
}
return {}
}
export function getConfig<T = any>(key: string, fallback?: T): T {
const config = getTenantConfig()
const value = emptyStringToNull(config?.[key])
return (value ?? fallback ?? null) as T
}
+83
View File
@@ -0,0 +1,83 @@
import { getConfig } from '@/config/app-config'
import { isPwaManifestReady } from '@/modules/pwa/manifest'
export function applyAppConfig() {
if (isPwaManifestReady()) return
setTitle()
setFavicon()
setAppleTouchIconFallback()
}
function setTitle() {
document.title = getConfig('name_fa', 'در حال بارگذاری...')
}
function getLogoUrl() {
return getConfig<string>('avatar') || '/favicon.png'
}
function setFavicon() {
let faviconLink =
document.querySelector<HTMLLinkElement>("link[rel='icon']") ||
document.querySelector<HTMLLinkElement>("link[rel~='icon']")
if (!faviconLink) {
faviconLink = document.createElement('link')
faviconLink.rel = 'icon'
document.head.appendChild(faviconLink)
}
const logoUrl = getLogoUrl()
faviconLink.type = 'image/png'
faviconLink.href = logoUrl.startsWith('http') ? logoUrl : resolveRemoteLogo(logoUrl)
}
function setAppleTouchIconFallback() {
const logoUrl = getLogoUrl()
if (!logoUrl) return
if (document.querySelector("link[rel='apple-touch-icon'][data-dynamic-pwa='true']")) {
return
}
const sizes = ['180x180', '152x152', '120x120']
sizes.forEach((size) => {
let link = document.querySelector<HTMLLinkElement>(
`link[rel='apple-touch-icon'][sizes='${size}']`
)
if (!link) {
link = document.createElement('link')
link.rel = 'apple-touch-icon'
link.sizes = size
document.head.appendChild(link)
}
link.href = logoUrl.startsWith('http') ? logoUrl : resolveRemoteLogo(logoUrl)
})
let appleTitle = document.querySelector<HTMLMetaElement>("meta[name='apple-mobile-web-app-title']")
if (!appleTitle) {
appleTitle = document.createElement('meta')
appleTitle.name = 'apple-mobile-web-app-title'
document.head.appendChild(appleTitle)
}
appleTitle.content = getConfig('name_fa', 'اپ مشتری')
}
function resolveRemoteLogo(path: string) {
if (/^(https?:\/\/|data:|blob:)/i.test(path)) return path
const lastSuccess = localStorage.getItem('CONFIG_Success_URL')
const base = lastSuccess
? lastSuccess.replace(/[?#].*$/, '').replace(/\/get_user\/?$/i, '').replace(/\/+$/, '')
: 'https://adm.montzar.ir'
return `${base}/${path.replace(/^\/+/, '')}`
}
+281
View File
@@ -0,0 +1,281 @@
import type { AppConfig } from '@/config/types'
import { resetVersionCheckCache } from '@/config/load-version'
import { clearCachedPwaManifest } from '@/modules/pwa/manifest-cache'
import { tokenName } from '@/themeConfig'
const CONFIG_COOKIE_NAME = 'APP_CONFIG_CACHE'
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
const CONFIG_COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 7
const MAX_COOKIE_VALUE_LENGTH = 3500
const VERSION_STORAGE_KEY = 'version'
const VERSION_UPDATE_LOCK_KEY = 'version_update_lock'
const VERSION_LAST_RELOAD_KEY = 'version_last_reload'
type CachedConfigPayload = {
cached_at: number
config: AppConfig
}
type VersionUpdateLock = {
version: string
started_at: number
}
function getCookie(name: string) {
const cookie = document.cookie.split('; ').find((row) => row.startsWith(`${name}=`))
if (!cookie) return null
return cookie.substring(name.length + 1)
}
function setCookie(name: string, value: string, maxAgeSeconds: number) {
const secure = window.location.protocol === 'https:' ? '; Secure' : ''
document.cookie = [
`${name}=${value}`,
'Path=/',
`Max-Age=${maxAgeSeconds}`,
'SameSite=Lax',
secure
].join('; ')
}
export function readCachedAppConfig(): AppConfig | null {
try {
const rawCookie = getCookie(CONFIG_COOKIE_NAME)
if (!rawCookie) return null
const decoded = decodeURIComponent(rawCookie)
const payload = JSON.parse(decoded) as CachedConfigPayload
if (!payload?.config) return null
return payload.config
} catch (error) {
console.warn('Failed to read cached app config:', error)
clearCachedAppConfig()
return null
}
}
export function writeCachedAppConfig(config: AppConfig) {
try {
const payload: CachedConfigPayload = {
cached_at: Date.now(),
config
}
const encoded = encodeURIComponent(JSON.stringify(payload))
if (encoded.length > MAX_COOKIE_VALUE_LENGTH) {
console.warn(`App config is too large for cookie cache. Size: ${encoded.length}`)
return
}
setCookie(CONFIG_COOKIE_NAME, encoded, CONFIG_COOKIE_MAX_AGE_SECONDS)
} catch (error) {
console.warn('Failed to write app config cache:', error)
}
}
export function clearCachedAppConfig() {
document.cookie = `${CONFIG_COOKIE_NAME}=; Path=/; Max-Age=0; SameSite=Lax`
clearCachedPwaManifest()
}
export function getStoredAppVersion() {
return localStorage.getItem(VERSION_STORAGE_KEY)
}
export function getDisplayAppVersion(fallbackVersion: string) {
return getStoredAppVersion() || fallbackVersion
}
export function writeStoredAppVersion(version: string) {
localStorage.setItem(VERSION_STORAGE_KEY, String(version).trim())
}
export function getNormalizedVersion(version: unknown) {
if (version === null || version === undefined) return ''
return String(version).trim()
}
export function shouldUpdateForVersion(serverVersion: unknown) {
const normalizedServerVersion = getNormalizedVersion(serverVersion)
if (!normalizedServerVersion) return false
const storedVersion = getStoredAppVersion()
if (!storedVersion) {
writeStoredAppVersion(normalizedServerVersion)
return false
}
return storedVersion !== normalizedServerVersion
}
export function canStartVersionUpdate(serverVersion: string) {
const version = getNormalizedVersion(serverVersion)
if (!version) return false
const lastReloadVersion = sessionStorage.getItem(VERSION_LAST_RELOAD_KEY)
if (lastReloadVersion === version) {
return false
}
const rawLock = sessionStorage.getItem(VERSION_UPDATE_LOCK_KEY)
if (rawLock) {
try {
const lock = JSON.parse(rawLock) as VersionUpdateLock
const isSameVersion = lock.version === version
const isFreshLock = Date.now() - lock.started_at < 60_000
if (isSameVersion && isFreshLock) {
return false
}
} catch {
sessionStorage.removeItem(VERSION_UPDATE_LOCK_KEY)
}
}
return true
}
export function startVersionUpdateLock(serverVersion: string) {
const version = getNormalizedVersion(serverVersion)
const lock: VersionUpdateLock = {
version,
started_at: Date.now()
}
sessionStorage.setItem(VERSION_UPDATE_LOCK_KEY, JSON.stringify(lock))
}
export function finishVersionUpdateBeforeReload(serverVersion: string) {
const version = getNormalizedVersion(serverVersion)
writeStoredAppVersion(version)
sessionStorage.setItem(VERSION_LAST_RELOAD_KEY, version)
sessionStorage.removeItem(VERSION_UPDATE_LOCK_KEY)
}
export function cancelVersionUpdateLock() {
sessionStorage.removeItem(VERSION_UPDATE_LOCK_KEY)
}
function clearReadableCookiesExceptConfigAlreadyHandled() {
document.cookie.split(';').forEach((cookie) => {
const name = cookie.split('=')[0]?.trim()
if (!name) return
document.cookie = `${name}=; Path=/; Max-Age=0; SameSite=Lax`
})
}
export async function clearBrowserRuntimeCaches() {
try {
if ('serviceWorker' in navigator) {
const registrations = await navigator.serviceWorker.getRegistrations()
await Promise.all(registrations.map((registration) => registration.unregister()))
}
} catch (error) {
console.warn('Could not unregister service workers:', error)
}
try {
if (!('caches' in window)) return
const cacheKeys = await caches.keys()
await Promise.all(cacheKeys.map((key) => caches.delete(key)))
} catch (error) {
console.warn('Could not clear browser caches:', error)
}
}
function clearLocalStorageExceptToken() {
const token = localStorage.getItem(tokenName)
localStorage.clear()
if (token) {
localStorage.setItem(tokenName, token)
}
}
export function clearAppStorageExceptToken() {
clearReadableCookiesExceptConfigAlreadyHandled()
clearLocalStorageExceptToken()
sessionStorage.clear()
}
export function clearAllBootstrapFetchCaches() {
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
clearCachedPwaManifest()
resetVersionCheckCache()
window.__APP_CONFIG__ = undefined
}
export function hardReloadApp() {
const refreshUrl = `${window.location.origin}${window.location.pathname}?__app_refresh=${Date.now()}`
window.location.href = refreshUrl
}
export async function refreshConfigCacheForVersion(
newVersion: string,
fetchConfig: () => Promise<AppConfig>
) {
const normalizedVersion = getNormalizedVersion(newVersion)
if (!normalizedVersion) {
throw new Error('Version is empty')
}
startVersionUpdateLock(normalizedVersion)
clearCachedAppConfig()
clearAppStorageExceptToken()
clearAllBootstrapFetchCaches()
await clearBrowserRuntimeCaches()
const freshConfig = await fetchConfig()
writeCachedAppConfig(freshConfig)
finishVersionUpdateBeforeReload(normalizedVersion)
return freshConfig
}
export async function resetAppAndRefreshConfig(
fetchConfig: () => Promise<AppConfig>,
version?: string | null
) {
const normalizedVersion = getNormalizedVersion(version)
clearCachedAppConfig()
clearAppStorageExceptToken()
clearAllBootstrapFetchCaches()
await clearBrowserRuntimeCaches()
const freshConfig = await fetchConfig()
writeCachedAppConfig(freshConfig)
if (normalizedVersion) {
writeStoredAppVersion(normalizedVersion)
}
return freshConfig
}
+129
View File
@@ -0,0 +1,129 @@
import type { AppConfig } from '@/config/types'
import { normalizeAppConfig } from '@/config/app-config'
import { readCachedAppConfig, writeCachedAppConfig } from '@/config/config-cache'
import {
allowSuperAdminFallback,
getSuperAdminBase,
getSuperAdminBases,
isSuperAdminUrl,
resolveTenantDomain,
SA_RETRY_ROUNDS,
} from '@/config/superadmin'
const CONFIG_SUCCESS_URL_KEY = 'CONFIG_Success_URL'
export const CONFIG_RETRY_ROUNDS = SA_RETRY_ROUNDS
function getProtocol() {
return window.location.protocol === 'https:' ? 'https:' : 'http:'
}
export function getConfigUrls() {
const protocol = getProtocol()
const domain = encodeURIComponent(resolveTenantDomain())
const urls = getSuperAdminBases().map((base) => `${base}/get_user?domain=${domain}`)
if (allowSuperAdminFallback()) {
urls.push(
`${protocol}//tablo.talasevin.ir/get_user`,
`${protocol}//abshode-service.montgit.ir/server/get_user`,
`${protocol}//212.23.201.173:8381/get_user`,
`${protocol}//91.212.174.137:4040/server/get_user`,
)
}
return urls
}
export function sortConfigUrls(urls: string[]) {
const lastSuccessUrl = localStorage.getItem(CONFIG_SUCCESS_URL_KEY)
if (
!lastSuccessUrl ||
!urls.includes(lastSuccessUrl) ||
!isSuperAdminUrl(lastSuccessUrl)
) {
if (lastSuccessUrl && !isSuperAdminUrl(lastSuccessUrl)) {
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
}
return [...urls]
}
return [lastSuccessUrl, ...urls.filter((url) => url !== lastSuccessUrl)]
}
function clearStaleConfigSuccessUrl(url: string) {
if (localStorage.getItem(CONFIG_SUCCESS_URL_KEY) === url) {
localStorage.removeItem(CONFIG_SUCCESS_URL_KEY)
}
}
async function fetchConfig(url: string, timeout = 3000): Promise<AppConfig> {
const controller = new AbortController()
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
try {
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
},
cache: 'no-store',
signal: controller.signal,
})
if (!response.ok) {
throw new Error(`Config request failed with status ${response.status}`)
}
const contentType = response.headers.get('content-type') ?? ''
if (!contentType.includes('application/json')) {
throw new Error('Config response is not JSON')
}
return normalizeAppConfig(await response.json())
} finally {
clearTimeout(timeoutId)
}
}
export async function fetchFreshAppConfig(rounds = CONFIG_RETRY_ROUNDS): Promise<AppConfig> {
const urls = sortConfigUrls(getConfigUrls())
for (let round = 1; round <= rounds; round++) {
for (let index = 0; index < urls.length; index++) {
const url = urls[index]
try {
const timeout = index === urls.length - 1 ? 7000 : 4000
const config = await fetchConfig(url, timeout)
if (isSuperAdminUrl(url)) {
localStorage.setItem(CONFIG_SUCCESS_URL_KEY, url)
} else {
clearStaleConfigSuccessUrl(url)
}
writeCachedAppConfig(config)
return config
} catch (error) {
clearStaleConfigSuccessUrl(url)
console.warn(`Config failed from ${url}. Round: ${round}`, error)
}
}
}
throw new Error(
getSuperAdminBase()
? `Cannot load from SuperAdmin (${getSuperAdminBase()}).`
: 'Cannot load app config from any server',
)
}
export async function loadAppConfig(): Promise<AppConfig> {
const cachedConfig = readCachedAppConfig()
if (cachedConfig) {
return normalizeAppConfig(cachedConfig)
}
return await fetchFreshAppConfig()
}
+189
View File
@@ -0,0 +1,189 @@
import {
allowSuperAdminFallback,
getSuperAdminBases,
isSuperAdminUrl,
resolveTenantDomain,
SA_RETRY_ROUNDS,
} from '@/config/superadmin'
type VersionResponse =
| string
| number
| {
version?: string | number
data?: string | number | { version?: string | number; value?: string | number }
value?: string | number
user?: unknown
}
const VERSION_SUCCESS_URL_KEY = 'VERSION_Success_URL'
export const VERSION_RETRY_ROUNDS = SA_RETRY_ROUNDS
let versionFetchPromise: Promise<string | null> | null = null
function getProtocol() {
return window.location.protocol === 'https:' ? 'https:' : 'http:'
}
function getVersionUrls() {
const protocol = getProtocol()
const domain = encodeURIComponent(resolveTenantDomain())
const urls = getSuperAdminBases().map((base) => `${base}/get_version?domain=${domain}`)
if (allowSuperAdminFallback()) {
urls.push(
'https://tablo.talasevin.ir/get_version',
'https://abshode-service.montgit.ir/server/get_version',
`${protocol}//212.23.201.173:8381/get_version`,
`${protocol}//91.212.174.137:4040/server/get_version`,
)
}
return urls
}
function sortVersionUrls(urls: string[]) {
const lastSuccessUrl = localStorage.getItem(VERSION_SUCCESS_URL_KEY)
if (
!lastSuccessUrl ||
!urls.includes(lastSuccessUrl) ||
!isSuperAdminUrl(lastSuccessUrl)
) {
if (lastSuccessUrl && !isSuperAdminUrl(lastSuccessUrl)) {
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
}
return [...urls]
}
return [lastSuccessUrl, ...urls.filter((url) => url !== lastSuccessUrl)]
}
function clearStaleVersionSuccessUrl(url: string) {
if (localStorage.getItem(VERSION_SUCCESS_URL_KEY) === url) {
localStorage.removeItem(VERSION_SUCCESS_URL_KEY)
}
}
function readUserVersion(user: unknown) {
if (!user || typeof user !== 'object' || Array.isArray(user)) {
return ''
}
const record = user as { version?: string | number; value?: string | number }
const version = record.version ?? record.value
return version === undefined || version === null ? '' : String(version).trim()
}
function normalizeVersionResponse(response: VersionResponse) {
if (typeof response === 'string' || typeof response === 'number') {
return String(response).trim()
}
if (!response) return ''
if (typeof response.data === 'string' || typeof response.data === 'number') {
return String(response.data).trim()
}
const directVersion =
response.version ??
response.value ??
(typeof response.data === 'object' ? response.data?.version ?? response.data?.value : undefined)
if (directVersion !== undefined && directVersion !== null) {
return String(directVersion).trim()
}
return readUserVersion(response.user)
}
async function fetchVersion(url: string, timeout = 3500): Promise<string | null> {
const controller = new AbortController()
const timeoutId = window.setTimeout(() => controller.abort(), timeout)
try {
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
},
cache: 'no-store',
signal: controller.signal,
})
if (!response.ok) {
throw new Error(`Version request failed with status ${response.status}`)
}
const contentType = response.headers.get('content-type') ?? ''
if (!contentType.includes('application/json')) {
throw new Error('Version response is not JSON')
}
const data = (await response.json()) as VersionResponse
const version = normalizeVersionResponse(data)
if (!version) {
throw new Error('Version response is empty')
}
if (isSuperAdminUrl(url)) {
localStorage.setItem(VERSION_SUCCESS_URL_KEY, url)
} else {
clearStaleVersionSuccessUrl(url)
}
return version
} finally {
window.clearTimeout(timeoutId)
}
}
async function fetchVersionWithRetry(rounds = VERSION_RETRY_ROUNDS): Promise<string | null> {
const urls = sortVersionUrls(getVersionUrls())
for (let round = 1; round <= rounds; round++) {
for (let index = 0; index < urls.length; index++) {
const url = urls[index]
const timeout = index === urls.length - 1 ? 6000 : 3500
try {
const version = await fetchVersion(url, timeout)
if (version) {
return version
}
} catch (error) {
clearStaleVersionSuccessUrl(url)
console.warn(`Version failed from ${url}. Round: ${round}`, error)
}
}
}
return null
}
export function resetVersionCheckCache() {
versionFetchPromise = null
}
export async function loadRemoteAppVersion(options?: {
rounds?: number
force?: boolean
}): Promise<string | null> {
const rounds = options?.rounds ?? VERSION_RETRY_ROUNDS
const force = options?.force ?? false
if (force) {
resetVersionCheckCache()
}
if (versionFetchPromise) {
return versionFetchPromise
}
versionFetchPromise = fetchVersionWithRetry(rounds).finally(() => {
versionFetchPromise = null
})
return versionFetchPromise
}
+83
View File
@@ -0,0 +1,83 @@
/** سوپرادمین — مستر، بعد دو اسلیو */
export const SUPERADMIN_BASES = [
'https://adm.montzar.ir',
'https://adm.montech.ir',
'https://adm.montest.ir',
] as const
/** هر API: سه دامنه × سه دور */
export const SA_RETRY_ROUNDS = 3
/** تنظیمات پیشرفته نسخه — همان دادهٔ /get_settings بدون نیاز به nginx جدا */
export const SA_PROGRAM_SETTINGS_PATH = '/api/public/program-settings'
function normalizeBase(url: string) {
return String(url || '').trim().replace(/\/$/, '')
}
export function getSuperAdminBases(): string[] {
const fromEnv = normalizeBase(String(import.meta.env.VITE_SUPERADMIN_URL || ''))
const bases = [...SUPERADMIN_BASES]
if (fromEnv) {
return [fromEnv, ...bases.filter((base) => base !== fromEnv)]
}
return bases
}
export function getSuperAdminBase(): string {
return getSuperAdminBases()[0] || ''
}
export function resolveTenantDomain(): string {
const override = String(import.meta.env.VITE_TENANT_DOMAIN || '').trim()
if (override) return override
const host = String(window.location.hostname || '').trim()
if (!host || host === 'localhost' || host === '127.0.0.1') {
return 'k.montzar.ir'
}
return host
}
export function isSuperAdminUrl(url: string): boolean {
return getSuperAdminBases().some((base) => url.startsWith(base))
}
export function allowSuperAdminFallback(): boolean {
return Boolean(import.meta.env.DEV)
}
export async function fetchSuperAdminJson<T>(
buildUrl: (base: string) => string,
timeout = 5000,
): Promise<T> {
let lastError: unknown
const bases = getSuperAdminBases()
for (let round = 1; round <= SA_RETRY_ROUNDS; round++) {
for (const base of bases) {
const controller = new AbortController()
const timer = window.setTimeout(() => controller.abort(), timeout)
try {
const res = await fetch(buildUrl(base), {
method: 'GET',
cache: 'no-store',
signal: controller.signal,
headers: { Accept: 'application/json' },
})
if (!res.ok) {
throw new Error(`HTTP ${res.status}`)
}
const contentType = res.headers.get('content-type') || ''
if (!contentType.includes('application/json')) {
throw new Error('SuperAdmin response is not JSON')
}
return (await res.json()) as T
} catch (error) {
lastError = error
} finally {
window.clearTimeout(timer)
}
}
}
throw lastError instanceof Error ? lastError : new Error('SuperAdmin unreachable')
}
+20
View File
@@ -0,0 +1,20 @@
export interface AppConfig {
mode?: string
theme?: string
name?: string
name_fa?: string
avatar?: string
color?: string
background_color?: string
secondary_color?: string
node_server?: string
node_ws?: string
manifest_url?: string
user?: Record<string, any>
[key: string]: any
}
+12
View File
@@ -0,0 +1,12 @@
<template>
<DesktopAppLayout v-if="isDesktopLayout" />
<MobileAppLayout v-else />
</template>
<script lang="ts" setup>
import { useDesktopBreakpoint } from './composables/useAppLayout'
import DesktopAppLayout from './desktop/DesktopAppLayout.vue'
import MobileAppLayout from './mobile/MobileAppLayout.vue'
const isDesktopLayout = useDesktopBreakpoint()
</script>
@@ -0,0 +1,27 @@
<template>
<div class="dpage">
<header v-if="title" class="dpage-topbar">
<div>
<h1 class="dpage-topbar__title">{{ title }}</h1>
<p v-if="subtitle" class="dpage-topbar__subtitle">{{ subtitle }}</p>
</div>
<slot name="actions" />
</header>
<slot />
</div>
</template>
<script lang="ts" setup>
defineProps<{
title?: string
subtitle?: string
}>()
</script>
<style scoped>
.dpage-topbar__subtitle {
font-size: 14px;
color: #6b7280;
margin: 6px 0 0;
}
</style>
@@ -0,0 +1,44 @@
<template>
<header class="dpage-topbar" :class="{ 'dpage-topbar--sticky': sticky }">
<button
v-if="showBack"
type="button"
class="dpage-topbar__back"
@click="handleBack"
>
<BasicIcon icon="vuesax-linear:arrow-right-1" size="16" />
<span>بازگشت</span>
</button>
<div class="dpage-topbar__meta">
<p v-if="eyebrow" class="dpage-topbar__eyebrow">{{ eyebrow }}</p>
<h1 class="dpage-topbar__title">{{ title }}</h1>
<p v-if="subtitle" class="dpage-topbar__subtitle">{{ subtitle }}</p>
</div>
<div v-if="$slots.trailing">
<slot name="trailing" />
</div>
</header>
</template>
<script setup lang="ts">
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import router from '@/router'
withDefaults(
defineProps<{
title: string
eyebrow?: string
subtitle?: string
showBack?: boolean
sticky?: boolean
}>(),
{
showBack: false,
sticky: true,
},
)
function handleBack() {
router.back()
}
</script>
@@ -0,0 +1,35 @@
<template>
<div class="mpage-header wrap-fix">
<button
v-if="showBack"
type="button"
class="mpage-header__back"
@click="handleBack"
>
<BasicIcon icon="vuesax-linear:arrow-right-1" />
</button>
<div class="mpage-header__title">{{ title }}</div>
<div v-if="$slots.trailing" class="mpage-header__trailing">
<slot name="trailing" />
</div>
</div>
</template>
<script setup lang="ts">
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import router from '@/router'
withDefaults(
defineProps<{
title: string
showBack?: boolean
}>(),
{
showBack: false,
},
)
function handleBack() {
router.back()
}
</script>
@@ -0,0 +1,35 @@
<template>
<div class="responsive-view-pair">
<div v-show="!isDesktop" class="responsive-view-pair__pane">
<slot name="mobile" />
</div>
<div v-show="isDesktop" class="responsive-view-pair__pane">
<slot name="desktop" />
</div>
</div>
</template>
<script lang="ts" setup>
import { useDesktopBreakpoint } from '../composables/useResponsiveLayout'
const isDesktop = useDesktopBreakpoint()
</script>
<style scoped>
.responsive-view-pair {
min-height: 0;
height: 100%;
width: 100%;
max-width: 100%;
min-width: 0;
overflow-x: hidden;
}
.responsive-view-pair__pane {
min-height: 0;
height: 100%;
width: 100%;
max-width: 100%;
min-width: 0;
}
</style>
+26
View File
@@ -0,0 +1,26 @@
import { useMediaQuery } from '@vueuse/core'
import { onUnmounted, watch } from 'vue'
import { DESKTOP_LAYOUT_MIN_WIDTH } from '../constants'
const DESKTOP_LAYOUT_CLASS = 'app-layout--desktop'
export function useDesktopBreakpoint() {
return useMediaQuery(`(min-width: ${DESKTOP_LAYOUT_MIN_WIDTH}px)`)
}
export function useApplyDesktopLayoutClass() {
const isDesktopLayout = useDesktopBreakpoint()
const stop = watch(
isDesktopLayout,
(desktop) => {
document.documentElement.classList.toggle(DESKTOP_LAYOUT_CLASS, desktop)
},
{ immediate: true }
)
onUnmounted(() => {
stop()
document.documentElement.classList.remove(DESKTOP_LAYOUT_CLASS)
})
}
@@ -0,0 +1,48 @@
import { computed, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
export function useAppNavigation() {
const router = useRouter()
const route = useRoute()
const popVisible = ref(false)
const currentRoute = computed(() => route.name)
const hideMenu = computed(() => !!route.meta.hideMenu)
/** فقط ناو پایین موبایل — سایدبار دسکتاپ را مخفی نمی‌کند */
const hideBottomNav = computed(
() => !!route.meta.hideBottomNav || !!route.meta.hideMenu,
)
function isNavActive(routeName: string) {
return currentRoute.value === routeName
}
function navItemClass(routeName: string) {
return isNavActive(routeName) ? 'text-primary' : 'text-gray-400'
}
function navigateTo(routeName: string) {
popVisible.value = false
router.push({ name: routeName })
}
function toggleOverflowMenu() {
popVisible.value = !popVisible.value
}
function closeOverflowMenu() {
popVisible.value = false
}
return {
popVisible,
currentRoute,
hideMenu,
hideBottomNav,
isNavActive,
navItemClass,
navigateTo,
toggleOverflowMenu,
closeOverflowMenu,
}
}
@@ -0,0 +1,125 @@
import { nextTick } from 'vue'
import router from '@/router'
let recoveryTimers: ReturnType<typeof setTimeout>[] = []
function clearRecoveryTimers() {
recoveryTimers.forEach(clearTimeout)
recoveryTimers = []
}
function blurFocusedField() {
const active = document.activeElement
if (active instanceof HTMLElement && active !== document.body) {
active.blur()
}
}
function clearBodyScrollLock() {
document.body.classList.remove('van-overflow-hidden')
document.body.style.removeProperty('position')
document.body.style.removeProperty('top')
document.body.style.removeProperty('left')
document.body.style.removeProperty('right')
document.body.style.removeProperty('width')
document.body.style.removeProperty('height')
document.body.style.removeProperty('min-height')
document.body.style.removeProperty('overflow')
document.body.style.removeProperty('transform')
document.documentElement.style.removeProperty('overflow')
document.documentElement.style.removeProperty('height')
document.documentElement.style.removeProperty('transform')
const appRoot = document.getElementById('app')
if (appRoot) {
appRoot.style.removeProperty('position')
appRoot.style.removeProperty('top')
appRoot.style.removeProperty('height')
appRoot.style.removeProperty('min-height')
appRoot.style.removeProperty('overflow')
appRoot.style.removeProperty('transform')
}
}
function resetAllScrollPositions() {
window.scrollTo(0, 0)
document.documentElement.scrollTop = 0
document.body.scrollTop = 0
document
.querySelectorAll('.main-with-bottom-chrome-inner, .login-page, .login-page-root')
.forEach((node) => {
if (node instanceof HTMLElement) {
node.scrollTop = 0
}
})
}
function kickViewportReflow() {
window.dispatchEvent(new Event('resize'))
if (window.visualViewport) {
window.scrollTo(0, 0)
}
}
function runViewportRecovery() {
clearBodyScrollLock()
resetAllScrollPositions()
kickViewportReflow()
}
function scheduleViewportRecovery() {
clearRecoveryTimers()
runViewportRecovery()
nextTick(() => {
requestAnimationFrame(() => {
runViewportRecovery()
for (const delay of [50, 150, 300, 500]) {
recoveryTimers.push(window.setTimeout(runViewportRecovery, delay))
}
})
})
}
/** Reset scroll offsets after navigation — fixes iOS safe-area drift. */
export function resetMobileAppScroll() {
runViewportRecovery()
nextTick(() => {
requestAnimationFrame(runViewportRecovery)
})
}
export async function dismissMobileKeyboard() {
blurFocusedField()
await new Promise((resolve) => window.setTimeout(resolve, 120))
}
export async function prepareMobileViewportForAppShell() {
blurFocusedField()
resetAllScrollPositions()
await dismissMobileKeyboard()
}
/** Full recovery after auth — runs after home shell is mounted. */
export function recoverMobileViewportAfterAuth() {
scheduleViewportRecovery()
}
export const resetMobileAppScrollAfterLogin = recoverMobileViewportAfterAuth
export async function completeLoginNavigation() {
await prepareMobileViewportForAppShell()
await router.push({ name: 'buyProduct' })
await router.isReady()
recoverMobileViewportAfterAuth()
}
export function initMobileScrollRestoration() {
if (typeof history !== 'undefined' && 'scrollRestoration' in history) {
history.scrollRestoration = 'manual'
}
}
@@ -0,0 +1 @@
export { useDesktopBreakpoint, useApplyDesktopLayoutClass } from './useAppLayout'
+53
View File
@@ -0,0 +1,53 @@
import type { AppNavItem } from '../types'
/** تب‌های پایین موبایل — کاربر لاگین‌شده */
export const AUTH_PRIMARY_NAV: AppNavItem[] = [
{ id: 'home', routeName: 'home', label: 'صفحه اصلی', icon: 'vuesax-linear:home' },
{ id: 'transactions', routeName: 'transactions', label: 'گزارش', icon: 'vuesax-linear:receipt-item' },
{ id: 'wallet', routeName: 'wallet', label: 'کیف پول', icon: 'vuesax-linear:wallet-1' },
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
]
/** تب‌های پایین موبایل — مهمان */
export const GUEST_PRIMARY_NAV: AppNavItem[] = [
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
{ id: 'about', routeName: 'about', label: 'درباره ما', icon: 'vuesax-linear:info-circle' },
{ id: 'cart', routeName: 'cart', label: 'سبد خرید', icon: 'vuesax-linear:shopping-cart' },
{ id: 'login', routeName: 'login', label: 'ورود', icon: 'vuesax-linear:login' },
]
export const RECOVERY_SITES_NAV_ITEM: AppNavItem = {
id: 'recoverySites',
routeName: 'recoverySites',
label: 'سایت‌های ری‌گیری',
icon: 'vuesax-linear:global',
}
/** منوی FAB موبایل + بخش فرعی سایدبار دسکتاپ — کاربر لاگین‌شده */
export const AUTH_SECONDARY_NAV: AppNavItem[] = [
{ id: 'notifyTrigger', routeName: 'notifyTrigger', label: 'هشدار قیمت', icon: 'vuesax-linear:bill' },
{ id: 'buyProduct', routeName: 'buyProduct', label: 'فروشگاه', icon: 'vuesax-linear:coin' },
{ id: 'fund', routeName: 'fund', label: 'دارایی ها', icon: 'vuesax-linear:archive-1' },
{ id: 'user', routeName: 'user', label: 'حساب کاربری', icon: 'vuesax-linear:user' },
{ id: 'physicalReceive', routeName: 'physicalReceive', label: 'دریافت طلای فیزیکی', icon: 'vuesax-linear:direct-inbox' },
{ id: 'list', routeName: 'list', label: 'لیست دریافتی‌ها', icon: 'vuesax-linear:receipt-item' },
{ id: 'giftCard', routeName: 'giftCard', label: 'ثبت کارت هدیه', icon: 'vuesax-linear:gift' },
{ id: 'earnMoney', routeName: 'earnMoney', label: 'کسب درآمد', icon: 'vuesax-linear:dollar-circle' },
{ id: 'about', routeName: 'about', label: 'درباره ما', icon: 'vuesax-linear:info-circle' },
{ id: 'rules', routeName: 'rules', label: 'قوانین و مقررات', icon: 'vuesax-linear:task' },
]
export function getPrimaryNavItems(isAuthenticated: boolean): AppNavItem[] {
return isAuthenticated ? AUTH_PRIMARY_NAV : GUEST_PRIMARY_NAV
}
export function getSecondaryNavItems(
isAuthenticated: boolean,
options?: { includeRecoverySites?: boolean },
): AppNavItem[] {
if (!isAuthenticated) return []
if (options?.includeRecoverySites) {
return [...AUTH_SECONDARY_NAV, RECOVERY_SITES_NAV_ITEM]
}
return AUTH_SECONDARY_NAV
}
+4
View File
@@ -0,0 +1,4 @@
/** Minimum viewport width for desktop app shell (sidebar layout). */
export const DESKTOP_LAYOUT_MIN_WIDTH = 768
export const DESKTOP_SIDEBAR_WIDTH = 260
+38
View File
@@ -0,0 +1,38 @@
<template>
<div class="desktop-app-layout">
<DesktopSidebar v-if="!hideMenu" />
<main
class="desktop-app-layout__main"
:class="{ 'desktop-app-layout__main--full': hideMenu }"
>
<router-view v-slot="{ Component, route }">
<div :key="route.fullPath" class="desktop-app-layout__content">
<component :is="Component" />
</div>
</router-view>
</main>
</div>
</template>
<script lang="ts" setup>
import { onUnmounted, watch } from 'vue'
import { useAppNavigation } from '../composables/useAppNavigation'
import DesktopSidebar from './DesktopSidebar.vue'
const NO_SIDEBAR_CLASS = 'app-layout--desktop-no-sidebar'
const { hideMenu } = useAppNavigation()
watch(
hideMenu,
(hidden) => {
document.documentElement.classList.toggle(NO_SIDEBAR_CLASS, hidden)
},
{ immediate: true }
)
onUnmounted(() => {
document.documentElement.classList.remove(NO_SIDEBAR_CLASS)
})
</script>
<style lang="less" src="./desktop-layout.less"></style>
+65
View File
@@ -0,0 +1,65 @@
<template>
<button
type="button"
class="desktop-nav-item"
:class="{ 'desktop-nav-item--active': active }"
@click="$emit('click')"
>
<span class="desktop-nav-item__icon-wrap">
<img
v-if="iconSrc"
:src="iconSrc"
alt=""
class="desktop-nav-item__icon desktop-nav-item__icon--image"
/>
<BasicIcon v-else :icon="icon" size="20" class="desktop-nav-item__icon" />
<span v-if="badgeCount && badgeCount > 0" class="desktop-nav-item__badge">{{ badgeCount }}</span>
</span>
<span class="desktop-nav-item__label">{{ label }}</span>
</button>
</template>
<script lang="ts" setup>
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
defineProps<{
icon: string
iconSrc?: string
label: string
active: boolean
badgeCount?: number
}>()
defineEmits<{
click: []
}>()
</script>
<style scoped>
.desktop-nav-item__icon-wrap {
position: relative;
}
.desktop-nav-item__badge {
position: absolute;
top: -4px;
left: -4px;
min-width: 18px;
height: 18px;
padding: 0 4px;
border-radius: 999px;
background: #a72b77;
color: #fff;
font-size: 10px;
font-weight: 700;
line-height: 18px;
text-align: center;
}
.desktop-nav-item__icon--image {
width: 32px;
height: 32px;
object-fit: contain;
transform: scale(1.75);
}
</style>
+76
View File
@@ -0,0 +1,76 @@
<template>
<aside class="desktop-sidebar">
<div class="desktop-sidebar__brand">
<img :src="navLogo" alt="کشکول گلد" class="desktop-sidebar__logo" />
</div>
<nav class="desktop-sidebar__section" aria-label="منوی اصلی">
<DesktopNavItem
v-for="item in primaryItems"
:key="item.id"
:icon="item.icon"
:icon-src="item.iconSrc"
:label="item.label"
:active="isNavActive(item.routeName)"
:badge-count="item.routeName === 'cart' && cartCount ? cartCount : undefined"
@click="navigateTo(item.routeName)"
/>
</nav>
<div v-if="secondaryItems.length" class="desktop-sidebar__divider" />
<nav
v-if="secondaryItems.length"
class="desktop-sidebar__section desktop-sidebar__section--secondary"
aria-label="منوی فرعی"
>
<DesktopNavItem
v-for="item in secondaryItems"
:key="item.id"
:icon="item.icon"
:icon-src="item.iconSrc"
:label="item.label"
:active="isNavActive(item.routeName)"
@click="navigateTo(item.routeName)"
/>
</nav>
</aside>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import logoFull from '@/assets/img/logo_full_.png'
import { isToken } from '@/utils'
import { useCartStore } from '@/store/cartStore'
import { useTrackingSystemsFeature } from '@/composables/useTrackingSystemsFeature'
import { useSettingsStore } from '@/store/settingsStore'
import { getPrimaryNavItems, getSecondaryNavItems } from '../config/navigation'
import { useAppNavigation } from '../composables/useAppNavigation'
import DesktopNavItem from './DesktopNavItem.vue'
const cartStore = useCartStore()
const authenticated = computed(() => isToken())
const navLogo = logoFull
const { trackingSystemsEnabled } = useTrackingSystemsFeature()
const settingsStore = useSettingsStore()
const primaryItems = computed(() => getPrimaryNavItems(authenticated.value))
/** «لیست دریافتی‌ها» فقط در موبایل نمایش داده می‌شود */
const DESKTOP_HIDDEN_NAV_IDS = ['list']
const secondaryItems = computed(() =>
getSecondaryNavItems(authenticated.value, {
includeRecoverySites: trackingSystemsEnabled.value,
}).filter((item) => {
if (DESKTOP_HIDDEN_NAV_IDS.includes(item.id)) return false
if (item.id === 'notifyTrigger') {
return settingsStore.isSettingTruthy('has_page_price_trigger')
}
if (item.id === 'giftCard') {
return settingsStore.isSettingTruthy('has_page_gift_card')
}
return true
}),
)
const cartCount = computed(() => cartStore.itemCount || 0)
const { isNavActive, navigateTo } = useAppNavigation()
</script>
+151
View File
@@ -0,0 +1,151 @@
.desktop-app-layout {
display: flex;
flex-direction: row;
height: 100vh;
max-height: 100vh;
width: 100%;
max-width: 100vw;
background: @prefixCls-background-color;
overflow: hidden;
}
.desktop-app-layout__main {
flex: 1;
min-width: 0;
min-height: 0;
height: 100%;
max-height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
margin-right: var(--app-desktop-sidebar-width, 260px);
}
.desktop-app-layout__main--full {
width: 100%;
margin-right: 0;
}
.desktop-app-layout__content {
flex: 1 1 0;
min-height: 0;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
overscroll-behavior: contain;
-webkit-overflow-scrolling: touch;
background: @prefixCls-background-color;
}
.desktop-sidebar {
position: fixed;
top: 0;
right: 0;
bottom: 0;
width: var(--app-desktop-sidebar-width, 260px);
height: 100vh;
display: flex;
flex-direction: column;
background: #fff;
z-index: 100;
padding: 20px 12px 16px;
box-sizing: border-box;
border-left: 1px solid rgba(0, 0, 0, 0.06);
overflow: hidden;
overscroll-behavior: contain;
}
.desktop-sidebar__brand {
display: flex;
align-items: center;
justify-content: center;
padding: 8px 12px 20px;
margin-bottom: 4px;
}
.desktop-sidebar__logo {
max-width: 140px;
max-height: 56px;
width: auto;
height: auto;
object-fit: contain;
}
.desktop-sidebar__section {
display: flex;
flex-direction: column;
gap: 4px;
}
.desktop-sidebar__section--secondary {
margin-top: auto;
flex: 1;
min-height: 0;
overflow-y: auto;
overscroll-behavior: contain;
}
.desktop-sidebar__divider {
height: 1px;
background: rgba(0, 0, 0, 0.08);
margin: 12px 8px;
}
.desktop-nav-item {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
padding: 10px 12px;
border: none;
border-radius: 10px;
background: transparent;
cursor: pointer;
text-align: right;
font-family: inherit;
font-size: 14px;
font-weight: 600;
color: #6b7280;
transition: background 0.15s ease, color 0.15s ease;
&:hover {
background: rgba(167, 43, 119, 0.06);
color: @primary-color;
}
&--active {
background: rgba(167, 43, 119, 0.1);
color: @primary-color;
.desktop-nav-item__icon {
color: @primary-color;
}
}
}
.desktop-nav-item__icon {
flex-shrink: 0;
color: #9ca3af;
}
.desktop-nav-item__icon-wrap {
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 12px;
background: transparent;
flex-shrink: 0;
}
.desktop-nav-item__label {
flex: 1;
line-height: 1.3;
}
.desktop-sidebar__section--secondary .desktop-nav-item {
font-size: 13px;
font-weight: 500;
padding: 8px 12px;
}
@@ -0,0 +1,255 @@
/* Shared desktop layouts for inner pages */
.dinner {
min-height: 100%;
background: #f6f7f9;
color: #111827;
}
.dinner__container {
max-width: 1180px;
margin: 0 auto;
padding: 28px 36px 40px;
box-sizing: border-box;
}
.dinner-surface {
background: #fff;
border: 1px solid rgba(15, 23, 42, 0.06);
border-radius: 16px;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
/* Cart */
.dcart-grid {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
gap: 20px;
align-items: start;
}
.dcart-items {
display: flex;
flex-direction: column;
gap: 12px;
}
.dcart-item {
display: flex;
gap: 16px;
padding: 16px;
border-radius: 14px;
background: #fff;
border: 1px solid rgba(15, 23, 42, 0.06);
&__image {
width: 88px;
height: 88px;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
background: #f9fafb;
border-radius: 12px;
padding: 8px;
}
&__main {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
justify-content: space-between;
gap: 8px;
}
&__title {
font-size: 14px;
font-weight: 600;
color: #111827;
line-height: 1.5;
}
&__meta {
font-size: 12px;
color: #6b7280;
}
&__footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
&__price {
font-size: 15px;
font-weight: 700;
color: @App-primary-color;
}
}
.dcart-summary {
position: sticky;
top: 88px;
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
&__title {
font-size: 16px;
font-weight: 700;
margin: 0;
}
&__row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
font-size: 14px;
}
&__total {
font-size: 20px;
font-weight: 700;
color: @App-primary-color;
}
}
/* Product detail */
.dproduct-grid {
display: grid;
grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
gap: 24px;
align-items: start;
}
.dproduct-gallery {
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
min-height: 280px;
background: #f9fafb;
border-radius: 16px;
}
.dproduct-info {
display: flex;
flex-direction: column;
gap: 16px;
}
.dproduct-info__price-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
}
.dproduct-info__price {
font-size: 22px;
font-weight: 700;
color: @App-primary-color;
}
.dproduct-info__desc {
padding: 20px;
font-size: 14px;
line-height: 1.8;
color: #4b5563;
white-space: pre-line;
}
/* Simple form pages (gift card, etc.) */
.dform-page {
max-width: 560px;
}
.dform-card {
padding: 24px;
}
/* Earn money */
.dearn-stats {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin: 16px 0;
}
.dearn-stat {
padding: 16px;
border-radius: 12px;
text-align: center;
&--blue {
background: #dbeafe;
color: #2563eb;
}
&--yellow {
background: #fef9c3;
color: #ca8a04;
}
&__value {
font-size: 18px;
font-weight: 700;
}
&__label {
font-size: 12px;
margin-top: 6px;
}
}
.dearn-list {
display: flex;
flex-direction: column;
gap: 10px;
margin-top: 16px;
}
.dearn-list-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 14px 16px;
border-radius: 12px;
background: #fff;
border: 1px solid rgba(15, 23, 42, 0.06);
}
/* Physical receive */
.dphysical-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.dphysical-add {
margin-top: 20px;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
width: 100%;
padding: 14px;
border: 1px dashed rgba(15, 23, 42, 0.15);
border-radius: 12px;
background: #fff;
font-family: inherit;
font-size: 14px;
font-weight: 600;
color: #374151;
cursor: pointer;
&:hover {
background: #f9fafb;
}
}
@@ -0,0 +1,165 @@
html.app-layout--desktop {
.dpage {
max-width: 1180px;
margin: 0 auto;
padding: 28px 36px 48px;
box-sizing: border-box;
}
.dpage-topbar {
display: flex;
align-items: flex-start;
gap: 16px;
margin-bottom: 24px;
padding-bottom: 24px;
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
&--sticky {
position: sticky;
top: 0;
z-index: 30;
margin: -4px 0 20px;
padding: 12px 0 20px;
background: #f6f7f9;
}
&__back {
display: inline-flex;
align-items: center;
gap: 8px;
border: none;
background: transparent;
color: #6b7280;
font-size: 13px;
font-weight: 500;
font-family: inherit;
cursor: pointer;
padding: 8px 0;
flex-shrink: 0;
&:hover {
color: #111827;
}
}
&__meta {
flex: 1;
min-width: 0;
}
&__eyebrow {
font-size: 12px;
font-weight: 500;
color: #9ca3af;
margin: 0 0 4px;
}
&__title {
font-size: 26px;
font-weight: 700;
letter-spacing: -0.03em;
color: #111827;
line-height: 1.2;
margin: 0;
}
&__subtitle {
font-size: 14px;
color: #6b7280;
margin: 6px 0 0;
line-height: 1.5;
}
}
/* Hide mobile fixed headers on desktop inner pages */
.fund-info-page-root,
.cart-page-root,
.gift-card-page-root,
.earn-money-page-root,
.physical-receive-page-root,
.product-detail-page-root,
.dinner-page,
.cart-page,
.gift-card-page,
.earn-money-page,
.physical-receive-page,
.product-detail-page,
.about-page-root,
.rules-page-root {
> .wrap-fix,
> div > .wrap-fix,
.transaction-list {
display: none !important;
}
}
.products-page .grid-cols-2 {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media screen and (min-width: 1100px) {
.products-page .grid-cols-2 {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
.dpage-surface {
background: #fff;
border: 1px solid rgba(15, 23, 42, 0.06);
border-radius: 16px;
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.dhome-topbar {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 24px;
margin-bottom: 28px;
padding-bottom: 24px;
border-bottom: 1px solid rgba(15, 23, 42, 0.06);
&__eyebrow {
font-size: 12px;
font-weight: 500;
color: #9ca3af;
margin: 0 0 4px;
}
&__title {
font-size: 26px;
font-weight: 600;
letter-spacing: -0.03em;
color: #111827;
line-height: 1.2;
margin: 0;
}
&__actions {
display: flex;
align-items: center;
gap: 8px;
}
}
.dhome-btn-ghost {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 8px 12px;
border: none;
border-radius: 8px;
background: transparent;
font-family: inherit;
font-size: 13px;
font-weight: 500;
color: #6b7280;
cursor: pointer;
transition: color 0.15s ease, background 0.15s ease;
&:hover {
color: #111827;
background: rgba(15, 23, 42, 0.04);
}
}
}
+61
View File
@@ -0,0 +1,61 @@
<template>
<div class="mobile-app-layout">
<MobileOverflowMenu
:show="popVisible"
@close="closeOverflowMenu"
@navigate="navigateTo"
/>
<div :class="['main-with-bottom-chrome', { 'main-with-bottom-chrome--no-nav': hideBottomNav }]">
<router-view v-slot="{ Component, route: activeRoute }">
<transition :name="activeRoute.meta.transition || 'fade'">
<component :is="Component" :key="activeRoute.fullPath" class="main-with-bottom-chrome-inner" />
</transition>
</router-view>
</div>
<Teleport to="body">
<MobileBottomNav
v-if="!hideBottomNav"
:nav-item-class="navItemClass"
@navigate="navigateTo"
@toggle-overflow="toggleOverflowMenu"
/>
</Teleport>
</div>
</template>
<script lang="ts" setup>
import { onMounted, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useAppNavigation } from '../composables/useAppNavigation'
import { recoverMobileViewportAfterAuth, resetMobileAppScroll } from '../composables/useMobileScrollReset'
import MobileBottomNav from './MobileBottomNav.vue'
import MobileOverflowMenu from './MobileOverflowMenu.vue'
const route = useRoute()
const {
popVisible,
hideBottomNav,
navItemClass,
navigateTo,
toggleOverflowMenu,
closeOverflowMenu,
} = useAppNavigation()
watch(
() => route.fullPath,
() => {
resetMobileAppScroll()
},
{ flush: 'post' },
)
onMounted(() => {
resetMobileAppScroll()
recoverMobileViewportAfterAuth()
})
</script>
<style lang="less" src="./mobile-layout.less"></style>
+83
View File
@@ -0,0 +1,83 @@
<template>
<div class="bottom-appbar w-auto mx-auto bg-white">
<div class="tabs bottom-0">
<template v-for="item in leftTabs" :key="item.id">
<div :class="navItemClass(item.routeName)" class="tab" @click="$emit('navigate', item.routeName)">
<div class="tab__icon">
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
<Icon :icon="item.icon" size="24" />
</a-badge>
<Icon v-else :icon="item.icon" size="24" />
</div>
<div class="text-xs mt-1 font-bold">{{ item.label }}</div>
</div>
</template>
<div class="main_in">
<div class="text-white circle_in">
<div class="circle_into" @click="$emit('toggle-overflow')">
<img class="p-2" :src="navLogo" alt="" />
</div>
</div>
</div>
<template v-for="item in rightTabs" :key="item.id">
<div :class="navItemClass(item.routeName)" class="tab" @click="$emit('navigate', item.routeName)">
<div class="tab__icon">
<a-badge v-if="item.routeName === 'cart'" :count="cartCount">
<Icon :icon="item.icon" size="24" />
</a-badge>
<Icon v-else :icon="item.icon" size="24" />
</div>
<div class="text-xs mt-1 font-bold">{{ item.label }}</div>
</div>
</template>
</div>
<div class="main">
<div class="circle" />
</div>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import Icon from '@/components/BasicPacks/BasicIcon.vue'
import { isToken } from '@/utils'
import { useCartStore } from '@/store/cartStore'
import { getPrimaryNavItems } from '../config/navigation'
import logo from '@/assets/img/logo.png'
defineProps<{
navItemClass: (routeName: string) => string
}>()
defineEmits<{
navigate: [routeName: string]
'toggle-overflow': []
}>()
const cartStore = useCartStore()
const navLogo = logo
const cartCount = computed(() => cartStore.itemCount || 0)
const primaryItems = computed(() => getPrimaryNavItems(isToken()))
const leftTabs = computed(() => primaryItems.value.slice(0, 2))
const rightTabs = computed(() => primaryItems.value.slice(2))
</script>
<style scoped>
.tab__icon {
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
flex-shrink: 0;
color: inherit;
}
.tab__icon :deep(.ant-badge) {
color: inherit;
}
</style>
+149
View File
@@ -0,0 +1,149 @@
<template>
<Transition>
<div
v-if="show"
class="top-0 bottom-0 bg-black wrap-fix z-5000 opacity-60"
@click="$emit('close')"
/>
</Transition>
<Transition name="slide-fade">
<div v-if="show" class="wrap-fix bottom-11vh z-5000 flex justify-center items-end">
<div class="relative flex flex-col items-center">
<div
class="flex items-center justify-center bg-white rounded-full w-[30px] h-[30px] mb-2"
@click="$emit('close')"
>
<BasicIcon icon="vuesax-linear:close-circle" />
</div>
<div class="flex flex-col items-center gap-2">
<BasicButton
icon-size="16"
class="!font-bold w-15rem"
@click="go('user')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:user" size="16" class="absolute right-2" />
<div>حساب کاربری</div>
</div>
</BasicButton>
<BasicButton
v-if="authenticated"
icon-size="16"
class="!font-bold w-15rem"
@click="go('physicalReceive')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:direct-inbox" size="16" class="absolute right-2" />
<div>دریافت طلای فیزیکی</div>
</div>
</BasicButton>
<BasicButton
v-if="authenticated && priceTriggerEnabled"
icon-size="16"
class="!font-bold w-15rem"
@click="go('notifyTrigger')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:bill" size="16" class="absolute right-2" />
<div>هشدار قیمت</div>
</div>
</BasicButton>
<BasicButton
v-if="authenticated"
icon-size="16"
class="!font-bold w-15rem"
@click="go('buyProduct')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:coin" size="16" class="absolute right-2" />
<div>خرید محصول</div>
</div>
</BasicButton>
<!-- <BasicButton-->
<!-- v-if="authenticated"-->
<!-- icon-size="16"-->
<!-- class="!font-bold w-15rem"-->
<!-- @click="go('list')"-->
<!-- >-->
<!-- <div class="flex gap-2 items-center">-->
<!-- <BasicIcon icon="vuesax-linear:receipt-item" size="16" class="absolute right-2" />-->
<!-- <div>لیست دریافتی ها</div>-->
<!-- </div>-->
<!-- </BasicButton>-->
<BasicButton
v-if="authenticated && giftCardEnabled"
icon-size="16"
class="!font-bold w-15rem"
@click="go('giftCard')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:gift" size="16" class="absolute right-2" />
<div>ثبت کارت هدیه</div>
</div>
</BasicButton>
<BasicButton icon-size="16" class="!font-bold w-15rem" @click="go('about')">
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:info-circle" size="16" class="absolute right-2" />
<div>درباره ما</div>
</div>
</BasicButton>
<BasicButton
v-if="authenticated && trackingSystemsEnabled"
icon-size="16"
class="!font-bold w-15rem"
@click="go('recoverySites')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:global" size="16" class="absolute right-2" />
<div>سایت‌های ری‌گیری</div>
</div>
</BasicButton>
<BasicButton
v-if="authenticated"
icon-size="16"
class="!font-bold w-15rem"
@click="go('rules')"
>
<div class="flex gap-2 items-center">
<BasicIcon icon="vuesax-linear:task" size="16" class="absolute right-2" />
<div>قوانین و مقررات</div>
</div>
</BasicButton>
</div>
</div>
</div>
</Transition>
</template>
<script lang="ts" setup>
import { computed } from 'vue'
import BasicButton from '@/components/BasicPacks/BasicButton.vue'
import BasicIcon from '@/components/BasicPacks/BasicIcon.vue'
import { useTrackingSystemsFeature } from '@/composables/useTrackingSystemsFeature'
import { useSettingsStore } from '@/store/settingsStore'
import { isToken } from '@/utils'
defineProps<{
show: boolean
}>()
const emit = defineEmits<{
close: []
navigate: [routeName: string]
}>()
const authenticated = computed(() => isToken())
const { trackingSystemsEnabled } = useTrackingSystemsFeature()
const settingsStore = useSettingsStore()
const priceTriggerEnabled = computed(() =>
settingsStore.isSettingTruthy('has_page_price_trigger'),
)
const giftCardEnabled = computed(() =>
settingsStore.isSettingTruthy('has_page_gift_card'),
)
function go(routeName: string) {
emit('navigate', routeName)
emit('close')
}
</script>
+169
View File
@@ -0,0 +1,169 @@
.bottom-appbar {
z-index: var(--app-z-nav, 5000);
position: fixed;
bottom: 0;
right: 0;
left: 0;
width: 100%;
max-width: 100vw;
height: calc(var(--app-nav-height, 80px) + var(--app-safe-bottom, env(safe-area-inset-bottom, 0px)));
padding-bottom: var(--app-safe-bottom, env(safe-area-inset-bottom, 0px));
box-sizing: border-box;
display: flex;
justify-content: space-evenly;
background: #fff;
@media screen and (min-width: 426px) {
width: 426px;
max-width: 426px;
left: 50%;
right: auto;
transform: translateX(-50%);
}
.tabs {
display: flex;
height: 100%;
width: 100%;
background: #fff;
justify-content: space-between;
position: absolute;
bottom: 0;
z-index: 400;
box-shadow: 0 -2px 4px -2px #0000001a;
.tab {
width: 80px;
text-align: center;
flex-flow: column;
display: flex;
align-items: center;
justify-content: center;
align-content: center;
&.text-primary .tab__icon,
&.text-primary .tab__icon .ant-badge {
color: @primary-color;
}
&.text-gray-400 .tab__icon,
&.text-gray-400 .tab__icon .ant-badge {
color: #9ca3af;
}
}
.main_in {
width: 70px;
height: 70px;
flex-shrink: 0;
align-self: center;
.circle_in {
margin-top: -10px;
border-radius: 50%;
width: 70px;
height: 70px;
flex-shrink: 0;
z-index: 20;
display: flex;
justify-content: center;
align-items: center;
background-color: #a72b77;
.circle_into {
overflow: hidden;
background-color: @primary-color;
border-radius: 50%;
width: 56px;
height: 56px;
flex-shrink: 0;
display: flex;
justify-content: center;
align-items: center;
border: white 1px solid;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
}
}
}
}
.main {
height: 70px;
width: 70px;
position: relative;
.circle {
border-radius: 50%;
height: 70px;
width: 70px;
z-index: 20;
box-shadow: 0 -5px 4px -2px #0000001a;
position: absolute;
}
}
}
.v-enter-active,
.v-leave-active {
transition: opacity 0.5s ease;
}
.v-enter-from,
.v-leave-to {
opacity: 0;
}
.slide-fade-enter-active {
transition: all 0.3s ease-out;
}
.slide-fade-leave-active {
transition: all 0.4s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter-from,
.slide-fade-leave-to {
transform: translateX(20px);
opacity: 0;
}
.mobile-app-layout {
height: 100%;
max-height: 100%;
overflow: hidden;
display: flex;
flex-direction: column;
}
.main-with-bottom-chrome {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column;
}
.main-with-bottom-chrome-inner {
flex: 1 1 auto;
min-height: 0;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
overscroll-behavior-y: contain;
}
.main-with-bottom-chrome-inner--contained {
overflow: hidden;
}
.main-with-bottom-chrome--no-nav,
.main-with-bottom-chrome--no-nav .main-with-bottom-chrome-inner {
flex: 1 1 auto;
min-height: 0;
}

Some files were not shown because too many files have changed in this diff Show More