107 lines
4.2 KiB
HTML
107 lines
4.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=0" />
|
|
<title>GoChat Widget</title>
|
|
<script vite-ignore src="/runtime-config.js"></script>
|
|
<script type="module">
|
|
(function () {
|
|
var cfg = 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: {},
|
|
},
|
|
cfg
|
|
);
|
|
window.globalConfig = Object.assign(
|
|
{
|
|
INSTALLATION_NAME: 'GoChat',
|
|
BRAND_NAME: 'GoChat',
|
|
CREATE_NEW_ACCOUNT_FROM_DASHBOARD: false,
|
|
DISPLAY_MANIFEST: false,
|
|
LOGO: '/brand-assets/logo.svg',
|
|
LOGO_DARK: '/brand-assets/logo_dark.svg',
|
|
LOGO_THUMBNAIL: '/brand-assets/logo_thumbnail.svg',
|
|
WIDGET_BRAND_URL: '/',
|
|
},
|
|
cfg.globalConfig || {}
|
|
);
|
|
window.errorLoggingConfig = '';
|
|
window.browserConfig = { browser_name: navigator.userAgent };
|
|
|
|
// Initialize widget channel config from URL params
|
|
(function() {
|
|
var params = new URLSearchParams(window.location.search);
|
|
var websiteToken = params.get('website_token');
|
|
var widgetToken = params.get('cw_conversation') || localStorage.getItem('cw_conversation');
|
|
if (!websiteToken) return;
|
|
window.chatwootWebChannel = {
|
|
websiteToken: websiteToken,
|
|
locale: params.get('locale') || 'zh_CN',
|
|
widgetColor: '#1f93ff',
|
|
enabledLanguages: window.chatwootConfig.enabledLanguages || [],
|
|
workingHours: [],
|
|
workingHoursEnabled: false,
|
|
utcOffset: '+08:00',
|
|
replyTime: 'in_a_few_minutes',
|
|
enabledFeatures: ['attachments', 'emoji', 'end_conversation'],
|
|
allowMessageAfterResolved: true,
|
|
preChatFormEnabled: false,
|
|
preChatFormOptions: {},
|
|
businessHoursEnabled: false,
|
|
offlineMessageEnabled: true,
|
|
hmacEnabled: false,
|
|
portal: null,
|
|
};
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('POST', '/api/v1/widget/config', true);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.onload = function() {
|
|
if (xhr.status === 200) {
|
|
try {
|
|
var config = JSON.parse(xhr.responseText);
|
|
var channel = config.website_channel_config || {};
|
|
window.authToken = channel.auth_token;
|
|
localStorage.setItem('cw_conversation', window.authToken);
|
|
window.chatwootPubsubToken = config.contact && config.contact.pubsub_token;
|
|
channel.widgetColor = channel.widget_color || window.chatwootWebChannel.widgetColor;
|
|
channel.websiteName = channel.website_name;
|
|
channel.welcomeTitle = channel.welcome_title;
|
|
channel.welcomeTagline = channel.welcome_tagline;
|
|
window.chatwootWebChannel = Object.assign(window.chatwootWebChannel, channel);
|
|
import('/app/javascript/entrypoints/widget.js');
|
|
} catch(e) {}
|
|
}
|
|
};
|
|
xhr.send(JSON.stringify({ website_token: websiteToken, widget_token: widgetToken }));
|
|
})();
|
|
})();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="app" class="h-full"></div>
|
|
<noscript id="noscript">This app works best with JavaScript enabled.</noscript>
|
|
</body>
|
|
</html>
|