61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
const config = window.__GOCHAT_CONFIG__ || {};
|
|
|
|
window.chatwootConfig = Object.assign(
|
|
{
|
|
hostURL: '',
|
|
helpCenterURL: '',
|
|
fbAppId: '',
|
|
instagramAppId: '',
|
|
tiktokAppId: '',
|
|
googleOAuthClientId: '',
|
|
googleOAuthCallbackUrl: '',
|
|
allowedLoginMethods: ['email'],
|
|
fbApiVersion: '',
|
|
whatsappAppId: '',
|
|
whatsappConfigurationId: '',
|
|
whatsappApiVersion: '',
|
|
signupEnabled: 'false',
|
|
isMfaEnabled: 'false',
|
|
inboxEventsEnabled: 'false',
|
|
selectedLocale: 'zh_CN',
|
|
enabledLanguages: [
|
|
{ name: '中文', iso_639_1_code: 'zh_CN' },
|
|
{ name: 'English', iso_639_1_code: 'en' },
|
|
],
|
|
helpUrls: {},
|
|
},
|
|
config
|
|
);
|
|
window.globalConfig = Object.assign(
|
|
{
|
|
INSTALLATION_NAME: 'GoChat',
|
|
CREATE_NEW_ACCOUNT_FROM_DASHBOARD: false,
|
|
DISPLAY_MANIFEST: false,
|
|
LOGO_THUMBNAIL: '/favicon-32x32.png',
|
|
},
|
|
config.globalConfig || {}
|
|
);
|
|
window.errorLoggingConfig = '';
|
|
window.browserConfig = { browser_name: navigator.userAgent };
|
|
|
|
try {
|
|
const sessionCookie = document.cookie
|
|
.split('; ')
|
|
.find(cookie => cookie.startsWith('cw_d_session_info='));
|
|
if (sessionCookie) {
|
|
const raw = decodeURIComponent(sessionCookie.split('=').slice(1).join('='));
|
|
const extract = key =>
|
|
raw.match(new RegExp(`"${key}":"([^"]+)"`))?.[1] || '';
|
|
const token = extract('access-token');
|
|
if (token) {
|
|
localStorage.setItem('access-token', token);
|
|
localStorage.setItem('client', extract('client'));
|
|
localStorage.setItem('uid', extract('uid'));
|
|
localStorage.setItem('token-type', extract('token-type') || 'Bearer');
|
|
localStorage.setItem('expiry', extract('expiry'));
|
|
}
|
|
}
|
|
} catch {
|
|
// Ignore malformed legacy session cookies.
|
|
}
|