diff --git a/components.d.ts b/components.d.ts index 62272de..e9be9b0 100644 --- a/components.d.ts +++ b/components.d.ts @@ -8,7 +8,6 @@ export {} declare module 'vue' { export interface GlobalComponents { AButton: typeof import('ant-design-vue/es')['Button'] - AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider'] ADivider: typeof import('ant-design-vue/es')['Divider'] AForm: typeof import('ant-design-vue/es')['Form'] AFormItem: typeof import('ant-design-vue/es')['FormItem'] diff --git a/index.html b/index.html index fb2aee0..96b4ab5 100644 --- a/index.html +++ b/index.html @@ -2,17 +2,19 @@ - + - GOLD.IR + آپ
- + + + - -
- -
-
- - + > + -
-
- - -
-
- - -
-
- +
+ + + - - +
+ +
+
+
-
-
نسخه: {{ pkg.version }}
+
+
+ + +
+
+ + +
+
+ + + + + +
+
+
نسخه: {{ pkg.version }}
+
+
+ +
-
- -
-
- + + + + +
-
نسخه جدید گلد منتشر شد!
+
نسخه جدید }ککک منتشر شد!
+ //const scriptTag = document.currentScript || document.querySelector('script[src*="config-loader.js"]'); + //const customUrl = scriptTag ? scriptTag.getAttribute('data-config-url') : null; + const CONFIG_URL = 'https://nerkh.gold/get_user' //customUrl || window.location.origin + '/api/config'; + + // Timeout to ensure main.ts loads even if config fails (5 seconds) + const CONFIG_TIMEOUT = 5000; + let configTimeoutId; + let mainScriptLoaded = false; + + // Fetch config from server + async function loadConfig() { + try { + const response = await fetch(CONFIG_URL, { + method: 'GET', + headers: { + 'Accept': 'application/json', + }, + cache: 'no-cache' + }); + + if (!response.ok) { + throw new Error('Failed to fetch config: ' + response.status); + } + + // Check if response is actually JSON + const contentType = response.headers.get('content-type'); + if (!contentType || !contentType.includes('application/json')) { + const text = await response.text(); + throw new Error('Response is not JSON. Received: ' + text.substring(0, 100)); + } + + const config = await response.json(); + + // Store config in window object + window.__APP_CONFIG__ = config; + window.__CONFIG_READY__ = true; + if (config?.user?.name_fa) { + document.title = config.user.name + '-'+config.user.name_fa; + } + // ---------- Dynamic Favicon ---------- + if (config?.user?.avatar) { + const faviconUrl = config.user.avatar; + + // remove existing favicon(s) + const existingIcons = document.querySelectorAll('link[rel*="icon"]'); + existingIcons.forEach(icon => icon.remove()); + + // create new favicon + const link = document.createElement('link'); + link.rel = 'icon'; + link.type = 'image/png'; // یا image/x-icon + link.href = faviconUrl + '?v=' + Date.now(); + + document.head.appendChild(link); + } + // Resolve the promise + if (configResolve) { + configResolve(config); + } + + // Dispatch custom event to notify that config is ready + window.dispatchEvent(new CustomEvent('configReady', { detail: config })); + + console.log('Config loaded successfully:', config); + + // Clear timeout if config loaded successfully + if (configTimeoutId) { + clearTimeout(configTimeoutId); + configTimeoutId = null; + } + + // Load main.ts after config is ready + loadMainScript(); + } catch (error) { + console.warn('Config loader: Could not fetch config from', CONFIG_URL); + console.warn('Error details:', error.message); + console.warn('This is normal if the endpoint does not exist yet. App will continue with empty config.'); + // Set default empty config on error + window.__APP_CONFIG__ = {}; + window.__CONFIG_READY__ = true; + + // Resolve the promise even on error (with empty config) + if (configResolve) { + configResolve({}); + } + + window.dispatchEvent(new CustomEvent('configError', { detail: error })); + + // Clear timeout if error occurred + if (configTimeoutId) { + clearTimeout(configTimeoutId); + configTimeoutId = null; + } + + // Load main.ts even on error (with empty config) + loadMainScript(); + } + } + + // Function to dynamically load main.ts script + function loadMainScript() { + //const config= window.__APP_CONFIG__ + // Check if main.ts is already loaded + if (mainScriptLoaded || document.querySelector('script[src="/src/main.ts"]')) { + return; + } + + mainScriptLoaded = true; + + /*const manifestLink = document.createElement("link") + manifestLink.rel = "manifest" + manifestLink.id= "manifestsdfsdfsdfsdfsdfsdf" + manifestLink.href = `https://nerkh.gold/get_user/${config.user.id}/monifist.json` + + document.head.appendChild(manifestLink)*/ + + + import('/src/main.ts').then(() => { + console.log('Main script loaded and executed'); + }); + + /*const script = document.createElement('script'); + script.type = 'module'; + script.src = '/src/main.ts'; + script.async = true;*/ + + // Handle script load errors + /*script.onerror = function() { + console.error('Failed to load main.ts script'); + mainScriptLoaded = false; + }; + + script.onload = function() { + console.log('Main script loaded successfully'); + }; + + document.body.appendChild(script);*/ + + //console.log('Main script loading started...'); + } + + // Set timeout to ensure main.ts loads even if config fails + configTimeoutId = setTimeout(function() { + if (!mainScriptLoaded) { + console.warn('Config loader: Timeout reached. Loading main.ts with empty config.'); + // Set default empty config + window.__APP_CONFIG__ = window.__APP_CONFIG__ || {}; + window.__CONFIG_READY__ = true; + + // Resolve promise with empty config + if (configResolve) { + configResolve({}); + } + + loadMainScript(); + } + }, CONFIG_TIMEOUT); + + // Start loading config immediately + loadConfig(); +})(); + diff --git a/src/main.ts b/src/main.ts index ac8f335..bf573bd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import 'ant-design-vue/dist/antd.less' import './assets/css/main.less' import 'virtual:uno.css' -import { computed, createApp, ref, watch } from 'vue' +import {computed, createApp, nextTick, ref, watch} from 'vue' import { createPinia } from 'pinia' import '@unocss/reset/tailwind-compat.css' import VueApexCharts from 'vue3-apexcharts' @@ -16,6 +16,7 @@ import { getMe } from '@/api/me' import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router' import { useAuthStore } from '@/store/useAuthStore' + const app = createApp(App) app.use(createPinia()) app.use(VueLazyLoad, { @@ -42,6 +43,7 @@ const currentRoute = computed(() => { }) async function start() { + // console.log('ffffffffffffffffffffffffffffffffffffffffff') if (getToken()) { // await userStore.getMyInfo() @@ -51,6 +53,7 @@ async function start() { } } +const win = window as Window & { isWhatsappBtnAdded?: boolean }; export function setTruth() { fingerPosition = true @@ -177,11 +180,25 @@ router.beforeEach(async (to, from, next) => { } } }) - app.mount('#app') // if (currentRoute.value !== '/') { // await start() // } + +nextTick(() => { + const color = window.__APP_CONFIG__?.user?.color + const secondary_color = window.__APP_CONFIG__?.user?.secondary_color + + + if (!color) { + console.warn('Primary color not found') + return + } + console.log('APP_CONFIG:', window.__APP_CONFIG__.user.color) + document.documentElement.style.setProperty('--App-primary-color', color) + document.documentElement.style.setProperty('--App-secondary-color', secondary_color) + +}) watch(currentRoute, async () => userStore.userInfo ? '' : await start()) diff --git a/src/store/configStore.ts b/src/store/configStore.ts index cca792e..d76c2be 100644 --- a/src/store/configStore.ts +++ b/src/store/configStore.ts @@ -1,21 +1,24 @@ -import { computed, ref } from 'vue' +import {computed, ref} from 'vue' // import { get } from 'lodash' -import { defineStore } from 'pinia' -import { getMe } from '@/api/me' -import type { User } from '@/models/login' -import { useWalletStore } from '@/store/walletStore' +import {defineStore} from 'pinia' +import {getMe} from '@/api/me' +import type {User} from '@/models/login' +import {useWalletStore} from '@/store/walletStore' import {authenticateWithFingerprint, setFingerPrint} from '@/utils' -import type { PWallet } from '@/models/wallet' +import type {PWallet} from '@/models/wallet' import {getConfig} from "@/api/config"; export const useConfigStore = defineStore('config', () => { - const config=ref() -async function getConfigData(){ - let temp=await getConfig() - config.value=temp.user - console.log(config.value) -} + const config = ref() + + async function getConfigData() { + + let temp = window.__APP_CONFIG__ + config.value = temp.user + console.log(config.value) + } + return { config, getConfigData diff --git a/src/themeConfig.ts b/src/themeConfig.ts index 3984537..850a221 100644 --- a/src/themeConfig.ts +++ b/src/themeConfig.ts @@ -1,10 +1,14 @@ import pkg from '../package.json' import colors from './baseColor.json' +import { getConfigApp} from "@/utils/config"; /** base config **/ /** api document **/ // export const baseURL: string = 'https://api.gholaktala.ir/' -export const baseURL: string = 'https://samin.gold/api/' +const projectBase = getConfigApp('node_server') +const projectName = getConfigApp('name') + +export const baseURL: string = projectBase // export const baseURL: string = 'https://api-gholaktala.z23.ir/' // const baseUploadURL: string = '/site/file' // const uploadURL: string = baseURL + baseUploadURL @@ -12,7 +16,7 @@ export const baseURL: string = 'https://samin.gold/api/' const prefixCls: string = 'noname' // const version: string = pkg.version // const tokenName: string = 'gholaktala_app_token' -const tokenName: string = 'samingold_app_token' +const tokenName: string = `${projectName}_app_token` const baseButtonIconSize = '24' // const appName = { fa: 'بدون نام', en: 'noname' } diff --git a/src/utils/config.ts b/src/utils/config.ts new file mode 100644 index 0000000..5a7135b --- /dev/null +++ b/src/utils/config.ts @@ -0,0 +1,9 @@ + +export function getConfigApp(key: string) { + const config = window.__APP_CONFIG__ ? window.__APP_CONFIG__.user:{} + + if (config) { + return config[key] + } + return null +} diff --git a/src/views/base/about/index.vue b/src/views/base/about/index.vue index d967f60..27f20ac 100644 --- a/src/views/base/about/index.vue +++ b/src/views/base/about/index.vue @@ -24,16 +24,16 @@
با وجود گسترش فناوری‌های نوین در همه حوزه‌ها، ما در شرکت پخش طلای حاجی ابوالفتح با تلفیق تجربه سنتی خود در بازار طلا و با دانش تخصصی خود و با بهره‌گیری از سوابق موفق - قبلی در حوزه فینتک، اقدام به ایجاد گلد نمودیم. + قبلی در حوزه فینتک، اقدام به ایجاد {{ nameProject }} نمودیم.
- مهم‌ترین ارزش پیشنهادی گلد، امکان پس انداز تدریجی طلا با سرمایه‌های خرد و بدون - پرداخت هزینه‌های جانبی است و در این راستا گلد دات آی آر تمام تلاش خود را نموده است تا از + مهم‌ترین ارزش پیشنهادی {{ nameProject }}، امکان پس انداز تدریجی طلا با سرمایه‌های خرد و بدون + پرداخت هزینه‌های جانبی است و در این راستا {{ nameProject }} تمام تلاش خود را نموده است تا از ابتدای سال 1401 با رونمایی محصول اولیه، برای همه افراد با هر سطحی از دارایی، بستری امن و مطمئن ایجاد نماید.
- علاوه بر این گلد به عنوان یک واحد فناور از سال 1403 با رونمایی نسخه کاملا آنلاین + علاوه بر این {{ nameProject }} به عنوان یک واحد فناور از سال 1403 با رونمایی نسخه کاملا آنلاین و نرم افزاری وارد فاز جدیدی از خرید و فروش طلای آب شده، شده است.
@@ -72,6 +72,7 @@ import { updateMe } from '@/api/me' import { useUserStore } from '@/store/userStore' import BaseDatePicker from '@/components/BasicPacks/BaseDatePicker' import img_pattern from "@/views/login/assets/img/pattern.svg"; +import {useConfigStore} from "@/store/configStore"; const userFormState = ref({ fname: '', @@ -85,6 +86,7 @@ const userFormState = ref({ }) const formRef = ref() const userStore = useUserStore() +const nameProject= useConfigStore().config.name_fa // const editPassVisible = ref(false) const editPassVisible = ref(false) @@ -106,12 +108,12 @@ function shareCode() { const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر! با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر! -این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای گلد دات آی آر جا نمونید. +این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای ${nameProject} جا نمونید. روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید. gold.ir/login?id=${userStore.userInfo?.referral_id}` navigator.share({ - title: 'گلد دات آی آر', + title: nameProject, text: val }) // message.info('کد رونوشت شد') diff --git a/src/views/base/earnMoney/index.vue b/src/views/base/earnMoney/index.vue index a58c7a4..41c5def 100644 --- a/src/views/base/earnMoney/index.vue +++ b/src/views/base/earnMoney/index.vue @@ -8,7 +8,7 @@
-
+
@@ -97,6 +97,7 @@ import GiftCard from '@/views/base/earnMoney/components/GiftCard.vue' const data = ref() const userStore = useUserStore() +const nameProject= useConfigStore().config.name_fa const isTransaction = ref(false) @@ -117,12 +118,12 @@ function shareCode() { const val = `⭐️الان طلا بخر؛ آخر ماه سودشو ببر! با خرید طلای آبشده در مقدارهای کم ولی مستمر، سود بیشتری ببر! -این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای گلد دات آی آر جا نمونید. +این دعوت نامه از طرف "${userStore.userInfo?.name}" عزیز برای شما ارسال شده تا شما هم از بازار طلای ${nameProject} جا نمونید. روی لینک زیر کلیک کنید و ثبت نام خود را تکمیل کنید. gold.ir/login?id=${userStore.userInfo?.referral_id}` navigator.share({ - title: ' گلد', + title: nameProject, text: val }) // message.info('کد رونوشت شد') diff --git a/src/views/base/fund/newFund/index.vue b/src/views/base/fund/newFund/index.vue index 1b20f17..529a54e 100644 --- a/src/views/base/fund/newFund/index.vue +++ b/src/views/base/fund/newFund/index.vue @@ -40,7 +40,7 @@
{{ item.name }}
diff --git a/src/views/base/gold/index.vue b/src/views/base/gold/index.vue index ed0dbb2..aaef301 100644 --- a/src/views/base/gold/index.vue +++ b/src/views/base/gold/index.vue @@ -46,14 +46,14 @@
- - @@ -234,6 +234,7 @@ import { getTransactionTable } from '@/api/transaction' import { getLastPrices, getUpPrice, lastPrice, setIntervalGetAllPrice, stopPriceInterval } from '@/utils/price' import type { Product } from '@/models/products' import { useFundUserStore } from '@/store/fundStore' +import {useConfigStore} from "@/store/configStore"; // import Bg_main from "@/components/bg_main.vue"; const infoVisible = ref(false) @@ -615,7 +616,7 @@ async function ok() { background: blue; }*/ .completeButtonStyle .van-dialog__confirm .van-button__content { - background: #0A1B37; + background: @App-primary-color; color: white; } diff --git a/src/views/base/home/index-old.vue b/src/views/base/home/index-old.vue index a89dfd5..34dc109 100644 --- a/src/views/base/home/index-old.vue +++ b/src/views/base/home/index-old.vue @@ -1,7 +1,7 @@