@ozdao/martyrs 0.2.428 → 0.2.430
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/community.server.js +1 -1
- package/dist/community.server.mjs +1 -1
- package/dist/events.server.js +1 -1
- package/dist/events.server.mjs +1 -1
- package/dist/gallery.server.js +1 -1
- package/dist/gallery.server.mjs +1 -1
- package/dist/{globals.logger-Deb_8o7C.mjs → globals.cache-BT6q3vOf.mjs} +0 -33
- package/dist/{globals.logger-BuG0pN80.js → globals.cache-CwWvNGFQ.js} +0 -33
- package/dist/globals.logger-BdjooLaD.js +34 -0
- package/dist/globals.logger-DusiFsxN.mjs +35 -0
- package/dist/martyrs/src/modules/chats/components/pages/ChatPage.vue.cjs +13 -3
- package/dist/martyrs/src/modules/chats/components/pages/ChatPage.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/chats/components/pages/ChatPage.vue.js +14 -4
- package/dist/martyrs/src/modules/chats/components/pages/ChatPage.vue.js.map +1 -1
- package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.cjs +24 -6
- package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.js +25 -7
- package/dist/martyrs/src/modules/chats/components/sections/ChatWindow.vue.js.map +1 -1
- package/dist/martyrs/src/modules/chats/store/chat.store.cjs +7 -8
- package/dist/martyrs/src/modules/chats/store/chat.store.cjs.map +1 -1
- package/dist/martyrs/src/modules/chats/store/chat.store.js +7 -8
- package/dist/martyrs/src/modules/chats/store/chat.store.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs +6 -8
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js +6 -8
- package/dist/martyrs/src/modules/globals/views/classes/globals.websocket.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs +11 -8
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js +11 -8
- package/dist/martyrs/src/modules/globals/views/components/layouts/Client.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs +5 -5
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js +5 -5
- package/dist/martyrs/src/modules/globals/views/components/partials/Header.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs +17 -9
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js +17 -9
- package/dist/martyrs/src/modules/globals/views/components/partials/Navigation.vue.js.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Sidebar.vue.cjs +16 -4
- package/dist/martyrs/src/modules/globals/views/components/partials/Sidebar.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/globals/views/components/partials/Sidebar.vue.js +16 -4
- package/dist/martyrs/src/modules/globals/views/components/partials/Sidebar.vue.js.map +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js +1 -1
- package/dist/martyrs/src/modules/marketplace/views/components/sections/SectionMenu.vue.js.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.cjs +7 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.js +7 -1
- package/dist/martyrs/src/modules/notifications/components/elements/NotificationBadge.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderBackoffice.vue.cjs +112 -0
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderBackoffice.vue.cjs.map +1 -0
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderBackoffice.vue.js +112 -0
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderBackoffice.vue.js.map +1 -0
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.cjs +2 -2
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderItem.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.cjs +18 -12
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.js +18 -12
- package/dist/martyrs/src/modules/orders/components/blocks/CardOrderUser.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs +200 -92
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js +213 -105
- package/dist/martyrs/src/modules/orders/components/pages/OrderBackoffice.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs +9 -12
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js +10 -13
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreate.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs +14 -6
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js +23 -15
- package/dist/martyrs/src/modules/orders/components/pages/OrderCreateBackoffice.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.cjs +16 -99
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.js +16 -99
- package/dist/martyrs/src/modules/orders/components/pages/Orders.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.cjs +2 -2
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.js +2 -2
- package/dist/martyrs/src/modules/orders/components/partials/ShopCart.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs +99 -99
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js +102 -102
- package/dist/martyrs/src/modules/orders/components/sections/FormDelivery.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.cjs +14 -8
- package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.js +15 -9
- package/dist/martyrs/src/modules/orders/components/sections/FormPayment.vue.js.map +1 -1
- package/dist/martyrs/src/modules/orders/store/orders.cjs +51 -0
- package/dist/martyrs/src/modules/orders/store/orders.cjs.map +1 -1
- package/dist/martyrs/src/modules/orders/store/orders.js +51 -0
- package/dist/martyrs/src/modules/orders/store/orders.js.map +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs +59 -56
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js +63 -60
- package/dist/martyrs/src/modules/organizations/components/pages/Organization.vue.js.map +1 -1
- package/dist/martyrs/src/modules/organizations/store/organizations.cjs +0 -2
- package/dist/martyrs/src/modules/organizations/store/organizations.cjs.map +1 -1
- package/dist/martyrs/src/modules/organizations/store/organizations.js +1 -3
- package/dist/martyrs/src/modules/organizations/store/organizations.js.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs +4 -3
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js +5 -4
- package/dist/martyrs/src/modules/products/components/pages/Products.vue.js.map +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.cjs +15 -12
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.cjs.map +1 -1
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.js +15 -12
- package/dist/martyrs/src/modules/spots/components/blocks/CardSpot.vue.js.map +1 -1
- package/dist/martyrs/src/modules/spots/store/spots.cjs +2 -2
- package/dist/martyrs/src/modules/spots/store/spots.cjs.map +1 -1
- package/dist/martyrs/src/modules/spots/store/spots.js +2 -2
- package/dist/martyrs/src/modules/spots/store/spots.js.map +1 -1
- package/dist/martyrs.css +1 -1
- package/dist/orders.server.js +11 -4
- package/dist/orders.server.mjs +10 -3
- package/dist/organizations.server.js +33 -30
- package/dist/organizations.server.mjs +33 -30
- package/dist/products.server.js +1 -1
- package/dist/products.server.mjs +1 -1
- package/dist/{queryProcessor-CCmHM0yi.mjs → queryProcessor-CWnMIe2U.mjs} +4 -1
- package/dist/{queryProcessor-CwQakZkT.js → queryProcessor-D6GuKfTV.js} +4 -1
- package/dist/rents.server.js +4 -3
- package/dist/rents.server.mjs +3 -2
- package/dist/spots.server.js +41 -12
- package/dist/spots.server.mjs +41 -12
- package/dist/style.css +57 -65
- package/dist/wallet.server.js +1 -1
- package/dist/wallet.server.mjs +1 -1
- package/package.json +1 -1
- package/src/modules/chats/components/pages/ChatPage.vue +18 -23
- package/src/modules/chats/components/sections/ChatWindow.vue +55 -38
- package/src/modules/chats/store/chat.store.js +20 -21
- package/src/modules/globals/controllers/utils/queryProcessor.js +2 -1
- package/src/modules/globals/views/classes/globals.websocket.js +10 -11
- package/src/modules/globals/views/components/layouts/Client.vue +21 -15
- package/src/modules/globals/views/components/partials/Header.vue +3 -4
- package/src/modules/globals/views/components/partials/Navigation.vue +17 -19
- package/src/modules/globals/views/components/partials/Sidebar.vue +20 -9
- package/src/modules/marketplace/views/components/sections/SectionMenu.vue +1 -1
- package/src/modules/notifications/components/elements/NotificationBadge.vue +7 -0
- package/src/modules/orders/components/blocks/CardOrderBackoffice.vue +106 -0
- package/src/modules/orders/components/blocks/CardOrderItem.vue +2 -2
- package/src/modules/orders/components/blocks/CardOrderUser.vue +16 -9
- package/src/modules/orders/components/pages/OrderBackoffice.vue +146 -77
- package/src/modules/orders/components/pages/OrderCreate.vue +7 -12
- package/src/modules/orders/components/pages/OrderCreateBackoffice.vue +15 -3
- package/src/modules/orders/components/pages/Orders.vue +10 -93
- package/src/modules/orders/components/partials/ShopCart.vue +2 -2
- package/src/modules/orders/components/sections/FormDelivery.vue +35 -43
- package/src/modules/orders/components/sections/FormPayment.vue +17 -7
- package/src/modules/orders/controllers/orders.controller.js +12 -1
- package/src/modules/orders/store/orders.js +65 -0
- package/src/modules/organizations/components/pages/Organization.vue +48 -47
- package/src/modules/organizations/controllers/organizations.controller.js +57 -47
- package/src/modules/organizations/store/organizations.js +6 -6
- package/src/modules/products/components/pages/Products.vue +4 -3
- package/src/modules/spots/components/blocks/CardSpot.vue +8 -7
- package/src/modules/spots/controllers/spots.controller.js +47 -14
- package/src/modules/spots/routes/spots.routes.js +2 -3
- package/src/modules/spots/store/spots.js +4 -4
- package/src/styles/base/shadow_transitions_hover_refactor.scss +1 -0
- package/src/modules/landing/components/sections/HowToBuyWDR.vue +0 -130
- package/src/modules/landing/components/sections/WhatIsWDRSection.vue +0 -116
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.websocket.cjs","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["/**\n * Global WebSocket handler for centralized WebSocket connections\n * @martyrs/src/modules/globals/views/classes/globals.websocket.js\n */\nclass GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000; // 30 seconds\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n }\n\n /**\n * Initialize WebSocket with configuration options\n * @param {Object} options - Configuration options\n */\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n }\n\n /**\n * Get default WebSocket URL based on current HTTP URL\n * @returns {String} WebSocket URL\n */\n _getDefaultWsUrl() {\n // Check if window exists (for SSR compatibility)\n if (typeof window === 'undefined') {\n return '/api/ws'; // Default fallback for SSR\n }\n \n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n /**\n * Connect to WebSocket server\n * @param {String} userId - User ID for authentication\n * @returns {Promise} Promise that resolves when connection is established\n */\n connect(userId) {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return Promise.resolve(false);\n }\n\n // If already connected with the same user, just return the existing connection\n if (this.isConnected && this.userId === userId && this.socket) {\n return Promise.resolve(this.socket);\n }\n\n this.userId = userId;\n\n // If there's already a connection attempt in progress, return that promise\n if (this.connectPromise) {\n return this.connectPromise;\n }\n\n // Create new connection promise\n this.connectPromise = new Promise((resolve, reject) => {\n // Close existing connection if any\n this.disconnect();\n\n // Create new WebSocket connection with user ID\n const wsUrl = userId ? `${this.baseUrl}?userId=${userId}` : this.baseUrl;\n this.socket = new WebSocket(wsUrl);\n\n // Setup event handlers\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n \n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (error) => {\n this._handleError(error);\n reject(error);\n };\n \n this.socket.onclose = this._handleClose.bind(this);\n\n // Timeout for connection\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n /**\n * Disconnect from WebSocket server\n */\n disconnect() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.socket) {\n // Remove event listeners\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n \n // Close connection\n if (this.socket.readyState === WebSocket.OPEN || \n this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n \n this.socket = null;\n }\n\n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this.isConnected = false;\n this.userId = null;\n }\n\n /**\n * Send data through WebSocket\n * @param {Object|String} data - Data to send\n * @returns {Boolean} Success status\n */\n send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const message = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(message);\n return true;\n } catch (error) {\n console.error('Error sending WebSocket message:', error);\n return false;\n }\n }\n\n /**\n * Register an event listener\n * @param {String} eventType - Event type to listen for\n * @param {Function} callback - Callback function\n * @param {Object} options - Additional options like module name for namespacing\n * @returns {String} Listener ID for unregistering\n */\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n \n if (!this.listeners[eventType]) {\n this.listeners[eventType] = {};\n }\n \n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n /**\n * Remove an event listener\n * @param {String} eventType - Event type\n * @param {String} listenerId - Listener ID returned from addEventListener\n */\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType] && this.listeners[eventType][listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n /**\n * Remove all listeners for a module\n * @param {String} moduleName - Module name to remove listeners for\n */\n removeModuleListeners(moduleName) {\n if (!moduleName) return;\n \n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n /**\n * Handle WebSocket open event\n */\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n \n // Setup ping interval to keep connection alive\n this.pingInterval = setInterval(() => {\n if (this.socket && this.socket.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n // Notify listeners\n this._notifyListeners('open', { isConnected: true });\n }\n\n /**\n * Handle WebSocket message event\n * @param {Event} event - WebSocket message event\n */\n _handleMessage(event) {\n try {\n const data = JSON.parse(event.data);\n \n // Generic event notifications\n this._notifyListeners('message', data);\n \n // Specific event type notifications\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n \n } catch (error) {\n console.error('Error processing WebSocket message:', error);\n }\n }\n\n /**\n * Handle WebSocket error\n * @param {Error} error - WebSocket error\n */\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n }\n\n /**\n * Handle WebSocket close event\n * @param {Event} event - WebSocket close event\n */\n _handleClose(event) {\n this.isConnected = false;\n \n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n \n this._notifyListeners('close', { code: event.code, reason: event.reason });\n \n // Attempt to reconnect if not a normal closure and we have a userId\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n \n setTimeout(() => {\n if (this.userId) {\n this.connect(this.userId).catch(error => {\n console.error('Reconnection failed:', error);\n });\n }\n }, delay);\n }\n }\n\n /**\n * Notify event listeners\n * @param {String} eventType - Event type\n * @param {Object} data - Event data\n */\n _notifyListeners(eventType, data) {\n if (!this.listeners[eventType]) return;\n \n Object.values(this.listeners[eventType]).forEach(callback => {\n try {\n callback(data);\n } catch (error) {\n console.error(`Error in WebSocket ${eventType} listener:`, error);\n }\n });\n }\n\n /**\n * Get connection status\n * @returns {Boolean} Connection status\n */\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\n// Create singleton instance\nconst globalWebSocket = new GlobalWebSocket();\n\nexport default globalWebSocket;"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,WAAW,UAAU,IAAI;AACvB,SAAK,uBAAuB,QAAQ,wBAAwB,KAAK;AACjE,SAAK,iBAAiB,QAAQ,kBAAkB,KAAK;AACrD,SAAK,UAAU,QAAQ,SAAS,KAAK,iBAAkB;AACvD,SAAK,mBAAmB,QAAQ,gBAAgB,KAAK;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,mBAAmB;AAEjB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACb;AAEI,UAAM,WAAW,OAAO,SAAS,aAAa,WAAW,SAAS;AAClE,UAAM,OAAO,OAAO,SAAS;AAC7B,WAAO,GAAG,QAAQ,KAAK,IAAI;AAAA,E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AS,EAAE,MAAM,MAAM,MAAM,QAAQ,MAAM,QAAQ;AAGzE,QAAI,MAAM,SAAS,OAAQ,KAAK,UAAU,KAAK,oBAAoB,KAAK,sBAAsB;AAC5F,WAAK;AACL,YAAM,QAAQ,KAAK,iBAAiB,KAAK;AAEzC,iBAAW,MAAM;AACf,YAAI,KAAK,QAAQ;AACf,eAAK,QAAQ,KAAK,MAAM,EAAE,MAAM,WAAS;AACvC,oBAAQ,MAAM,wBAAwB,KAAK;AAAA,UACvD,CAAW;AAAA,QACX;AAAA,MACO,GAAE,KAAK;AAAA,IACd;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOE,iBAAiB,WAAW,MAAM;AAChC,QAAI,CAAC,KAAK,UAAU,SAAS,EAAG;AAEhC,WAAO,OAAO,KAAK,UAAU,SAAS,CAAC,EAAE,QAAQ,cAAY;AAC3D,UAAI;AACF,iBAAS,IAAI;AAAA,MACd,SAAQ,OAAO;AACd,gBAAQ,MAAM,sBAAsB,SAAS,cAAc,KAAK;AAAA,MACxE;AAAA,IACA,CAAK;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,oBAAoB;;AAClB,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAGK,MAAC,kBAAkB,IAAI,gBAAe;;"}
|
|
1
|
+
{"version":3,"file":"globals.websocket.cjs","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["/**\n * Global WebSocket handler for centralized WebSocket connections\n * @martyrs/src/modules/globals/views/classes/globals.websocket.js\n */\nclass GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000; // 30 seconds\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n }\n\n /**\n * Initialize WebSocket with configuration options\n * @param {Object} options - Configuration options\n */\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n }\n\n /**\n * Get default WebSocket URL based on current HTTP URL\n * @returns {String} WebSocket URL\n */\n _getDefaultWsUrl() {\n // Check if window exists (for SSR compatibility)\n if (typeof window === 'undefined') {\n return '/api/ws'; // Default fallback for SSR\n }\n \n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n /**\n * Connect to WebSocket server\n * @param {String} userId - User ID for authentication\n * @returns {Promise} Promise that resolves when connection is established\n */\n connect(userId) {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return Promise.resolve(false);\n }\n\n // Always update userId before any connection logic\n this.userId = userId;\n\n // If already connected with the same user and socket is valid, return the existing connection\n if (this.isConnected && this.socket && this.socket.readyState === WebSocket.OPEN) {\n return Promise.resolve(this.socket);\n }\n\n // Clear any existing connection promise to avoid conflicts\n this.connectPromise = null;\n\n // Create new connection promise\n this.connectPromise = new Promise((resolve, reject) => {\n // Close existing connection if any\n this.disconnect();\n\n // Create new WebSocket connection with user ID\n const wsUrl = userId ? `${this.baseUrl}?userId=${encodeURIComponent(userId)}` : this.baseUrl;\n this.socket = new WebSocket(wsUrl);\n\n // Setup event handlers\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n \n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (error) => {\n this._handleError(error);\n reject(error);\n };\n \n this.socket.onclose = this._handleClose.bind(this);\n\n // Timeout for connection\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n /**\n * Disconnect from WebSocket server\n */\n disconnect() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.socket) {\n // Remove event listeners\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n \n // Close connection\n if (this.socket.readyState === WebSocket.OPEN || \n this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n \n this.socket = null;\n }\n\n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this.isConnected = false;\n this.userId = null;\n }\n\n /**\n * Send data through WebSocket\n * @param {Object|String} data - Data to send\n * @returns {Boolean} Success status\n */\n async send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const message = typeof data === 'string' ? data : JSON.stringify(data);\n await this.socket.send(message);\n return true;\n } catch (error) {\n console.error('Error sending WebSocket message:', error);\n return false;\n }\n }\n\n /**\n * Register an event listener\n * @param {String} eventType - Event type to listen for\n * @param {Function} callback - Callback function\n * @param {Object} options - Additional options like module name for namespacing\n * @returns {String} Listener ID for unregistering\n */\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n \n if (!this.listeners[eventType]) {\n this.listeners[eventType] = {};\n }\n \n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n /**\n * Remove an event listener\n * @param {String} eventType - Event type\n * @param {String} listenerId - Listener ID returned from addEventListener\n */\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType] && this.listeners[eventType][listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n /**\n * Remove all listeners for a module\n * @param {String} moduleName - Module name to remove listeners for\n */\n removeModuleListeners(moduleName) {\n if (!moduleName) return;\n \n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n /**\n * Handle WebSocket open event\n */\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n \n // Setup ping interval to keep connection alive\n this.pingInterval = setInterval(() => {\n if (this.socket && this.socket.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n // Notify listeners\n this._notifyListeners('open', { isConnected: true });\n }\n\n /**\n * Handle WebSocket message event\n * @param {Event} event - WebSocket message event\n */\n _handleMessage(event) {\n try {\n const data = JSON.parse(event.data);\n \n // Generic event notifications\n this._notifyListeners('message', data);\n \n // Specific event type notifications\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n \n } catch (error) {\n console.error('Error processing WebSocket message:', error);\n }\n }\n\n /**\n * Handle WebSocket error\n * @param {Error} error - WebSocket error\n */\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n }\n\n /**\n * Handle WebSocket close event\n * @param {Event} event - WebSocket close event\n */\n _handleClose(event) {\n this.isConnected = false;\n \n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n \n this._notifyListeners('close', { code: event.code, reason: event.reason });\n \n // Attempt to reconnect if not a normal closure and we have a userId\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n \n setTimeout(() => {\n if (this.userId) {\n this.connect(this.userId).catch(error => {\n console.error('Reconnection failed:', error);\n });\n }\n }, delay);\n }\n }\n\n /**\n * Notify event listeners\n * @param {String} eventType - Event type\n * @param {Object} data - Event data\n */\n _notifyListeners(eventType, data) {\n if (!this.listeners[eventType]) return;\n \n Object.values(this.listeners[eventType]).forEach(callback => {\n try {\n callback(data);\n } catch (error) {\n console.error(`Error in WebSocket ${eventType} listener:`, error);\n }\n });\n }\n\n /**\n * Get connection status\n * @returns {Boolean} Connection status\n */\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\n// Create singleton instance\nconst globalWebSocket = new GlobalWebSocket();\n\nexport default globalWebSocket;"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,WAAW,UAAU,IAAI;AACvB,SAAK,uBAAuB,QAAQ,wBAAwB,KAAK;AACjE,SAAK,iBAAiB,QAAQ,kBAAkB,KAAK;AACrD,SAAK,UAAU,QAAQ,SAAS,KAAK,iBAAkB;AACvD,SAAK,mBAAmB,QAAQ,gBAAgB,KAAK;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,mBAAmB;AAEjB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACb;AAEI,UAAM,WAAW,OAAO,SAAS,aAAa,WAAW,SAAS;AAClE,UAAM,OAAO,OAAO,SAAS;AAC7B,WAAO,GAAG,QAAQ,KAAK,IAAI;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOE,QAAQ,QAAQ;AAEd,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO,QAAQ,QAAQ,KAAK;AAAA,IAClC;AAGI,SAAK,SAAS;AAGd,QAAI,KAAK,eAAe,KAAK,UAAU,KAAK,OAAO,eAAe,UAAU,MAAM;AAChF,aAAO,QAAQ,QAAQ,KAAK,MAAM;AAAA,IACxC;AAGI,SAAK,iBAAiB;AAGtB,SAAK,iBAAiB,IAAI,QAAQ,CAAC,SAAS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MACO,GAAE,KAAK;AAAA,IACd;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOE,iBAAiB,WAAW,MAAM;AAChC,QAAI,CAAC,KAAK,UAAU,SAAS,EAAG;AAEhC,WAAO,OAAO,KAAK,UAAU,SAAS,CAAC,EAAE,QAAQ,cAAY;AAC3D,UAAI;AACF,iBAAS,IAAI;AAAA,MACd,SAAQ,OAAO;AACd,gBAAQ,MAAM,sBAAsB,SAAS,cAAc,KAAK;AAAA,MACxE;AAAA,IACA,CAAK;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,oBAAoB;;AAClB,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAGK,MAAC,kBAAkB,IAAI,gBAAe;;"}
|
|
@@ -43,16 +43,14 @@ class GlobalWebSocket {
|
|
|
43
43
|
if (typeof window === "undefined") {
|
|
44
44
|
return Promise.resolve(false);
|
|
45
45
|
}
|
|
46
|
-
if (this.isConnected && this.userId === userId && this.socket) {
|
|
47
|
-
return Promise.resolve(this.socket);
|
|
48
|
-
}
|
|
49
46
|
this.userId = userId;
|
|
50
|
-
if (this.
|
|
51
|
-
return this.
|
|
47
|
+
if (this.isConnected && this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
48
|
+
return Promise.resolve(this.socket);
|
|
52
49
|
}
|
|
50
|
+
this.connectPromise = null;
|
|
53
51
|
this.connectPromise = new Promise((resolve, reject) => {
|
|
54
52
|
this.disconnect();
|
|
55
|
-
const wsUrl = userId ? `${this.baseUrl}?userId=${userId}` : this.baseUrl;
|
|
53
|
+
const wsUrl = userId ? `${this.baseUrl}?userId=${encodeURIComponent(userId)}` : this.baseUrl;
|
|
56
54
|
this.socket = new WebSocket(wsUrl);
|
|
57
55
|
this.socket.onopen = () => {
|
|
58
56
|
this._handleOpen();
|
|
@@ -103,14 +101,14 @@ class GlobalWebSocket {
|
|
|
103
101
|
* @param {Object|String} data - Data to send
|
|
104
102
|
* @returns {Boolean} Success status
|
|
105
103
|
*/
|
|
106
|
-
send(data) {
|
|
104
|
+
async send(data) {
|
|
107
105
|
if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
|
|
108
106
|
console.error("Cannot send message: WebSocket is not connected");
|
|
109
107
|
return false;
|
|
110
108
|
}
|
|
111
109
|
try {
|
|
112
110
|
const message = typeof data === "string" ? data : JSON.stringify(data);
|
|
113
|
-
this.socket.send(message);
|
|
111
|
+
await this.socket.send(message);
|
|
114
112
|
return true;
|
|
115
113
|
} catch (error) {
|
|
116
114
|
console.error("Error sending WebSocket message:", error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.websocket.js","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["/**\n * Global WebSocket handler for centralized WebSocket connections\n * @martyrs/src/modules/globals/views/classes/globals.websocket.js\n */\nclass GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000; // 30 seconds\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n }\n\n /**\n * Initialize WebSocket with configuration options\n * @param {Object} options - Configuration options\n */\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n }\n\n /**\n * Get default WebSocket URL based on current HTTP URL\n * @returns {String} WebSocket URL\n */\n _getDefaultWsUrl() {\n // Check if window exists (for SSR compatibility)\n if (typeof window === 'undefined') {\n return '/api/ws'; // Default fallback for SSR\n }\n \n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n /**\n * Connect to WebSocket server\n * @param {String} userId - User ID for authentication\n * @returns {Promise} Promise that resolves when connection is established\n */\n connect(userId) {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return Promise.resolve(false);\n }\n\n // If already connected with the same user, just return the existing connection\n if (this.isConnected && this.userId === userId && this.socket) {\n return Promise.resolve(this.socket);\n }\n\n this.userId = userId;\n\n // If there's already a connection attempt in progress, return that promise\n if (this.connectPromise) {\n return this.connectPromise;\n }\n\n // Create new connection promise\n this.connectPromise = new Promise((resolve, reject) => {\n // Close existing connection if any\n this.disconnect();\n\n // Create new WebSocket connection with user ID\n const wsUrl = userId ? `${this.baseUrl}?userId=${userId}` : this.baseUrl;\n this.socket = new WebSocket(wsUrl);\n\n // Setup event handlers\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n \n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (error) => {\n this._handleError(error);\n reject(error);\n };\n \n this.socket.onclose = this._handleClose.bind(this);\n\n // Timeout for connection\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n /**\n * Disconnect from WebSocket server\n */\n disconnect() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.socket) {\n // Remove event listeners\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n \n // Close connection\n if (this.socket.readyState === WebSocket.OPEN || \n this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n \n this.socket = null;\n }\n\n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this.isConnected = false;\n this.userId = null;\n }\n\n /**\n * Send data through WebSocket\n * @param {Object|String} data - Data to send\n * @returns {Boolean} Success status\n */\n send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const message = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(message);\n return true;\n } catch (error) {\n console.error('Error sending WebSocket message:', error);\n return false;\n }\n }\n\n /**\n * Register an event listener\n * @param {String} eventType - Event type to listen for\n * @param {Function} callback - Callback function\n * @param {Object} options - Additional options like module name for namespacing\n * @returns {String} Listener ID for unregistering\n */\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n \n if (!this.listeners[eventType]) {\n this.listeners[eventType] = {};\n }\n \n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n /**\n * Remove an event listener\n * @param {String} eventType - Event type\n * @param {String} listenerId - Listener ID returned from addEventListener\n */\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType] && this.listeners[eventType][listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n /**\n * Remove all listeners for a module\n * @param {String} moduleName - Module name to remove listeners for\n */\n removeModuleListeners(moduleName) {\n if (!moduleName) return;\n \n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n /**\n * Handle WebSocket open event\n */\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n \n // Setup ping interval to keep connection alive\n this.pingInterval = setInterval(() => {\n if (this.socket && this.socket.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n // Notify listeners\n this._notifyListeners('open', { isConnected: true });\n }\n\n /**\n * Handle WebSocket message event\n * @param {Event} event - WebSocket message event\n */\n _handleMessage(event) {\n try {\n const data = JSON.parse(event.data);\n \n // Generic event notifications\n this._notifyListeners('message', data);\n \n // Specific event type notifications\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n \n } catch (error) {\n console.error('Error processing WebSocket message:', error);\n }\n }\n\n /**\n * Handle WebSocket error\n * @param {Error} error - WebSocket error\n */\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n }\n\n /**\n * Handle WebSocket close event\n * @param {Event} event - WebSocket close event\n */\n _handleClose(event) {\n this.isConnected = false;\n \n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n \n this._notifyListeners('close', { code: event.code, reason: event.reason });\n \n // Attempt to reconnect if not a normal closure and we have a userId\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n \n setTimeout(() => {\n if (this.userId) {\n this.connect(this.userId).catch(error => {\n console.error('Reconnection failed:', error);\n });\n }\n }, delay);\n }\n }\n\n /**\n * Notify event listeners\n * @param {String} eventType - Event type\n * @param {Object} data - Event data\n */\n _notifyListeners(eventType, data) {\n if (!this.listeners[eventType]) return;\n \n Object.values(this.listeners[eventType]).forEach(callback => {\n try {\n callback(data);\n } catch (error) {\n console.error(`Error in WebSocket ${eventType} listener:`, error);\n }\n });\n }\n\n /**\n * Get connection status\n * @returns {Boolean} Connection status\n */\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\n// Create singleton instance\nconst globalWebSocket = new GlobalWebSocket();\n\nexport default globalWebSocket;"],"names":[],"mappings":"AAIA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EA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ACA;AAGK,MAAC,kBAAkB,IAAI,gBAAe;"}
|
|
1
|
+
{"version":3,"file":"globals.websocket.js","sources":["../../../../../../../src/modules/globals/views/classes/globals.websocket.js"],"sourcesContent":["/**\n * Global WebSocket handler for centralized WebSocket connections\n * @martyrs/src/modules/globals/views/classes/globals.websocket.js\n */\nclass GlobalWebSocket {\n constructor() {\n this.socket = null;\n this.isConnected = false;\n this.reconnectAttempts = 0;\n this.maxReconnectAttempts = 5;\n this.reconnectDelay = 3000;\n this.baseUrl = null;\n this.pingInterval = null;\n this.pingIntervalTime = 30000; // 30 seconds\n this.listeners = {};\n this.userId = null;\n this.connectPromise = null;\n }\n\n /**\n * Initialize WebSocket with configuration options\n * @param {Object} options - Configuration options\n */\n initialize(options = {}) {\n this.maxReconnectAttempts = options.maxReconnectAttempts || this.maxReconnectAttempts;\n this.reconnectDelay = options.reconnectDelay || this.reconnectDelay;\n this.baseUrl = options.wsUrl || this._getDefaultWsUrl();\n this.pingIntervalTime = options.pingInterval || this.pingIntervalTime;\n }\n\n /**\n * Get default WebSocket URL based on current HTTP URL\n * @returns {String} WebSocket URL\n */\n _getDefaultWsUrl() {\n // Check if window exists (for SSR compatibility)\n if (typeof window === 'undefined') {\n return '/api/ws'; // Default fallback for SSR\n }\n \n const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';\n const host = window.location.host;\n return `${protocol}//${host}/api/ws`;\n }\n\n /**\n * Connect to WebSocket server\n * @param {String} userId - User ID for authentication\n * @returns {Promise} Promise that resolves when connection is established\n */\n connect(userId) {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return Promise.resolve(false);\n }\n\n // Always update userId before any connection logic\n this.userId = userId;\n\n // If already connected with the same user and socket is valid, return the existing connection\n if (this.isConnected && this.socket && this.socket.readyState === WebSocket.OPEN) {\n return Promise.resolve(this.socket);\n }\n\n // Clear any existing connection promise to avoid conflicts\n this.connectPromise = null;\n\n // Create new connection promise\n this.connectPromise = new Promise((resolve, reject) => {\n // Close existing connection if any\n this.disconnect();\n\n // Create new WebSocket connection with user ID\n const wsUrl = userId ? `${this.baseUrl}?userId=${encodeURIComponent(userId)}` : this.baseUrl;\n this.socket = new WebSocket(wsUrl);\n\n // Setup event handlers\n this.socket.onopen = () => {\n this._handleOpen();\n resolve(this.socket);\n };\n \n this.socket.onmessage = this._handleMessage.bind(this);\n this.socket.onerror = (error) => {\n this._handleError(error);\n reject(error);\n };\n \n this.socket.onclose = this._handleClose.bind(this);\n\n // Timeout for connection\n setTimeout(() => {\n if (!this.isConnected) {\n reject(new Error('WebSocket connection timeout'));\n }\n }, 10000);\n }).finally(() => {\n this.connectPromise = null;\n });\n\n return this.connectPromise;\n }\n\n /**\n * Disconnect from WebSocket server\n */\n disconnect() {\n // Skip if running in SSR\n if (typeof window === 'undefined') {\n return;\n }\n\n if (this.socket) {\n // Remove event listeners\n this.socket.onopen = null;\n this.socket.onmessage = null;\n this.socket.onerror = null;\n this.socket.onclose = null;\n \n // Close connection\n if (this.socket.readyState === WebSocket.OPEN || \n this.socket.readyState === WebSocket.CONNECTING) {\n this.socket.close();\n }\n \n this.socket = null;\n }\n\n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n\n this.isConnected = false;\n this.userId = null;\n }\n\n /**\n * Send data through WebSocket\n * @param {Object|String} data - Data to send\n * @returns {Boolean} Success status\n */\n async send(data) {\n if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {\n console.error('Cannot send message: WebSocket is not connected');\n return false;\n }\n\n try {\n const message = typeof data === 'string' ? data : JSON.stringify(data);\n await this.socket.send(message);\n return true;\n } catch (error) {\n console.error('Error sending WebSocket message:', error);\n return false;\n }\n }\n\n /**\n * Register an event listener\n * @param {String} eventType - Event type to listen for\n * @param {Function} callback - Callback function\n * @param {Object} options - Additional options like module name for namespacing\n * @returns {String} Listener ID for unregistering\n */\n addEventListener(eventType, callback, options = {}) {\n const listenerId = `${options.module || 'global'}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;\n \n if (!this.listeners[eventType]) {\n this.listeners[eventType] = {};\n }\n \n this.listeners[eventType][listenerId] = callback;\n return listenerId;\n }\n\n /**\n * Remove an event listener\n * @param {String} eventType - Event type\n * @param {String} listenerId - Listener ID returned from addEventListener\n */\n removeEventListener(eventType, listenerId) {\n if (this.listeners[eventType] && this.listeners[eventType][listenerId]) {\n delete this.listeners[eventType][listenerId];\n }\n }\n\n /**\n * Remove all listeners for a module\n * @param {String} moduleName - Module name to remove listeners for\n */\n removeModuleListeners(moduleName) {\n if (!moduleName) return;\n \n Object.keys(this.listeners).forEach(eventType => {\n Object.keys(this.listeners[eventType]).forEach(listenerId => {\n if (listenerId.startsWith(`${moduleName}_`)) {\n delete this.listeners[eventType][listenerId];\n }\n });\n });\n }\n\n /**\n * Handle WebSocket open event\n */\n _handleOpen() {\n this.isConnected = true;\n this.reconnectAttempts = 0;\n \n // Setup ping interval to keep connection alive\n this.pingInterval = setInterval(() => {\n if (this.socket && this.socket.readyState === WebSocket.OPEN) {\n this.socket.send(JSON.stringify({ type: 'ping' }));\n }\n }, this.pingIntervalTime);\n\n // Notify listeners\n this._notifyListeners('open', { isConnected: true });\n }\n\n /**\n * Handle WebSocket message event\n * @param {Event} event - WebSocket message event\n */\n _handleMessage(event) {\n try {\n const data = JSON.parse(event.data);\n \n // Generic event notifications\n this._notifyListeners('message', data);\n \n // Specific event type notifications\n if (data.type) {\n this._notifyListeners(data.type, data);\n }\n \n } catch (error) {\n console.error('Error processing WebSocket message:', error);\n }\n }\n\n /**\n * Handle WebSocket error\n * @param {Error} error - WebSocket error\n */\n _handleError(error) {\n console.error('WebSocket error:', error);\n this._notifyListeners('error', { error });\n }\n\n /**\n * Handle WebSocket close event\n * @param {Event} event - WebSocket close event\n */\n _handleClose(event) {\n this.isConnected = false;\n \n // Clear ping interval\n if (this.pingInterval) {\n clearInterval(this.pingInterval);\n this.pingInterval = null;\n }\n \n this._notifyListeners('close', { code: event.code, reason: event.reason });\n \n // Attempt to reconnect if not a normal closure and we have a userId\n if (event.code !== 1000 && this.userId && this.reconnectAttempts < this.maxReconnectAttempts) {\n this.reconnectAttempts++;\n const delay = this.reconnectDelay * this.reconnectAttempts;\n \n setTimeout(() => {\n if (this.userId) {\n this.connect(this.userId).catch(error => {\n console.error('Reconnection failed:', error);\n });\n }\n }, delay);\n }\n }\n\n /**\n * Notify event listeners\n * @param {String} eventType - Event type\n * @param {Object} data - Event data\n */\n _notifyListeners(eventType, data) {\n if (!this.listeners[eventType]) return;\n \n Object.values(this.listeners[eventType]).forEach(callback => {\n try {\n callback(data);\n } catch (error) {\n console.error(`Error in WebSocket ${eventType} listener:`, error);\n }\n });\n }\n\n /**\n * Get connection status\n * @returns {Boolean} Connection status\n */\n isSocketConnected() {\n return this.isConnected && this.socket?.readyState === WebSocket.OPEN;\n }\n}\n\n// Create singleton instance\nconst globalWebSocket = new GlobalWebSocket();\n\nexport default globalWebSocket;"],"names":[],"mappings":"AAIA,MAAM,gBAAgB;AAAA,EACpB,cAAc;AACZ,SAAK,SAAS;AACd,SAAK,cAAc;AACnB,SAAK,oBAAoB;AACzB,SAAK,uBAAuB;AAC5B,SAAK,iBAAiB;AACtB,SAAK,UAAU;AACf,SAAK,eAAe;AACpB,SAAK,mBAAmB;AACxB,SAAK,YAAY,CAAE;AACnB,SAAK,SAAS;AACd,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,WAAW,UAAU,IAAI;AACvB,SAAK,uBAAuB,QAAQ,wBAAwB,KAAK;AACjE,SAAK,iBAAiB,QAAQ,kBAAkB,KAAK;AACrD,SAAK,UAAU,QAAQ,SAAS,KAAK,iBAAkB;AACvD,SAAK,mBAAmB,QAAQ,gBAAgB,KAAK;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,mBAAmB;AAEjB,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO;AAAA,IACb;AAEI,UAAM,WAAW,OAAO,SAAS,aA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,KAAK,cAAc;AACrB,oBAAc,KAAK,YAAY;AAC/B,WAAK,eAAe;AAAA,IAC1B;AAEI,SAAK,iBAAiB,SAAS,EAAE,MAAM,MAAM,MAAM,QAAQ,MAAM,QAAQ;AAGzE,QAAI,MAAM,SAAS,OAAQ,KAAK,UAAU,KAAK,oBAAoB,KAAK,sBAAsB;AAC5F,WAAK;AACL,YAAM,QAAQ,KAAK,iBAAiB,KAAK;AAEzC,iBAAW,MAAM;AACf,YAAI,KAAK,QAAQ;AACf,eAAK,QAAQ,KAAK,MAAM,EAAE,MAAM,WAAS;AACvC,oBAAQ,MAAM,wBAAwB,KAAK;AAAA,UACvD,CAAW;AAAA,QACX;AAAA,MACO,GAAE,KAAK;AAAA,IACd;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOE,iBAAiB,WAAW,MAAM;AAChC,QAAI,CAAC,KAAK,UAAU,SAAS,EAAG;AAEhC,WAAO,OAAO,KAAK,UAAU,SAAS,CAAC,EAAE,QAAQ,cAAY;AAC3D,UAAI;AACF,iBAAS,IAAI;AAAA,MACd,SAAQ,OAAO;AACd,gBAAQ,MAAM,sBAAsB,SAAS,cAAc,KAAK;AAAA,MACxE;AAAA,IACA,CAAK;AAAA,EACL;AAAA;AAAA;AAAA;AAAA;AAAA,EAME,oBAAoB;AA/StB;AAgTI,WAAO,KAAK,iBAAe,UAAK,WAAL,mBAAa,gBAAe,UAAU;AAAA,EACrE;AACA;AAGK,MAAC,kBAAkB,IAAI,gBAAe;"}
|
|
@@ -80,7 +80,7 @@ const _sfc_main = {
|
|
|
80
80
|
class: vue.normalizeClass(["pos-relative o-hidden", {
|
|
81
81
|
"pd-t-extra": _ctx.MOBILE_APP === "ios",
|
|
82
82
|
"bg-white": headerTheme.value === "light",
|
|
83
|
-
"bg-
|
|
83
|
+
"bg-black": headerTheme.value === "dark"
|
|
84
84
|
}])
|
|
85
85
|
}, [
|
|
86
86
|
vue.createVNode(vue.Transition, {
|
|
@@ -110,8 +110,9 @@ const _sfc_main = {
|
|
|
110
110
|
key: 0,
|
|
111
111
|
horizontal: true,
|
|
112
112
|
navigationItems: vue.unref(route).meta.sidebar_navigation_items,
|
|
113
|
-
stateSidebar: globals.state.isOpenSidebar
|
|
114
|
-
|
|
113
|
+
stateSidebar: globals.state.isOpenSidebar,
|
|
114
|
+
theme: headerTheme.value
|
|
115
|
+
}, null, 8, ["navigationItems", "stateSidebar", "theme"])) : vue.createCommentVNode("", true)
|
|
115
116
|
];
|
|
116
117
|
}),
|
|
117
118
|
_: 1
|
|
@@ -150,15 +151,16 @@ const _sfc_main = {
|
|
|
150
151
|
}])
|
|
151
152
|
}, [
|
|
152
153
|
vue.createVNode(ShopCart.default, {
|
|
153
|
-
class: vue.normalizeClass(
|
|
154
|
+
class: vue.normalizeClass({
|
|
154
155
|
"mobile:pd-t-extra": _ctx.MOBILE_APP === "ios"
|
|
155
|
-
}
|
|
156
|
+
})
|
|
156
157
|
}, null, 8, ["class"]),
|
|
157
158
|
((_a = vue.unref(route).meta) == null ? void 0 : _a.sidebar) && !_ctx.MOBILE_APP ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(route).meta.sidebar), {
|
|
158
159
|
key: 0,
|
|
159
160
|
stateSidebar: globals.state.isOpenSidebar,
|
|
160
161
|
widthHidden: (_b = vue.unref(route).meta) == null ? void 0 : _b.sidebar_width_hidden,
|
|
161
162
|
width: (_c = vue.unref(route).meta) == null ? void 0 : _c.sidebar_width,
|
|
163
|
+
theme: headerTheme.value,
|
|
162
164
|
onCloseSidebar: _cache[0] || (_cache[0] = () => globals.state.isOpenSidebar = !globals.state.isOpenSidebar)
|
|
163
165
|
}, {
|
|
164
166
|
default: vue.withCtx(({ Component }) => [
|
|
@@ -173,15 +175,16 @@ const _sfc_main = {
|
|
|
173
175
|
((_a2 = vue.unref(route).meta) == null ? void 0 : _a2.sidebar_navigation) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(route).meta.sidebar_navigation), {
|
|
174
176
|
key: vue.unref(route).meta.sidebar_navigation,
|
|
175
177
|
navigationItems: vue.unref(route).meta.sidebar_navigation_items,
|
|
176
|
-
stateSidebar: globals.state.isOpenSidebar
|
|
177
|
-
|
|
178
|
+
stateSidebar: globals.state.isOpenSidebar,
|
|
179
|
+
theme: headerTheme.value
|
|
180
|
+
}, null, 8, ["navigationItems", "stateSidebar", "theme"])) : vue.createCommentVNode("", true)
|
|
178
181
|
];
|
|
179
182
|
}),
|
|
180
183
|
_: 1
|
|
181
184
|
})
|
|
182
185
|
]),
|
|
183
186
|
_: 1
|
|
184
|
-
}, 40, ["stateSidebar", "widthHidden", "width"])) : vue.createCommentVNode("", true),
|
|
187
|
+
}, 40, ["stateSidebar", "widthHidden", "width", "theme"])) : vue.createCommentVNode("", true),
|
|
185
188
|
vue.createElementVNode("div", _hoisted_1, [
|
|
186
189
|
globals.state.error.show ? (vue.openBlock(), vue.createBlock(Status.default, {
|
|
187
190
|
key: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.vue.cjs","sources":["../../../../../../../../src/modules/globals/views/components/layouts/Client.vue"],"sourcesContent":["<template>\n\t<div \n\t\tid=\"app-wrapper\"\n\t\tclass=\"pos-relative o-hidden\"\n\t\t:class=\"{\n \t\t'pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t'bg-white': headerTheme === 'light',\n\t\t\t'bg-dark': headerTheme === 'dark' \n \t}\"\n\t>\n\t\t<transition name=\"moveFromTop\" appear>\n\t\t\t<Loader v-if=\"!page\" class=\"pos-fixed\"/>\n\t\t</transition>\n\t\n <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.header\"\n ref=\"header\" \n :is=\"route.meta.header\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.logotype\"\n :location=\"route.meta.location\"\n >\n \t<component\n\t\t v-if=\"route.meta?.header_navigation\"\n\t\t :is=\"route.meta.header_navigation\"\n\t\t :horizontal=\"true\"\n\t\t\t\t:navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t\t:stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t />\n \t</component>\n\n\t\t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t\t<component\n \tv-if=\"MOBILE_APP && !route.meta.hideNavigationBar\"\n :is=\"route.meta.navigationbar\"\n :logotype=\"route.meta.logotype\"\n :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n />\n\t\t</transition>\n\n\t <Popup \n\t \t@close-popup=\"closeLocationPopup\" \n\t \t:isPopupOpen=\"globals.state.isOpenLocationPopup\"\n\t \tclass=\"bg-white pd-semi w-m-33r radius-big\"\n\t >\t\n\t \t<LocationSelection />\n\t </Popup>\n\n\t\t<section \n\t\t\tid=\"screen\" \n\t\t\tref=\"screen\"\n\t\t\t@scroll=\"handleScroll\"\n\t\t\tclass=\"flex flex-nowrap transition-ease-in-out o-hidden pos-relative\"\n\t\t\t:class=\"{\n\t\t\t\t'': MOBILE_APP === 'ios',\n }\"\n\t\t>\n\t\t\t<ShopCart \n\t\t\t\tclass=\"pd-t-extra\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t'mobile:pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t\t}\"\n\t\t\t/>\n\n\t\t\t<!-- <section v-if=\"!route.meta?.breadcrumbs?.hide\" class=\"pd-thin pd-b-zero\">\n\t\t\t\t<Breadcrumbs \n\t\t\t\t\tv-if=\"!MOBILE_APP\"\n\t\t\t\t\tclass=\"bg-light pd-small radius-big\"\n\t\t\t\t/>\n\t\t\t</section> -->\n\n\t <component\n\t v-if=\"route.meta?.sidebar && !MOBILE_APP\"\n\t v-slot=\"{ Component }\"\n\t :is=\"route.meta.sidebar\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t :widthHidden='route.meta?.sidebar_width_hidden'\n\t :width=\"route.meta?.sidebar_width\"\n\t @closeSidebar=\"() => globals.state.isOpenSidebar = !globals.state.isOpenSidebar\"\n\t >\n\t \t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t <component\n\t\t v-if=\"route.meta?.sidebar_navigation\"\n\t\t :is=\"route.meta.sidebar_navigation\"\n\t\t :key=\"route.meta.sidebar_navigation\"\n\t\t :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t />\n\t </transition>\n\t </component>\n\t\t \n\t\t <div class=\"rows-1-min0_max1 pos-relative w-100 h-100\">\n \t\t\t<Status \n\t\t\t\t\tv-if=\"globals.state.error.show\" \n\t\t\t\t\t:data=\"globals.state.error\"\n\t\t\t\t\t@close=\"globals.state.error.show = false\"\n\t\t\t\t\tclass=\"z-index-7\" \n\t\t\t\t/>\n\t\t\t\t <Suspense @resolve=\"onSuspenseResolved\">\n\t\t\t\t\t<router-view \n\t\t\t\t\t\tv-slot=\"{ Component, route }\" \n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'scroll-hide': MOBILE_APP,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t\tclass=\"o-y-scroll o-x-hidden flex flex-column pos-relative h-100\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<transition @before-enter=\"scrollTop\" name=\"scaleTransition\" mode=\"out-in\" appear>\n\t\t\t \t<component \n\t\t\t \t\tref=\"page\" \n\t\t\t \t\t:is=\"Component\" \n\t\t\t \t\t:key=\"route.path\"\n\t\t\t \t\tclass=\"w-100 h-min-100\"\n\t\t \t\t @page-loading=\"handlePageLoading\"\n\t @page-loaded=\"handlePageLoaded\"\n\t\t\t \t/>\n\t\t\t \t<!-- Key пока выключил непонятно какие проблемы это вызовет -->\n\t\t\t \t<!-- -->\n\t\t\t </transition>\n\n\t\t\t <!-- <Footer /> -->\n\t\t\t\t\t</router-view>\n\t\t\t\t</Suspense>\n\t\t\t</div>\n\t\t</section>\n\n\t\t<router-view \n\t\t\tname=\"defaultBottom\"\n\t\t\tv-slot=\"{ Component, route }\" \n\t\t>\n\t\t\t<component \n \t\t:is=\"Component\" \n \t/>\n\t\t</router-view>\n\n\t <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.footer?.component && !route.meta.hideFooter\"\n ref=\"footer\" \n :is=\"route.meta.footer.component\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.footer.logotype\"\n :location=\"route.meta.footer.location\"\n />\n\n <component \n v-if=\"MOBILE_APP && route.meta.title_hide\"\n class=\"z-index-2\"\n \t:is=\"route.meta.bottombar\"\n />\n\t</div>\n</template>\n\n\n\n<script setup>\n\timport { computed, ref, onMounted, watch } from 'vue';\n\t// Router\n\timport { useRoute } from 'vue-router';\n\t// Store\n\timport * as globals from '@martyrs/src/modules/globals/views/store/globals';\n\t// Partials\n\timport Status from '@martyrs/src/components/Status/Status.vue';\n\timport Popup from '@martyrs/src/components/Popup/Popup.vue';\n\t// import Breadcrumbs from '@martyrs/src/components/Breadcrumbs/Breadcrumbs.vue'\n\timport Loader from '@martyrs/src/components/Loader/Loader.vue';\n\n\timport NavigationBar from '@martyrs/src/modules/globals/views/components/partials/NavigationBar.vue';\n\timport LocationSelection from '@martyrs/src/modules/globals/views/components/partials/LocationSelection.vue';\n\t// import Footer from '@martyrs/src/modules/globals/views/components/partials/Footer.vue'\n\n\timport ShopCart from '@martyrs/src/modules/orders/components/partials/ShopCart.vue';\n\t/////////////////////////////\n // LOADING\n /////////////////////////////\n // State\n let show = ref(false)\n // Preloader\n const page = ref(null)\n\n const isPageLoading = ref(true);\n \n // Обработчики событий загрузки\n function handlePageLoading() {\n isPageLoading.value = true;\n }\n \n function handlePageLoaded() {\n isPageLoading.value = false;\n }\n \n // Обработка события разрешения Suspense (когда async setup компонента завершается)\n function onSuspenseResolved() {\n // Если страница не отправляет событие page-loaded, этот обработчик \n // может служить запасным вариантом для отключения лоадера\n // Можно оставить закомментированным, если все страницы будут явно вызывать handlePageLoaded\n // isPageLoading.value = false;\n }\n\t/////////////////////////////\n\t// CREATED\n\t/////////////////////////////\n\tconst route = useRoute()\n\t// const router = useRouter()\n\t// Ref Code\n\tconst referalCode = ref(route.query.referalCode);\n\t/////////////////////////////\n\t// Methods\n\t/////////////////////////////\n\tfunction closeLocationPopup() {\n\t globals.state.isOpenLocationPopup = false;\n\t}\n\tfunction scrollTop(){\n\t\tdocument.getElementById('app').scrollIntoView();\n\t}\n\t// Scrolling header\n\tconst scrollOffset = ref(0)\n\tlet isScrolled = false\n\tconst header = ref(null)\n\n\tconst headerTheme = computed(() => {\n\t\tif (scrollOffset.value > 50) {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t} else {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t}\n\t})\n\n\tconst handleScroll = () => {\n\t scrollOffset.value = event.target.scrollTop\n\t};\n\n\tonMounted(async () => {\n\t\t \n\t\tif ('serviceWorker' in navigator) {\n\t \twindow.addEventListener('load', () => {\n\t \tnavigator.serviceWorker.register('/service-worker.js').then(registration => {\n\t \tconsole.log('SW registered: ', registration);\n\t \t}).catch(registrationError => {\n\t \tconsole.log('SW registration failed: ', registrationError);\n\t \t});\n\t });\n\t \t}\n\t\t\n\t\tconst savedPosition = localStorage.getItem('position');\n\n\t if (savedPosition) {\n\t globals.state.position = JSON.parse(savedPosition);\n\t } else if (route.meta.location) {\n \t\tglobals.state.isOpenLocationPopup = true;\n\t } else {\n\t \tglobals.state.isOpenLocationPopup = false;\n\t }\n\n\t\tif (referalCode.value) {\n\t\t localStorage.setItem('referalCode', referalCode.value);\n\t\t}\n\n\t\tif (page.value) show.value = true\n\t});\n</script>\n\n<style lang=\"scss\">\n\t.fade-enter-active, .fade-leave-active {\n\t transition: opacity .5s;\n\t}\n\t.fade-enter, .fade-leave-to /* .fade-leave-active в версии 2.1.8+ */ {\n\t opacity: 0;\n\t}\n\n\t\n .fade-move,\n .fade-enter-active,\n .fade-leave-active {\n transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);\n }\n\n /* 2. declare enter from and leave to state */\n .fade-enter-from,\n .fade-leave-to {\n opacity: 0;\n transform: translate(30px, 0);\n }\n\n /* 3. ensure leaving items are taken out of layout flow so that moving\n animations can be calculated correctly. */\n .fade-leave-active {\n position: absolute;\n }\n\n\t.moveFromTop-enter-active,\n\t.moveFromTop-leave-active {\n\t\ttransform: translateY(0);\n\t\topacity: 1;\n\t\ttransition: all 0.5s ease; \n\t\t\n\t}\n\t.moveFromTop-enter-from,\n\t.moveFromTop-leave-to {\n\t\ttransform: translateY(-1rem);\n\t\topacity: 0;\n\t\ttransition: all 0.5s ease;\n\t}\n\n\t.moveFromTopAbsolute-enter-active,\n\t.moveFromTopAbsolute-leave-active {\n\t\ttransform: translateY(0);\n\t\topacity: 1;\n\t\ttransition: all 0.5s ease; \n\t\t\n\t}\n\t.moveFromTopAbsolute-enter-from,\n\t.moveFromTopAbsolute-leave-to {\n\t\tposition: absolute;\n\t\ttransform: translateY(-1rem);\n\t\topacity: 0;\n\t\ttransition: all 0.5s ease;\n\t}\n\t.ScaleOut-enter-active,\n\t.ScaleOut-leave-active {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t\ttransition: all 0.3s ease; \n\t\t\n\t}\n\t.ScaleOut-enter-from,\n\t.ScaleOut-leave-to {\n\t\topacity: 0;\n\t\ttransform: scale(0.9);\n\t\ttransition: all 0.3s ease;\n\t}\n\t.slide-fade-enter-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-leave-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-enter-from,\n\t.slide-fade-leave-to {\n\t\tmin-height: 0;\n\t transform: translateX(20px);\n\t opacity: 0;\n\t left: 0;\n\t top: 0;\n\t}\n\n\t.scaleTransition-5px-enter-active,\n .scaleTransition-5px-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.2s ease;\n }\n\n .scaleTransition-5px-enter-from,\n .scaleTransition-5px-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n transform: translateY(-30px); \n transition: all 0.2s ease;\n }\n\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleTransition-enter-active,\n .scaleTransition-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.5s ease;\n }\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleIn-enter-active,\n .scaleIn-leave-active {\n // background: red;\n transition: all 0.5s ease;\n > section,div { transform-origin: 0 0; transform: translateZ(0px); transition: all 0.5s ease; }\n }\n .scaleIn-enter-from,\n .scaleIn-leave-to {\n opacity: 0;\n transform: scale(0.95);\n > section,div { transform: translateZ(-30px); transition: all 0.5s ease; }\n }\n</style>"],"names":["ref","useRoute","globals.state","computed","onMounted"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+KE,QAAI,OAAOA,IAAAA,IAAI,KAAK;AAEpB,UAAM,OAAOA,IAAAA,IAAI,IAAI;AAErB,UAAM,gBAAgBA,IAAG,IAAC,IAAI;AAG9B,aAAS,oBAAoB;AAC3B,oBAAc,QAAQ;AAAA,IAC1B;AAEE,aAAS,mBAAmB;AAC1B,oBAAc,QAAQ;AAAA,IAC1B;AAGE,aAAS,qBAAqB;AAAA,IAKhC;AAIC,UAAM,QAAQC,UAAQ,SAAA;AAGtB,UAAM,cAAcD,IAAG,IAAC,MAAM,MAAM,WAAW;AAI/C,aAAS,qBAAqB;AAC5BE,cAAa,MAAC,sBAAsB;AAAA,IACvC;AACC,aAAS,YAAW;AACnB,eAAS,eAAe,KAAK,EAAE,eAAgB;AAAA,IACjD;AAEC,UAAM,eAAeF,IA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/modules/globals/views/components/layouts/Client.vue"],"sourcesContent":["<template>\n\t<div \n\t\tid=\"app-wrapper\"\n\t\tclass=\"pos-relative o-hidden\"\n\t\t:class=\"{\n \t\t'pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t'bg-white': headerTheme === 'light',\n\t\t\t'bg-black': headerTheme === 'dark' \n \t}\"\n\t>\n\t\t<transition name=\"moveFromTop\" appear>\n\t\t\t<Loader v-if=\"!page\" class=\"pos-fixed\"/>\n\t\t</transition>\n\t\n <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.header\"\n ref=\"header\" \n :is=\"route.meta.header\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.logotype\"\n :location=\"route.meta.location\"\n >\n \t<component\n\t\t v-if=\"route.meta?.header_navigation\"\n\t\t :is=\"route.meta.header_navigation\"\n\t\t :horizontal=\"true\"\n\t\t\t\t:navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t\t:stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t\t\t:theme=\"headerTheme\"\n\t\t />\n \t</component>\n\n\t\t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t\t<component\n \tv-if=\"MOBILE_APP && !route.meta.hideNavigationBar\"\n :is=\"route.meta.navigationbar\"\n :logotype=\"route.meta.logotype\"\n :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n />\n\t\t</transition>\n\n\t <Popup \n\t \t@close-popup=\"closeLocationPopup\" \n\t \t:isPopupOpen=\"globals.state.isOpenLocationPopup\"\n\t \tclass=\"bg-white pd-semi w-m-33r radius-big\"\n\t >\t\n\t \t<LocationSelection />\n\t </Popup>\n\n\t\t<section \n\t\t\tid=\"screen\" \n\t\t\tref=\"screen\"\n\t\t\t@scroll=\"handleScroll\"\n\t\t\tclass=\"flex flex-nowrap transition-ease-in-out o-hidden pos-relative\"\n\t\t\t:class=\"{\n\t\t\t\t'': MOBILE_APP === 'ios',\n }\"\n\t\t>\n\t\t\t<ShopCart \n\t\t\t\t:class=\"{\n\t\t\t\t\t'mobile:pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t\t}\"\n\t\t\t/>\n\n\t\t\t<!-- <section v-if=\"!route.meta?.breadcrumbs?.hide\" class=\"pd-thin pd-b-zero\">\n\t\t\t\t<Breadcrumbs \n\t\t\t\t\tv-if=\"!MOBILE_APP\"\n\t\t\t\t\tclass=\"bg-light pd-small radius-big\"\n\t\t\t\t/>\n\t\t\t</section> -->\n\n\t <component\n\t v-if=\"route.meta?.sidebar && !MOBILE_APP\"\n\t v-slot=\"{ Component }\"\n\t :is=\"route.meta.sidebar\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t :widthHidden='route.meta?.sidebar_width_hidden'\n\t :width=\"route.meta?.sidebar_width\"\n\t :theme=\"headerTheme\"\n\t @closeSidebar=\"() => globals.state.isOpenSidebar = !globals.state.isOpenSidebar\"\n\t >\n\t \t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t <component\n\t\t v-if=\"route.meta?.sidebar_navigation\"\n\t\t :is=\"route.meta.sidebar_navigation\"\n\t\t :key=\"route.meta.sidebar_navigation\"\n\t\t :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t\t\t\t\t:theme=\"headerTheme\"\n\t\t />\n\t </transition>\n\t </component>\n\t\t \n\t\t <div class=\"rows-1-min0_max1 pos-relative w-100 h-100\">\n \t\t\t<Status \n\t\t\t\t\tv-if=\"globals.state.error.show\" \n\t\t\t\t\t:data=\"globals.state.error\"\n\t\t\t\t\t@close=\"globals.state.error.show = false\"\n\t\t\t\t\tclass=\"z-index-7\" \n\t\t\t\t/>\n\t\t\t\t <Suspense @resolve=\"onSuspenseResolved\">\n\t\t\t\t\t<router-view \n\t\t\t\t\t\tv-slot=\"{ Component, route }\" \n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'scroll-hide': MOBILE_APP,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t\tclass=\"o-y-scroll o-x-hidden flex flex-column pos-relative h-100\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<transition @before-enter=\"scrollTop\" name=\"scaleTransition\" mode=\"out-in\" appear>\n\t\t\t \t<component \n\t\t\t \t\tref=\"page\" \n\t\t\t \t\t:is=\"Component\" \n\t\t\t \t\t:key=\"route.path\"\n\t\t\t \t\tclass=\"w-100 h-min-100\"\n\t\t \t\t @page-loading=\"handlePageLoading\"\n\t @page-loaded=\"handlePageLoaded\"\n\t\t\t \t/>\n\t\t\t \t<!-- Key пока выключил непонятно какие проблемы это вызовет -->\n\t\t\t \t<!-- -->\n\t\t\t </transition>\n\n\t\t\t <!-- <Footer /> -->\n\t\t\t\t\t</router-view>\n\t\t\t\t</Suspense>\n\t\t\t</div>\n\t\t</section>\n\n\t\t<router-view \n\t\t\tname=\"defaultBottom\"\n\t\t\tv-slot=\"{ Component, route }\" \n\t\t>\n\t\t\t<component \n \t\t:is=\"Component\" \n \t/>\n\t\t</router-view>\n\n\t <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.footer?.component && !route.meta.hideFooter\"\n ref=\"footer\" \n :is=\"route.meta.footer.component\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.footer.logotype\"\n :location=\"route.meta.footer.location\"\n />\n\n <component \n v-if=\"MOBILE_APP && route.meta.title_hide\"\n class=\"z-index-2\"\n \t:is=\"route.meta.bottombar\"\n />\n\t</div>\n</template>\n\n\n\n<script setup>\n\timport { computed, ref, onMounted, watch } from 'vue';\n\t// Router\n\timport { useRoute } from 'vue-router';\n\t// Store\n\timport * as globals from '@martyrs/src/modules/globals/views/store/globals';\n\t// Partials\n\timport Status from '@martyrs/src/components/Status/Status.vue';\n\timport Popup from '@martyrs/src/components/Popup/Popup.vue';\n\t// import Breadcrumbs from '@martyrs/src/components/Breadcrumbs/Breadcrumbs.vue'\n\timport Loader from '@martyrs/src/components/Loader/Loader.vue';\n\n\timport NavigationBar from '@martyrs/src/modules/globals/views/components/partials/NavigationBar.vue';\n\timport LocationSelection from '@martyrs/src/modules/globals/views/components/partials/LocationSelection.vue';\n\t// import Footer from '@martyrs/src/modules/globals/views/components/partials/Footer.vue'\n\n\timport ShopCart from '@martyrs/src/modules/orders/components/partials/ShopCart.vue';\n\t/////////////////////////////\n // LOADING\n /////////////////////////////\n // State\n let show = ref(false)\n // Preloader\n const page = ref(null)\n\n const isPageLoading = ref(true);\n \n // Обработчики событий загрузки\n function handlePageLoading() {\n isPageLoading.value = true;\n }\n \n function handlePageLoaded() {\n isPageLoading.value = false;\n }\n \n // Обработка события разрешения Suspense (когда async setup компонента завершается)\n function onSuspenseResolved() {\n // Если страница не отправляет событие page-loaded, этот обработчик \n // может служить запасным вариантом для отключения лоадера\n // Можно оставить закомментированным, если все страницы будут явно вызывать handlePageLoaded\n // isPageLoading.value = false;\n }\n\t/////////////////////////////\n\t// CREATED\n\t/////////////////////////////\n\tconst route = useRoute()\n\t// const router = useRouter()\n\t// Ref Code\n\tconst referalCode = ref(route.query.referalCode);\n\t/////////////////////////////\n\t// Methods\n\t/////////////////////////////\n\tfunction closeLocationPopup() {\n\t globals.state.isOpenLocationPopup = false;\n\t}\n\tfunction scrollTop(){\n\t\tdocument.getElementById('app').scrollIntoView();\n\t}\n\t// Scrolling header\n\tconst scrollOffset = ref(0)\n\tlet isScrolled = false\n\tconst header = ref(null)\n\n\tconst headerTheme = computed(() => {\n\t\tif (scrollOffset.value > 50) {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t} else {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t}\n\t})\n\n\tconst handleScroll = () => {\n\t scrollOffset.value = event.target.scrollTop\n\t};\n\n\tonMounted(async () => {\n\t\t \n\t\tif ('serviceWorker' in navigator) {\n\t \twindow.addEventListener('load', () => {\n\t \tnavigator.serviceWorker.register('/service-worker.js').then(registration => {\n\t \tconsole.log('SW registered: ', registration);\n\t \t}).catch(registrationError => {\n\t \tconsole.log('SW registration failed: ', registrationError);\n\t \t});\n\t });\n\t \t}\n\t\t\n\t\tconst savedPosition = localStorage.getItem('position');\n\n\t if (savedPosition) {\n\t globals.state.position = JSON.parse(savedPosition);\n\t } else if (route.meta.location) {\n \t\tglobals.state.isOpenLocationPopup = true;\n\t } else {\n\t \tglobals.state.isOpenLocationPopup = false;\n\t }\n\n\t\tif (referalCode.value) {\n\t\t localStorage.setItem('referalCode', referalCode.value);\n\t\t}\n\n\t\tif (page.value) show.value = true\n\t});\n</script>\n\n<style lang=\"scss\">\n\t.fade-enter-active, .fade-leave-active {\n\t transition: opacity .5s;\n\t}\n\t.fade-enter, .fade-leave-to /* .fade-leave-active в версии 2.1.8+ */ {\n\t opacity: 0;\n\t}\n\n\t\n .fade-move,\n .fade-enter-active,\n .fade-leave-active {\n transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);\n }\n\n /* 2. declare enter from and leave to state */\n .fade-enter-from,\n .fade-leave-to {\n opacity: 0;\n transform: translate(30px, 0);\n }\n\n /* 3. ensure leaving items are taken out of layout flow so that moving\n animations can be calculated correctly. */\n .fade-leave-active {\n position: absolute;\n }\n\n.moveFromTop-enter-active,\n.moveFromTop-leave-active {\n transition: all 0.3s ease, max-height 0.2s ease;\n overflow: hidden;\n}\n\n.moveFromTop-enter-from,\n.moveFromTop-leave-to {\n transform: translateY(-1rem);\n opacity: 0;\n max-height: 0;\n}\n\n.moveFromTop-enter-to,\n.moveFromTop-leave-from {\n max-height: 100vh; \n}\n\n\t.moveFromTopAbsolute-enter-active,\n\t.moveFromTopAbsolute-leave-active {\n\t\ttransform: translateY(0);\n\t\topacity: 1;\n\t\ttransition: all 0.5s ease; \n\t\t\n\t}\n\t.moveFromTopAbsolute-enter-from,\n\t.moveFromTopAbsolute-leave-to {\n\t\tposition: absolute;\n\t\ttransform: translateY(-1rem);\n\t\topacity: 0;\n\t\ttransition: all 0.5s ease;\n\t}\n\t.ScaleOut-enter-active,\n\t.ScaleOut-leave-active {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t\ttransition: all 0.3s ease; \n\t\t\n\t}\n\t.ScaleOut-enter-from,\n\t.ScaleOut-leave-to {\n\t\topacity: 0;\n\t\ttransform: scale(0.9);\n\t\ttransition: all 0.3s ease;\n\t}\n\t.slide-fade-enter-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-leave-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-enter-from,\n\t.slide-fade-leave-to {\n\t\tmin-height: 0;\n\t transform: translateX(20px);\n\t opacity: 0;\n\t left: 0;\n\t top: 0;\n\t}\n\n\t.scaleTransition-5px-enter-active,\n .scaleTransition-5px-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.2s ease;\n }\n\n .scaleTransition-5px-enter-from,\n .scaleTransition-5px-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n transform: translateY(-30px); \n transition: all 0.2s ease;\n }\n\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleTransition-enter-active,\n .scaleTransition-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.5s ease;\n }\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleIn-enter-active,\n .scaleIn-leave-active {\n // background: red;\n transition: all 0.5s ease;\n > section,div { transform-origin: 0 0; transform: translateZ(0px); transition: all 0.5s ease; }\n }\n .scaleIn-enter-from,\n .scaleIn-leave-to {\n opacity: 0;\n transform: scale(0.95);\n > section,div { transform: translateZ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AQ,UAAU;AAEpD,UAAI,eAAe;AACjBF,gBAAAA,MAAc,WAAW,KAAK,MAAM,aAAa;AAAA,MACtD,WAAc,MAAM,KAAK,UAAU;AAC/BA,gBAAa,MAAC,sBAAsB;AAAA,MACxC,OAAU;AACNA,gBAAa,MAAC,sBAAsB;AAAA,MACxC;AAEE,UAAI,YAAY,OAAO;AACrB,qBAAa,QAAQ,eAAe,YAAY,KAAK;AAAA,MACzD;AAEE,UAAI,KAAK,MAAO,MAAK,QAAQ;AAAA,IAC/B,CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -78,7 +78,7 @@ const _sfc_main = {
|
|
|
78
78
|
class: normalizeClass(["pos-relative o-hidden", {
|
|
79
79
|
"pd-t-extra": _ctx.MOBILE_APP === "ios",
|
|
80
80
|
"bg-white": headerTheme.value === "light",
|
|
81
|
-
"bg-
|
|
81
|
+
"bg-black": headerTheme.value === "dark"
|
|
82
82
|
}])
|
|
83
83
|
}, [
|
|
84
84
|
createVNode(Transition, {
|
|
@@ -108,8 +108,9 @@ const _sfc_main = {
|
|
|
108
108
|
key: 0,
|
|
109
109
|
horizontal: true,
|
|
110
110
|
navigationItems: unref(route).meta.sidebar_navigation_items,
|
|
111
|
-
stateSidebar: state.isOpenSidebar
|
|
112
|
-
|
|
111
|
+
stateSidebar: state.isOpenSidebar,
|
|
112
|
+
theme: headerTheme.value
|
|
113
|
+
}, null, 8, ["navigationItems", "stateSidebar", "theme"])) : createCommentVNode("", true)
|
|
113
114
|
];
|
|
114
115
|
}),
|
|
115
116
|
_: 1
|
|
@@ -148,15 +149,16 @@ const _sfc_main = {
|
|
|
148
149
|
}])
|
|
149
150
|
}, [
|
|
150
151
|
createVNode(_sfc_main$3, {
|
|
151
|
-
class: normalizeClass(
|
|
152
|
+
class: normalizeClass({
|
|
152
153
|
"mobile:pd-t-extra": _ctx.MOBILE_APP === "ios"
|
|
153
|
-
}
|
|
154
|
+
})
|
|
154
155
|
}, null, 8, ["class"]),
|
|
155
156
|
((_a = unref(route).meta) == null ? void 0 : _a.sidebar) && !_ctx.MOBILE_APP ? (openBlock(), createBlock(resolveDynamicComponent(unref(route).meta.sidebar), {
|
|
156
157
|
key: 0,
|
|
157
158
|
stateSidebar: state.isOpenSidebar,
|
|
158
159
|
widthHidden: (_b = unref(route).meta) == null ? void 0 : _b.sidebar_width_hidden,
|
|
159
160
|
width: (_c = unref(route).meta) == null ? void 0 : _c.sidebar_width,
|
|
161
|
+
theme: headerTheme.value,
|
|
160
162
|
onCloseSidebar: _cache[0] || (_cache[0] = () => state.isOpenSidebar = !state.isOpenSidebar)
|
|
161
163
|
}, {
|
|
162
164
|
default: withCtx(({ Component }) => [
|
|
@@ -171,15 +173,16 @@ const _sfc_main = {
|
|
|
171
173
|
((_a2 = unref(route).meta) == null ? void 0 : _a2.sidebar_navigation) ? (openBlock(), createBlock(resolveDynamicComponent(unref(route).meta.sidebar_navigation), {
|
|
172
174
|
key: unref(route).meta.sidebar_navigation,
|
|
173
175
|
navigationItems: unref(route).meta.sidebar_navigation_items,
|
|
174
|
-
stateSidebar: state.isOpenSidebar
|
|
175
|
-
|
|
176
|
+
stateSidebar: state.isOpenSidebar,
|
|
177
|
+
theme: headerTheme.value
|
|
178
|
+
}, null, 8, ["navigationItems", "stateSidebar", "theme"])) : createCommentVNode("", true)
|
|
176
179
|
];
|
|
177
180
|
}),
|
|
178
181
|
_: 1
|
|
179
182
|
})
|
|
180
183
|
]),
|
|
181
184
|
_: 1
|
|
182
|
-
}, 40, ["stateSidebar", "widthHidden", "width"])) : createCommentVNode("", true),
|
|
185
|
+
}, 40, ["stateSidebar", "widthHidden", "width", "theme"])) : createCommentVNode("", true),
|
|
183
186
|
createElementVNode("div", _hoisted_1, [
|
|
184
187
|
state.error.show ? (openBlock(), createBlock(_sfc_main$4, {
|
|
185
188
|
key: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Client.vue.js","sources":["../../../../../../../../src/modules/globals/views/components/layouts/Client.vue"],"sourcesContent":["<template>\n\t<div \n\t\tid=\"app-wrapper\"\n\t\tclass=\"pos-relative o-hidden\"\n\t\t:class=\"{\n \t\t'pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t'bg-white': headerTheme === 'light',\n\t\t\t'bg-dark': headerTheme === 'dark' \n \t}\"\n\t>\n\t\t<transition name=\"moveFromTop\" appear>\n\t\t\t<Loader v-if=\"!page\" class=\"pos-fixed\"/>\n\t\t</transition>\n\t\n <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.header\"\n ref=\"header\" \n :is=\"route.meta.header\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.logotype\"\n :location=\"route.meta.location\"\n >\n \t<component\n\t\t v-if=\"route.meta?.header_navigation\"\n\t\t :is=\"route.meta.header_navigation\"\n\t\t :horizontal=\"true\"\n\t\t\t\t:navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t\t:stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t />\n \t</component>\n\n\t\t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t\t<component\n \tv-if=\"MOBILE_APP && !route.meta.hideNavigationBar\"\n :is=\"route.meta.navigationbar\"\n :logotype=\"route.meta.logotype\"\n :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n />\n\t\t</transition>\n\n\t <Popup \n\t \t@close-popup=\"closeLocationPopup\" \n\t \t:isPopupOpen=\"globals.state.isOpenLocationPopup\"\n\t \tclass=\"bg-white pd-semi w-m-33r radius-big\"\n\t >\t\n\t \t<LocationSelection />\n\t </Popup>\n\n\t\t<section \n\t\t\tid=\"screen\" \n\t\t\tref=\"screen\"\n\t\t\t@scroll=\"handleScroll\"\n\t\t\tclass=\"flex flex-nowrap transition-ease-in-out o-hidden pos-relative\"\n\t\t\t:class=\"{\n\t\t\t\t'': MOBILE_APP === 'ios',\n }\"\n\t\t>\n\t\t\t<ShopCart \n\t\t\t\tclass=\"pd-t-extra\"\n\t\t\t\t:class=\"{\n\t\t\t\t\t'mobile:pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t\t}\"\n\t\t\t/>\n\n\t\t\t<!-- <section v-if=\"!route.meta?.breadcrumbs?.hide\" class=\"pd-thin pd-b-zero\">\n\t\t\t\t<Breadcrumbs \n\t\t\t\t\tv-if=\"!MOBILE_APP\"\n\t\t\t\t\tclass=\"bg-light pd-small radius-big\"\n\t\t\t\t/>\n\t\t\t</section> -->\n\n\t <component\n\t v-if=\"route.meta?.sidebar && !MOBILE_APP\"\n\t v-slot=\"{ Component }\"\n\t :is=\"route.meta.sidebar\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t :widthHidden='route.meta?.sidebar_width_hidden'\n\t :width=\"route.meta?.sidebar_width\"\n\t @closeSidebar=\"() => globals.state.isOpenSidebar = !globals.state.isOpenSidebar\"\n\t >\n\t \t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t <component\n\t\t v-if=\"route.meta?.sidebar_navigation\"\n\t\t :is=\"route.meta.sidebar_navigation\"\n\t\t :key=\"route.meta.sidebar_navigation\"\n\t\t :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t />\n\t </transition>\n\t </component>\n\t\t \n\t\t <div class=\"rows-1-min0_max1 pos-relative w-100 h-100\">\n \t\t\t<Status \n\t\t\t\t\tv-if=\"globals.state.error.show\" \n\t\t\t\t\t:data=\"globals.state.error\"\n\t\t\t\t\t@close=\"globals.state.error.show = false\"\n\t\t\t\t\tclass=\"z-index-7\" \n\t\t\t\t/>\n\t\t\t\t <Suspense @resolve=\"onSuspenseResolved\">\n\t\t\t\t\t<router-view \n\t\t\t\t\t\tv-slot=\"{ Component, route }\" \n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'scroll-hide': MOBILE_APP,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t\tclass=\"o-y-scroll o-x-hidden flex flex-column pos-relative h-100\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<transition @before-enter=\"scrollTop\" name=\"scaleTransition\" mode=\"out-in\" appear>\n\t\t\t \t<component \n\t\t\t \t\tref=\"page\" \n\t\t\t \t\t:is=\"Component\" \n\t\t\t \t\t:key=\"route.path\"\n\t\t\t \t\tclass=\"w-100 h-min-100\"\n\t\t \t\t @page-loading=\"handlePageLoading\"\n\t @page-loaded=\"handlePageLoaded\"\n\t\t\t \t/>\n\t\t\t \t<!-- Key пока выключил непонятно какие проблемы это вызовет -->\n\t\t\t \t<!-- -->\n\t\t\t </transition>\n\n\t\t\t <!-- <Footer /> -->\n\t\t\t\t\t</router-view>\n\t\t\t\t</Suspense>\n\t\t\t</div>\n\t\t</section>\n\n\t\t<router-view \n\t\t\tname=\"defaultBottom\"\n\t\t\tv-slot=\"{ Component, route }\" \n\t\t>\n\t\t\t<component \n \t\t:is=\"Component\" \n \t/>\n\t\t</router-view>\n\n\t <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.footer?.component && !route.meta.hideFooter\"\n ref=\"footer\" \n :is=\"route.meta.footer.component\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.footer.logotype\"\n :location=\"route.meta.footer.location\"\n />\n\n <component \n v-if=\"MOBILE_APP && route.meta.title_hide\"\n class=\"z-index-2\"\n \t:is=\"route.meta.bottombar\"\n />\n\t</div>\n</template>\n\n\n\n<script setup>\n\timport { computed, ref, onMounted, watch } from 'vue';\n\t// Router\n\timport { useRoute } from 'vue-router';\n\t// Store\n\timport * as globals from '@martyrs/src/modules/globals/views/store/globals';\n\t// Partials\n\timport Status from '@martyrs/src/components/Status/Status.vue';\n\timport Popup from '@martyrs/src/components/Popup/Popup.vue';\n\t// import Breadcrumbs from '@martyrs/src/components/Breadcrumbs/Breadcrumbs.vue'\n\timport Loader from '@martyrs/src/components/Loader/Loader.vue';\n\n\timport NavigationBar from '@martyrs/src/modules/globals/views/components/partials/NavigationBar.vue';\n\timport LocationSelection from '@martyrs/src/modules/globals/views/components/partials/LocationSelection.vue';\n\t// import Footer from '@martyrs/src/modules/globals/views/components/partials/Footer.vue'\n\n\timport ShopCart from '@martyrs/src/modules/orders/components/partials/ShopCart.vue';\n\t/////////////////////////////\n // LOADING\n /////////////////////////////\n // State\n let show = ref(false)\n // Preloader\n const page = ref(null)\n\n const isPageLoading = ref(true);\n \n // Обработчики событий загрузки\n function handlePageLoading() {\n isPageLoading.value = true;\n }\n \n function handlePageLoaded() {\n isPageLoading.value = false;\n }\n \n // Обработка события разрешения Suspense (когда async setup компонента завершается)\n function onSuspenseResolved() {\n // Если страница не отправляет событие page-loaded, этот обработчик \n // может служить запасным вариантом для отключения лоадера\n // Можно оставить закомментированным, если все страницы будут явно вызывать handlePageLoaded\n // isPageLoading.value = false;\n }\n\t/////////////////////////////\n\t// CREATED\n\t/////////////////////////////\n\tconst route = useRoute()\n\t// const router = useRouter()\n\t// Ref Code\n\tconst referalCode = ref(route.query.referalCode);\n\t/////////////////////////////\n\t// Methods\n\t/////////////////////////////\n\tfunction closeLocationPopup() {\n\t globals.state.isOpenLocationPopup = false;\n\t}\n\tfunction scrollTop(){\n\t\tdocument.getElementById('app').scrollIntoView();\n\t}\n\t// Scrolling header\n\tconst scrollOffset = ref(0)\n\tlet isScrolled = false\n\tconst header = ref(null)\n\n\tconst headerTheme = computed(() => {\n\t\tif (scrollOffset.value > 50) {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t} else {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t}\n\t})\n\n\tconst handleScroll = () => {\n\t scrollOffset.value = event.target.scrollTop\n\t};\n\n\tonMounted(async () => {\n\t\t \n\t\tif ('serviceWorker' in navigator) {\n\t \twindow.addEventListener('load', () => {\n\t \tnavigator.serviceWorker.register('/service-worker.js').then(registration => {\n\t \tconsole.log('SW registered: ', registration);\n\t \t}).catch(registrationError => {\n\t \tconsole.log('SW registration failed: ', registrationError);\n\t \t});\n\t });\n\t \t}\n\t\t\n\t\tconst savedPosition = localStorage.getItem('position');\n\n\t if (savedPosition) {\n\t globals.state.position = JSON.parse(savedPosition);\n\t } else if (route.meta.location) {\n \t\tglobals.state.isOpenLocationPopup = true;\n\t } else {\n\t \tglobals.state.isOpenLocationPopup = false;\n\t }\n\n\t\tif (referalCode.value) {\n\t\t localStorage.setItem('referalCode', referalCode.value);\n\t\t}\n\n\t\tif (page.value) show.value = true\n\t});\n</script>\n\n<style lang=\"scss\">\n\t.fade-enter-active, .fade-leave-active {\n\t transition: opacity .5s;\n\t}\n\t.fade-enter, .fade-leave-to /* .fade-leave-active в версии 2.1.8+ */ {\n\t opacity: 0;\n\t}\n\n\t\n .fade-move,\n .fade-enter-active,\n .fade-leave-active {\n transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);\n }\n\n /* 2. declare enter from and leave to state */\n .fade-enter-from,\n .fade-leave-to {\n opacity: 0;\n transform: translate(30px, 0);\n }\n\n /* 3. ensure leaving items are taken out of layout flow so that moving\n animations can be calculated correctly. */\n .fade-leave-active {\n position: absolute;\n }\n\n\t.moveFromTop-enter-active,\n\t.moveFromTop-leave-active {\n\t\ttransform: translateY(0);\n\t\topacity: 1;\n\t\ttransition: all 0.5s ease; \n\t\t\n\t}\n\t.moveFromTop-enter-from,\n\t.moveFromTop-leave-to {\n\t\ttransform: translateY(-1rem);\n\t\topacity: 0;\n\t\ttransition: all 0.5s ease;\n\t}\n\n\t.moveFromTopAbsolute-enter-active,\n\t.moveFromTopAbsolute-leave-active {\n\t\ttransform: translateY(0);\n\t\topacity: 1;\n\t\ttransition: all 0.5s ease; \n\t\t\n\t}\n\t.moveFromTopAbsolute-enter-from,\n\t.moveFromTopAbsolute-leave-to {\n\t\tposition: absolute;\n\t\ttransform: translateY(-1rem);\n\t\topacity: 0;\n\t\ttransition: all 0.5s ease;\n\t}\n\t.ScaleOut-enter-active,\n\t.ScaleOut-leave-active {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t\ttransition: all 0.3s ease; \n\t\t\n\t}\n\t.ScaleOut-enter-from,\n\t.ScaleOut-leave-to {\n\t\topacity: 0;\n\t\ttransform: scale(0.9);\n\t\ttransition: all 0.3s ease;\n\t}\n\t.slide-fade-enter-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-leave-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-enter-from,\n\t.slide-fade-leave-to {\n\t\tmin-height: 0;\n\t transform: translateX(20px);\n\t opacity: 0;\n\t left: 0;\n\t top: 0;\n\t}\n\n\t.scaleTransition-5px-enter-active,\n .scaleTransition-5px-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.2s ease;\n }\n\n .scaleTransition-5px-enter-from,\n .scaleTransition-5px-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n transform: translateY(-30px); \n transition: all 0.2s ease;\n }\n\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleTransition-enter-active,\n .scaleTransition-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.5s ease;\n }\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleIn-enter-active,\n .scaleIn-leave-active {\n // background: red;\n transition: all 0.5s ease;\n > section,div { transform-origin: 0 0; transform: translateZ(0px); transition: all 0.5s ease; }\n }\n .scaleIn-enter-from,\n .scaleIn-leave-to {\n opacity: 0;\n transform: scale(0.95);\n > section,div { transform: translateZ(-30px); transition: all 0.5s ease; }\n }\n</style>"],"names":["globals.state"],"mappings":";;;;;;;;;;;;;;;;;;AA+KE,QAAI,OAAO,IAAI,KAAK;AAEpB,UAAM,OAAO,IAAI,IAAI;AAErB,UAAM,gBAAgB,IAAI,IAAI;AAG9B,aAAS,oBAAoB;AAC3B,oBAAc,QAAQ;AAAA,IAC1B;AAEE,aAAS,mBAAmB;AAC1B,oBAAc,QAAQ;AAAA,IAC1B;AAGE,aAAS,qBAAqB;AAAA,IAKhC;AAIC,UAAM,QAAQ,SAAQ;AAGtB,UAAM,cAAc,IAAI,MAAM,MAAM,WAAW;AAI/C,aAAS,qBAAqB;AAC5BA,YAAc,sBAAsB;AAAA,IACvC;AACC,aAAS,YAAW;AACnB,eAAS,eAAe,KAAK,EAAE,eAAgB;AAAA,IACjD;AAEC,UAAM,eAAe,IAAI,CAAC;AAE1B,UAAM,SAAS,IAAI,IAAI;AAEvB,UAAM,cAAc,SAAS,MAAM;AAClC,UAAI,aAAa,QAAQ,IAAI;AAC5B,eAAO,MAAM,KAAK,gBAAiB;AAAA,MACtC,OAAS;AACN,eAAO,MAAM,KAAK,gBAAgB;AAAA,MACrC;AAAA,IACE,CAAA;AAED,UAAM,eAAe,MAAM;AACzB,mBAAa,QAAQ,MAAM,OAAO;AAAA,IACnC;AAED,cAAU,YAAY;AAErB,UAAI,mBAAmB,WAAW;AAC/B,eAAO,iBAAiB,QAAQ,MAAM;AACpC,oBAAU,cAAc,SAAS,oBAAoB,EAAE,KAAK,kBAAgB;AAC1E,oBAAQ,IAAI,mBAAmB,YAAY;AAAA,UACpD,CAAQ,EAAE,MAAM,uBAAqB;AAC5B,oBAAQ,IAAI,4BAA4B,iBAAiB;AAAA,UAClE,CAAQ;AAAA,QACR,CAAK;AAAA,MACL;AAEE,YAAM,gBAAgB,aAAa,QAAQ,UAAU;AAEpD,UAAI,eAAe;AACjBA,cAAc,WAAW,KAAK,MAAM,aAAa;AAAA,MACtD,WAAc,MAAM,KAAK,UAAU;AAC/BA,cAAc,sBAAsB;AAAA,MACxC,OAAU;AACNA,cAAc,sBAAsB;AAAA,MACxC;AAEE,UAAI,YAAY,OAAO;AACrB,qBAAa,QAAQ,eAAe,YAAY,KAAK;AAAA,MACzD;AAEE,UAAI,KAAK,MAAO,MAAK,QAAQ;AAAA,IAC/B,CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Client.vue.js","sources":["../../../../../../../../src/modules/globals/views/components/layouts/Client.vue"],"sourcesContent":["<template>\n\t<div \n\t\tid=\"app-wrapper\"\n\t\tclass=\"pos-relative o-hidden\"\n\t\t:class=\"{\n \t\t'pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t'bg-white': headerTheme === 'light',\n\t\t\t'bg-black': headerTheme === 'dark' \n \t}\"\n\t>\n\t\t<transition name=\"moveFromTop\" appear>\n\t\t\t<Loader v-if=\"!page\" class=\"pos-fixed\"/>\n\t\t</transition>\n\t\n <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.header\"\n ref=\"header\" \n :is=\"route.meta.header\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.logotype\"\n :location=\"route.meta.location\"\n >\n \t<component\n\t\t v-if=\"route.meta?.header_navigation\"\n\t\t :is=\"route.meta.header_navigation\"\n\t\t :horizontal=\"true\"\n\t\t\t\t:navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t\t:stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t\t\t:theme=\"headerTheme\"\n\t\t />\n \t</component>\n\n\t\t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t\t<component\n \tv-if=\"MOBILE_APP && !route.meta.hideNavigationBar\"\n :is=\"route.meta.navigationbar\"\n :logotype=\"route.meta.logotype\"\n :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n />\n\t\t</transition>\n\n\t <Popup \n\t \t@close-popup=\"closeLocationPopup\" \n\t \t:isPopupOpen=\"globals.state.isOpenLocationPopup\"\n\t \tclass=\"bg-white pd-semi w-m-33r radius-big\"\n\t >\t\n\t \t<LocationSelection />\n\t </Popup>\n\n\t\t<section \n\t\t\tid=\"screen\" \n\t\t\tref=\"screen\"\n\t\t\t@scroll=\"handleScroll\"\n\t\t\tclass=\"flex flex-nowrap transition-ease-in-out o-hidden pos-relative\"\n\t\t\t:class=\"{\n\t\t\t\t'': MOBILE_APP === 'ios',\n }\"\n\t\t>\n\t\t\t<ShopCart \n\t\t\t\t:class=\"{\n\t\t\t\t\t'mobile:pd-t-extra': MOBILE_APP === 'ios', \n\t\t\t\t}\"\n\t\t\t/>\n\n\t\t\t<!-- <section v-if=\"!route.meta?.breadcrumbs?.hide\" class=\"pd-thin pd-b-zero\">\n\t\t\t\t<Breadcrumbs \n\t\t\t\t\tv-if=\"!MOBILE_APP\"\n\t\t\t\t\tclass=\"bg-light pd-small radius-big\"\n\t\t\t\t/>\n\t\t\t</section> -->\n\n\t <component\n\t v-if=\"route.meta?.sidebar && !MOBILE_APP\"\n\t v-slot=\"{ Component }\"\n\t :is=\"route.meta.sidebar\"\n\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t :widthHidden='route.meta?.sidebar_width_hidden'\n\t :width=\"route.meta?.sidebar_width\"\n\t :theme=\"headerTheme\"\n\t @closeSidebar=\"() => globals.state.isOpenSidebar = !globals.state.isOpenSidebar\"\n\t >\n\t \t<transition name=\"moveFromTop\" mode=\"out-in\" appear>\n\t\t <component\n\t\t v-if=\"route.meta?.sidebar_navigation\"\n\t\t :is=\"route.meta.sidebar_navigation\"\n\t\t :key=\"route.meta.sidebar_navigation\"\n\t\t :navigationItems=\"route.meta.sidebar_navigation_items\"\n\t\t\t :stateSidebar=\"globals.state.isOpenSidebar\" \n\t\t\t\t\t\t:theme=\"headerTheme\"\n\t\t />\n\t </transition>\n\t </component>\n\t\t \n\t\t <div class=\"rows-1-min0_max1 pos-relative w-100 h-100\">\n \t\t\t<Status \n\t\t\t\t\tv-if=\"globals.state.error.show\" \n\t\t\t\t\t:data=\"globals.state.error\"\n\t\t\t\t\t@close=\"globals.state.error.show = false\"\n\t\t\t\t\tclass=\"z-index-7\" \n\t\t\t\t/>\n\t\t\t\t <Suspense @resolve=\"onSuspenseResolved\">\n\t\t\t\t\t<router-view \n\t\t\t\t\t\tv-slot=\"{ Component, route }\" \n\t\t\t\t\t\t:class=\"{\n\t\t\t\t\t\t\t'scroll-hide': MOBILE_APP,\n\t\t\t\t\t\t}\"\n\t\t\t\t\t\tclass=\"o-y-scroll o-x-hidden flex flex-column pos-relative h-100\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<transition @before-enter=\"scrollTop\" name=\"scaleTransition\" mode=\"out-in\" appear>\n\t\t\t \t<component \n\t\t\t \t\tref=\"page\" \n\t\t\t \t\t:is=\"Component\" \n\t\t\t \t\t:key=\"route.path\"\n\t\t\t \t\tclass=\"w-100 h-min-100\"\n\t\t \t\t @page-loading=\"handlePageLoading\"\n\t @page-loaded=\"handlePageLoaded\"\n\t\t\t \t/>\n\t\t\t \t<!-- Key пока выключил непонятно какие проблемы это вызовет -->\n\t\t\t \t<!-- -->\n\t\t\t </transition>\n\n\t\t\t <!-- <Footer /> -->\n\t\t\t\t\t</router-view>\n\t\t\t\t</Suspense>\n\t\t\t</div>\n\t\t</section>\n\n\t\t<router-view \n\t\t\tname=\"defaultBottom\"\n\t\t\tv-slot=\"{ Component, route }\" \n\t\t>\n\t\t\t<component \n \t\t:is=\"Component\" \n \t/>\n\t\t</router-view>\n\n\t <component\n\t\t\tv-if=\"!MOBILE_APP && route.meta.footer?.component && !route.meta.hideFooter\"\n ref=\"footer\" \n :is=\"route.meta.footer.component\"\n :theme=\"headerTheme\"\n :logotype=\"route.meta.footer.logotype\"\n :location=\"route.meta.footer.location\"\n />\n\n <component \n v-if=\"MOBILE_APP && route.meta.title_hide\"\n class=\"z-index-2\"\n \t:is=\"route.meta.bottombar\"\n />\n\t</div>\n</template>\n\n\n\n<script setup>\n\timport { computed, ref, onMounted, watch } from 'vue';\n\t// Router\n\timport { useRoute } from 'vue-router';\n\t// Store\n\timport * as globals from '@martyrs/src/modules/globals/views/store/globals';\n\t// Partials\n\timport Status from '@martyrs/src/components/Status/Status.vue';\n\timport Popup from '@martyrs/src/components/Popup/Popup.vue';\n\t// import Breadcrumbs from '@martyrs/src/components/Breadcrumbs/Breadcrumbs.vue'\n\timport Loader from '@martyrs/src/components/Loader/Loader.vue';\n\n\timport NavigationBar from '@martyrs/src/modules/globals/views/components/partials/NavigationBar.vue';\n\timport LocationSelection from '@martyrs/src/modules/globals/views/components/partials/LocationSelection.vue';\n\t// import Footer from '@martyrs/src/modules/globals/views/components/partials/Footer.vue'\n\n\timport ShopCart from '@martyrs/src/modules/orders/components/partials/ShopCart.vue';\n\t/////////////////////////////\n // LOADING\n /////////////////////////////\n // State\n let show = ref(false)\n // Preloader\n const page = ref(null)\n\n const isPageLoading = ref(true);\n \n // Обработчики событий загрузки\n function handlePageLoading() {\n isPageLoading.value = true;\n }\n \n function handlePageLoaded() {\n isPageLoading.value = false;\n }\n \n // Обработка события разрешения Suspense (когда async setup компонента завершается)\n function onSuspenseResolved() {\n // Если страница не отправляет событие page-loaded, этот обработчик \n // может служить запасным вариантом для отключения лоадера\n // Можно оставить закомментированным, если все страницы будут явно вызывать handlePageLoaded\n // isPageLoading.value = false;\n }\n\t/////////////////////////////\n\t// CREATED\n\t/////////////////////////////\n\tconst route = useRoute()\n\t// const router = useRouter()\n\t// Ref Code\n\tconst referalCode = ref(route.query.referalCode);\n\t/////////////////////////////\n\t// Methods\n\t/////////////////////////////\n\tfunction closeLocationPopup() {\n\t globals.state.isOpenLocationPopup = false;\n\t}\n\tfunction scrollTop(){\n\t\tdocument.getElementById('app').scrollIntoView();\n\t}\n\t// Scrolling header\n\tconst scrollOffset = ref(0)\n\tlet isScrolled = false\n\tconst header = ref(null)\n\n\tconst headerTheme = computed(() => {\n\t\tif (scrollOffset.value > 50) {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t} else {\n\t\t\treturn route.meta.header_theme || 'light'\n\t\t}\n\t})\n\n\tconst handleScroll = () => {\n\t scrollOffset.value = event.target.scrollTop\n\t};\n\n\tonMounted(async () => {\n\t\t \n\t\tif ('serviceWorker' in navigator) {\n\t \twindow.addEventListener('load', () => {\n\t \tnavigator.serviceWorker.register('/service-worker.js').then(registration => {\n\t \tconsole.log('SW registered: ', registration);\n\t \t}).catch(registrationError => {\n\t \tconsole.log('SW registration failed: ', registrationError);\n\t \t});\n\t });\n\t \t}\n\t\t\n\t\tconst savedPosition = localStorage.getItem('position');\n\n\t if (savedPosition) {\n\t globals.state.position = JSON.parse(savedPosition);\n\t } else if (route.meta.location) {\n \t\tglobals.state.isOpenLocationPopup = true;\n\t } else {\n\t \tglobals.state.isOpenLocationPopup = false;\n\t }\n\n\t\tif (referalCode.value) {\n\t\t localStorage.setItem('referalCode', referalCode.value);\n\t\t}\n\n\t\tif (page.value) show.value = true\n\t});\n</script>\n\n<style lang=\"scss\">\n\t.fade-enter-active, .fade-leave-active {\n\t transition: opacity .5s;\n\t}\n\t.fade-enter, .fade-leave-to /* .fade-leave-active в версии 2.1.8+ */ {\n\t opacity: 0;\n\t}\n\n\t\n .fade-move,\n .fade-enter-active,\n .fade-leave-active {\n transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);\n }\n\n /* 2. declare enter from and leave to state */\n .fade-enter-from,\n .fade-leave-to {\n opacity: 0;\n transform: translate(30px, 0);\n }\n\n /* 3. ensure leaving items are taken out of layout flow so that moving\n animations can be calculated correctly. */\n .fade-leave-active {\n position: absolute;\n }\n\n.moveFromTop-enter-active,\n.moveFromTop-leave-active {\n transition: all 0.3s ease, max-height 0.2s ease;\n overflow: hidden;\n}\n\n.moveFromTop-enter-from,\n.moveFromTop-leave-to {\n transform: translateY(-1rem);\n opacity: 0;\n max-height: 0;\n}\n\n.moveFromTop-enter-to,\n.moveFromTop-leave-from {\n max-height: 100vh; \n}\n\n\t.moveFromTopAbsolute-enter-active,\n\t.moveFromTopAbsolute-leave-active {\n\t\ttransform: translateY(0);\n\t\topacity: 1;\n\t\ttransition: all 0.5s ease; \n\t\t\n\t}\n\t.moveFromTopAbsolute-enter-from,\n\t.moveFromTopAbsolute-leave-to {\n\t\tposition: absolute;\n\t\ttransform: translateY(-1rem);\n\t\topacity: 0;\n\t\ttransition: all 0.5s ease;\n\t}\n\t.ScaleOut-enter-active,\n\t.ScaleOut-leave-active {\n\t\topacity: 1;\n\t\ttransform: scale(1);\n\t\ttransition: all 0.3s ease; \n\t\t\n\t}\n\t.ScaleOut-enter-from,\n\t.ScaleOut-leave-to {\n\t\topacity: 0;\n\t\ttransform: scale(0.9);\n\t\ttransition: all 0.3s ease;\n\t}\n\t.slide-fade-enter-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-leave-active {\n\t\t// min-height: 100vh;\n\t transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);\n\t}\n\n\t.slide-fade-enter-from,\n\t.slide-fade-leave-to {\n\t\tmin-height: 0;\n\t transform: translateX(20px);\n\t opacity: 0;\n\t left: 0;\n\t top: 0;\n\t}\n\n\t.scaleTransition-5px-enter-active,\n .scaleTransition-5px-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.2s ease;\n }\n\n .scaleTransition-5px-enter-from,\n .scaleTransition-5px-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n transform: translateY(-30px); \n transition: all 0.2s ease;\n }\n\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleTransition-enter-active,\n .scaleTransition-leave-active {\n transform: translateY(0px); \n opacity: 1;\n z-index: 1;\n transition: all 0.5s ease;\n }\n .scaleTransition-enter-from,\n .scaleTransition-leave-to {\n opacity: 0;\n z-index: 0;\n position: absolute;\n width: inherit;\n height: inherit;\n display: block;\n transform: translateY(30px); \n transition: all 0.5s ease;\n }\n\n .scaleIn-enter-active,\n .scaleIn-leave-active {\n // background: red;\n transition: all 0.5s ease;\n > section,div { transform-origin: 0 0; transform: translateZ(0px); transition: all 0.5s ease; }\n }\n .scaleIn-enter-from,\n .scaleIn-leave-to {\n opacity: 0;\n transform: scale(0.95);\n > section,div { transform: translateZ(-30px); transition: all 0.5s ease; }\n }\n</style>"],"names":["globals.state"],"mappings":";;;;;;;;;;;;;;;;;;AAiLE,QAAI,OAAO,IAAI,KAAK;AAEpB,UAAM,OAAO,IAAI,IAAI;AAErB,UAAM,gBAAgB,IAAI,IAAI;AAG9B,aAAS,oBAAoB;AAC3B,oBAAc,QAAQ;AAAA,IAC1B;AAEE,aAAS,mBAAmB;AAC1B,oBAAc,QAAQ;AAAA,IAC1B;AAGE,aAAS,qBAAqB;AAAA,IAKhC;AAIC,UAAM,QAAQ,SAAQ;AAGtB,UAAM,cAAc,IAAI,MAAM,MAAM,WAAW;AAI/C,aAAS,qBAAqB;AAC5BA,YAAc,sBAAsB;AAAA,IACvC;AACC,aAAS,YAAW;AACnB,eAAS,eAAe,KAAK,EAAE,eAAgB;AAAA,IACjD;AAEC,UAAM,eAAe,IAAI,CAAC;AAE1B,UAAM,SAAS,IAAI,IAAI;AAEvB,UAAM,cAAc,SAAS,MAAM;AAClC,UAAI,aAAa,QAAQ,IAAI;AAC5B,eAAO,MAAM,KAAK,gBAAiB;AAAA,MACtC,OAAS;AACN,eAAO,MAAM,KAAK,gBAAgB;AAAA,MACrC;AAAA,IACE,CAAA;AAED,UAAM,eAAe,MAAM;AACzB,mBAAa,QAAQ,MAAM,OAAO;AAAA,IACnC;AAED,cAAU,YAAY;AAErB,UAAI,mBAAmB,WAAW;AAC/B,eAAO,iBAAiB,QAAQ,MAAM;AACpC,oBAAU,cAAc,SAAS,oBAAoB,EAAE,KAAK,kBAAgB;AAC1E,oBAAQ,IAAI,mBAAmB,YAAY;AAAA,UACpD,CAAQ,EAAE,MAAM,uBAAqB;AAC5B,oBAAQ,IAAI,4BAA4B,iBAAiB;AAAA,UAClE,CAAQ;AAAA,QACR,CAAK;AAAA,MACL;AAEE,YAAM,gBAAgB,aAAa,QAAQ,UAAU;AAEpD,UAAI,eAAe;AACjBA,cAAc,WAAW,KAAK,MAAM,aAAa;AAAA,MACtD,WAAc,MAAM,KAAK,UAAU;AAC/BA,cAAc,sBAAsB;AAAA,MACxC,OAAU;AACNA,cAAc,sBAAsB;AAAA,MACxC;AAEE,UAAI,YAAY,OAAO;AACrB,qBAAa,QAAQ,eAAe,YAAY,KAAK;AAAA,MACzD;AAEE,UAAI,KAAK,MAAO,MAAK,QAAQ;AAAA,IAC/B,CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -56,9 +56,9 @@ const _sfc_main = {
|
|
|
56
56
|
var _a;
|
|
57
57
|
return vue.openBlock(), vue.createElementBlock("header", {
|
|
58
58
|
id: "header",
|
|
59
|
-
class: vue.normalizeClass(["pd-thin gap-micro flex-justify-between flex-nowrap flex h-4r w-100 z-index-2 pos-relative pos-t-0 br-b br-solid
|
|
60
|
-
"t-black": __props.theme === "light",
|
|
61
|
-
"t-white": __props.theme === "dark"
|
|
59
|
+
class: vue.normalizeClass(["pd-thin gap-micro flex-justify-between flex-nowrap flex h-4r w-100 z-index-2 pos-relative pos-t-0 br-b br-solid", {
|
|
60
|
+
"t-black br-light": __props.theme === "light",
|
|
61
|
+
"t-white br-dark": __props.theme === "dark"
|
|
62
62
|
}])
|
|
63
63
|
}, [
|
|
64
64
|
vue.createElementVNode("div", _hoisted_1, [
|
|
@@ -143,8 +143,8 @@ const _sfc_main = {
|
|
|
143
143
|
}, 8, ["submit", "counter"]),
|
|
144
144
|
auth.state.user._id ? (vue.openBlock(), vue.createBlock(NotificationBadge.default, {
|
|
145
145
|
key: 1,
|
|
146
|
-
fill: "rgb(var(--black))"
|
|
147
|
-
})) : vue.createCommentVNode("", true),
|
|
146
|
+
fill: __props.theme === "light" ? "rgb(var(--black))" : "rgb(var(--white))"
|
|
147
|
+
}, null, 8, ["fill"])) : vue.createCommentVNode("", true),
|
|
148
148
|
vue.createVNode(Button.default, {
|
|
149
149
|
"aria-label": "profile",
|
|
150
150
|
class: "pd-zero bg-transp",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.vue.cjs","sources":["../../../../../../../../src/modules/globals/views/components/partials/Header.vue"],"sourcesContent":["<script setup=\"props\">\n\timport { computed, onMounted, toRefs, ref, inject } from 'vue'\n\n\timport { useRouter,useRoute } from 'vue-router'\n\timport { useI18n } from 'vue-i18n'\n\t\n\timport * as globals from '@martyrs/src/modules/globals/views/store/globals'\n\timport * as shopcart from '@martyrs/src/modules/orders/store/shopcart'\n\timport * as auth from '@martyrs/src/modules/auth/views/store/auth'\n\t\n\t// Globasls Component\n\n\timport NotificationBadge from '@martyrs/src/modules/notifications/components/elements/NotificationBadge.vue';\n\t// import Navigation from '@martyrs/src/modules/globals/views/components/partials/Navigation.vue'\n\t// Martyrs Component\n\timport Button from '@martyrs/src/components/Button/Button.vue'\n\timport Select from '@martyrs/src/components/Select/Select.vue'\n\timport Checkbox from '@martyrs/src/components/Checkbox/Checkbox.vue'\n\t// Icons module\n\timport IconShopcart from '@martyrs/src/modules/icons/entities/IconShopcart.vue'\n\timport IconProfile from '@martyrs/src/modules/icons/entities/IconProfile.vue'\n\timport IconSearch from '@martyrs/src/modules/icons/navigation/IconSearch.vue';\n\t// Props\n\tconst props = defineProps({\n theme: {\n \ttype: String,\n\t default: \"light\"\n },\n logotype: {\n\t type: Object\n\t },\n\t location: {\n\t type: Boolean,\n\t\t default: true\n\t },\n\t theme_switcher: {\n\t type: Boolean,\n\t\t default: true\n\t },\n });\n\t// Accessing state\n\tconst router = useRouter()\n\tconst route = useRoute()\n\t// Localization\n\tconst { t } = useI18n()\n\t// const search = computed(() => store.products.state.search)\n\n\tfunction openLocationPopup() {\n\t globals.state.isOpenLocationPopup = true;\n\t}\n\t/////////////////////////////\n\t// MOUNTED\n\t/////////////////////////////\n\tonMounted(() => {\n shopcart.actions.setShopcart()\n });\n</script>\n\n<template>\n\t<header \n\t\tid=\"header\" \n\t\tclass=\"\n\t\t\tpd-thin \n\t\t\tgap-micro\n\t\t\tflex-justify-between\n\t\t\tflex-nowrap\n\t\t\tflex\n\t\t\th-4r\n\t\t\tw-100\n\t\t\tz-index-2 \n\t\t\tpos-relative pos-t-0\n\t\t\tbr-b\n\t\t\tbr-solid\n\t\t\
|
|
1
|
+
{"version":3,"file":"Header.vue.cjs","sources":["../../../../../../../../src/modules/globals/views/components/partials/Header.vue"],"sourcesContent":["<script setup=\"props\">\n\timport { computed, onMounted, toRefs, ref, inject } from 'vue'\n\n\timport { useRouter,useRoute } from 'vue-router'\n\timport { useI18n } from 'vue-i18n'\n\t\n\timport * as globals from '@martyrs/src/modules/globals/views/store/globals'\n\timport * as shopcart from '@martyrs/src/modules/orders/store/shopcart'\n\timport * as auth from '@martyrs/src/modules/auth/views/store/auth'\n\t\n\t// Globasls Component\n\n\timport NotificationBadge from '@martyrs/src/modules/notifications/components/elements/NotificationBadge.vue';\n\t// import Navigation from '@martyrs/src/modules/globals/views/components/partials/Navigation.vue'\n\t// Martyrs Component\n\timport Button from '@martyrs/src/components/Button/Button.vue'\n\timport Select from '@martyrs/src/components/Select/Select.vue'\n\timport Checkbox from '@martyrs/src/components/Checkbox/Checkbox.vue'\n\t// Icons module\n\timport IconShopcart from '@martyrs/src/modules/icons/entities/IconShopcart.vue'\n\timport IconProfile from '@martyrs/src/modules/icons/entities/IconProfile.vue'\n\timport IconSearch from '@martyrs/src/modules/icons/navigation/IconSearch.vue';\n\t// Props\n\tconst props = defineProps({\n theme: {\n \ttype: String,\n\t default: \"light\"\n },\n logotype: {\n\t type: Object\n\t },\n\t location: {\n\t type: Boolean,\n\t\t default: true\n\t },\n\t theme_switcher: {\n\t type: Boolean,\n\t\t default: true\n\t },\n });\n\t// Accessing state\n\tconst router = useRouter()\n\tconst route = useRoute()\n\t// Localization\n\tconst { t } = useI18n()\n\t// const search = computed(() => store.products.state.search)\n\n\tfunction openLocationPopup() {\n\t globals.state.isOpenLocationPopup = true;\n\t}\n\t/////////////////////////////\n\t// MOUNTED\n\t/////////////////////////////\n\tonMounted(() => {\n shopcart.actions.setShopcart()\n });\n</script>\n\n<template>\n\t<header \n\t\tid=\"header\" \n\t\tclass=\"\n\t\t\tpd-thin \n\t\t\tgap-micro\n\t\t\tflex-justify-between\n\t\t\tflex-nowrap\n\t\t\tflex\n\t\t\th-4r\n\t\t\tw-100\n\t\t\tz-index-2 \n\t\t\tpos-relative pos-t-0\n\t\t\tbr-b\n\t\t\tbr-solid\n\t\t\"\n\t\t:class=\"{\n \t\t't-black br-light': theme === 'light',\n \t\t't-white br-dark': theme === 'dark' \n \t}\"\n\t>\n\t<div class=\"flex-nowrap flex-v-center flex-justify-start flex gap-micro \">\n\t\t<!-- MENU -->\n\t\t<button \n\t\t\taria-label=\"menu\"\n\t\t\t@click=\"() => globals.state.isOpenSidebar = !globals.state.isOpenSidebar\" \n\t\t\tclass=\"cursor-pointer menu-btn\"\n\t\t\t:class=\"{\n\t\t\t\t'menu-btn_active': globals.state.isOpenSidebar\n\t\t\t}\"\n\t\t>\n\t <span\n\t \tclass=\"no-events\"\n\t\t :class=\"{\n\t\t 'bg-black': theme === 'light',\n\t\t 'bg-white': theme === 'dark'\n\t\t }\"\n\t\t >\n\t\t <span class=\"menu-btn__before\" :class=\"{ 'bg-black': theme === 'light', 'bg-white': theme === 'dark' }\"></span>\n\t\t <span class=\"menu-btn__after\" :class=\"{ 'bg-black': theme === 'light', 'bg-white': theme === 'dark' }\"></span>\n\t\t </span>\n\t </button>\n\n\t\t<!-- LOGO -->\n\t\t<component\n\t\t\tv-if=\"logotype\"\n\t\t :is=\"logotype\"\n\t\t @click=\"router.push({ path: '/' })\" \n\t\t :theme=\"theme\"\n\t\t class=\"cursor-pointer\"\n\t\t/>\n\n\t\t<button\n\t\t\tv-if=\"location\"\n\t\t\taria-label=\"button_location\"\n \tclass=\"\n \t\tcursor-pointer\n \t\tbg-transp \n \t\tpd-l-micro pd-r-micro\n \t\tradius-extra \n \t\tuppercase \n \t\tt-semi\n \t\tbr-solid \n \t\tbr-2px \n \t\ttransition-linear\n \t\tt-nowrap\n \t\n \t\"\n \t:class=\"{\n \t\t'fill-black br-black t-black hover-bg-black hover-t-white hover-fill-white': theme === 'light',\n \t\t'fill-white br-white t-white hover-bg-white hover-t-black hover-fill-black': theme === 'dark' \n \t}\"\n \t@click=\"openLocationPopup()\"\n >\n \t<svg class=\"i-small\" :fill=\"'inherit'\" xmlns=\"http://www.w3.org/2000/svg\" width=\"50\" height=\"67\" viewBox=\"0 0 50 67\" fill=\"none\">\n\t\t\t <path d=\"M25 0C11.207 0 0 11.207 0 25C0 38.793 20.832 66.668 25 66.668C29.168 66.668 50 38.793 50 25C50 11.207 38.793 0 25 0ZM25 33.332C20.418 33.332 16.668 29.582 16.668 25C16.668 20.418 20.418 16.668 25 16.668C29.582 16.668 33.332 20.418 33.332 25C33.332 29.582 29.582 33.332 25 33.332Z\" :fill=\"'inherit'\"/>\n\t\t\t</svg>\n \t {{globals.state.position?.country ? globals.state.position.country : 'World'}}\n </button>\n </div>\n\n \t<slot></slot>\n\n\t<div class=\"flex-justify-end flex-v-center flex-nowrap flex gap-micro\">\n\t\t<Button \n\t\t\tv-if=\"router.hasRoute('Search')\"\n\t\t\taria-label=\"search\"\n\t\t\tclass=\"pd-zero bg-transp\"\n\t\t\t:submit=\"() => router.push({name: 'Search'})\"\n\t\t\t:showSucces=\"false\"\n\t\t\t:showLoader=\"false\"\n\t\t>\n\t\t\t<IconSearch \n\t\t\t\tclass=\"i-semi\"\n\t\t\t\t:fill=\"theme === 'light' ? 'rgb(var(--black))' : 'rgb(var(--white))'\" \n\t\t\t/>\n\t\t</Button>\n\t\n\t\t<Button\n\t\t\taria-label=\"shopcart\"\n\t\t\t:submit=\"a => shopcart.actions.toggleShopcart()\" \n\t\t\t:counter=\"shopcart.getters.cartTotalAmount\" \n\t\t\t:showSucces=\"false\"\n\t\t\t:showLoader=\"false\"\n\t\t\tclass=\"pd-zero mn-r-micro\"\n\t\t\t> \n\t\t\t<IconShopcart \n\t\t\t\tclass=\"i-semi\"\n\t\t\t\t:fill=\"theme === 'light' ? 'rgb(var(--black))' : 'rgb(var(--white))'\" \n\t\t\t/>\n\t\t\t<!-- <div class=\"w-max p-small pos-absolute pos-t-100 pos-r-0\">Product Added to Shopcart</div> -->\n\t\t</Button>\n\n\n\t\t<NotificationBadge\n\t\t\tv-if=\"auth.state.user._id\"\n\t\t\t:fill=\"theme === 'light' ? 'rgb(var(--black))' : 'rgb(var(--white))'\" \n\t\t/>\n\n\t\t<Button \n\t\t\taria-label=\"profile\"\n\t\t\tclass=\"pd-zero bg-transp\"\n\t\t\t:submit=\"\n\t\t\t\tauth.state.access.status === false \n\t\t\t\t? \n\t\t\t\ta => router.push({name: 'Sign In'}) \n\t\t\t\t: \n\t\t\t\ta => router.push({ name: 'User Profile', params: { _id: auth.state.user._id }})\n\t\t\t\"\n\t\t\t:showSucces=\"false\"\n\t\t\t:showLoader=\"false\"\n\t\t>\n\t\t\t<IconProfile \n\t\t\t\tclass=\"i-semi\"\n\t\t\t\t:fill=\"theme === 'light' ? 'rgb(var(--black))' : 'rgb(var(--white))'\" \n\t\t\t/>\n\t\t</Button>\n\n\n\n\t\t<Select \n\t\t\tv-if=\"$i18n.availableLocales.length > 1\"\n\t\t\tv-model:select=\"$i18n.locale\"\n\t\t :options=\"$i18n.availableLocales\"\n\t\t :property=\"'value'\"\n class=\"pos-relative uppercase pd-l-small pd-r-small pd-micro t-semi radius-thin\"\n :class=\"{\n \t\t'bg-light t-black': theme === 'light',\n \t\t'bg-dark t-white': theme === 'dark' \n \t}\"\n />\n </div>\n</header>\n \n</template>\n\n<style lang=\"scss\">\n.location-button { \n\t&:hover {\n\t\tbox-shadow: inset 0 0 0 2px rgb(var(--main));\n\t}\n}\n\n.menu-btn {\n display: block;\n width: 2rem;\n height: 2rem;\n border-radius: 50%;\n position: relative;\n}\n.menu-btn span,\n.menu-btn__before,\n.menu-btn__after {\n position: absolute;\n top: 50%;\n margin-top: -1px;\n left: 50%;\n margin-left: -10px;\n width: 20px;\n height: 2px;\n}\n.menu-btn__before,\n.menu-btn__after {\n display: block;\n transition: 0.2s;\n}\n.menu-btn__before {\n transform: translateY(-5px);\n}\n.menu-btn__after {\n transform: translateY(5px);\n}\n.menu-btn_active .menu-btn__before {\n transform: rotate(-35deg);\n width: 10px;\n transform-origin: left bottom;\n}\n.menu-btn_active .menu-btn__after {\n transform: rotate(35deg);\n width: 10px;\n transform-origin: left top;\n}\n\n.menu-btn_active span:before {\n transform: rotate(-35deg);\n width: 10px;\n transform-origin: left bottom;\n}\n.menu-btn_active span:after {\n transform: rotate(35deg);\n width: 10px;\n transform-origin: left top;\n}\n\n.menu-block {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.menu-nav {\n background-color: #fff;\n height: 50px;\n \n}\n.menu-nav__link {\n display: inline-block;\n text-decoration: none;\n color: #fff;\n margin-right: 20px;\n}\n.menu-nav__link {\n transition: 0.5s;\n transform-origin: right center;\n transform: translateX(50%);\n opacity: 0;\n}\n.menu-nav__link_active {\n transform: translateX(0%);\n opacity: 1;\n}\n\n</style>"],"names":["useRouter","useRoute","useI18n","globals.state","onMounted","shopcart.actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCC,UAAM,SAASA,UAAS,UAAA;AACVC,cAAQ,SAAA;AAEtB,UAAM,EAAE,EAAC,IAAKC,QAAO,QAAA;AAGrB,aAAS,oBAAoB;AAC3BC,cAAa,MAAC,sBAAsB;AAAA,IACvC;AAICC,QAAAA,UAAU,MAAM;AACbC,eAAAA,QAAiB,YAAW;AAAA,IAChC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -54,9 +54,9 @@ const _sfc_main = {
|
|
|
54
54
|
var _a;
|
|
55
55
|
return openBlock(), createElementBlock("header", {
|
|
56
56
|
id: "header",
|
|
57
|
-
class: normalizeClass(["pd-thin gap-micro flex-justify-between flex-nowrap flex h-4r w-100 z-index-2 pos-relative pos-t-0 br-b br-solid
|
|
58
|
-
"t-black": __props.theme === "light",
|
|
59
|
-
"t-white": __props.theme === "dark"
|
|
57
|
+
class: normalizeClass(["pd-thin gap-micro flex-justify-between flex-nowrap flex h-4r w-100 z-index-2 pos-relative pos-t-0 br-b br-solid", {
|
|
58
|
+
"t-black br-light": __props.theme === "light",
|
|
59
|
+
"t-white br-dark": __props.theme === "dark"
|
|
60
60
|
}])
|
|
61
61
|
}, [
|
|
62
62
|
createElementVNode("div", _hoisted_1, [
|
|
@@ -141,8 +141,8 @@ const _sfc_main = {
|
|
|
141
141
|
}, 8, ["submit", "counter"]),
|
|
142
142
|
state$1.user._id ? (openBlock(), createBlock(NotificationBadge, {
|
|
143
143
|
key: 1,
|
|
144
|
-
fill: "rgb(var(--black))"
|
|
145
|
-
})) : createCommentVNode("", true),
|
|
144
|
+
fill: __props.theme === "light" ? "rgb(var(--black))" : "rgb(var(--white))"
|
|
145
|
+
}, null, 8, ["fill"])) : createCommentVNode("", true),
|
|
146
146
|
createVNode(_sfc_main$1, {
|
|
147
147
|
"aria-label": "profile",
|
|
148
148
|
class: "pd-zero bg-transp",
|