Add redirect to sub official for wechat (#132)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
e453968abe
commit
0874e193d8
8 files changed
+62
-6
No files matched your search
@@ -4,7 +4,8 @@ import { getLocale } from '@/i18n';
|
||||
import store from '@/store';
|
||||
import { IToken } from '@/models';
|
||||
import psl from 'psl';
|
||||
import { LOCALE_CURRENCY_MAPPING } from '@/constants';
|
||||
import { BASE_HOST_HUB, LOCALE_CURRENCY_MAPPING } from '@/constants';
|
||||
import { isOfficial, isSubOfficial, isWechatBrowser } from './is';
|
||||
|
||||
export const getDomain = (host: string = window.location.hostname) => {
|
||||
const parsed = psl.parse(host);
|
||||
@@ -202,3 +203,14 @@ export const initializeExchangeRate = async () => {
|
||||
console.debug('initialize exchange rate', payload);
|
||||
await store.dispatch('getExchangeRate', payload);
|
||||
};
|
||||
|
||||
export const initializeRedirect = async () => {
|
||||
if (isOfficial() && !isSubOfficial() && isWechatBrowser()) {
|
||||
console.debug('redirect to sub domain with prefix');
|
||||
// redirect from hub.acedata.cloud to dynamic date like 20240802.hub.acedata.cloud
|
||||
const date = new Date().toISOString().split('T')[0].replace(/-/g, '');
|
||||
const newUrl = window.location.href.replace(BASE_HOST_HUB, `${date}.${BASE_HOST_HUB}`);
|
||||
console.debug('redirect to', newUrl);
|
||||
window.location.href = newUrl;
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user