* add web client entry button to bottom navbar in index page.

This commit is contained in:
Hao Sun
2021-11-26 15:03:18 +08:00
parent 8632e63341
commit 84092dcc2c
3 changed files with 43 additions and 0 deletions
@@ -15,6 +15,24 @@ class myIndex extends index
{
$this->view->pageBodyClass = 'xxc-embed';
}
else
{
$this->loadModel('im');
$xuanConfig = new stdclass();
$token = $this->im->userGetAuthToken($this->app->user->id, 'zentaoweb');
$clientUrl = isset($this->config->webClientUrl) ? $this->config->webClientUrl : 'data/xuanxuan/web/';
$xuanConfig->clientUrl = $clientUrl;
$xuanConfig->server = $this->im->getServer('zentao');
$xuanConfig->account = $this->app->user->account;
$xuanConfig->authKey = $token->token;
$xuanConfig->debug = $this->config->debug;
$xuanConfig->serverTime = (int)(microtime(true) * 1000);
$xuanConfig->serverNowTime = (int)round(time() / $tokenAuthWindow);
$this->view->xuanConfig = $xuanConfig;
}
return parent::index($open);
}
@@ -30,3 +30,23 @@ $(function()
});
</script>
<?php endif; ?>
<?php if(isset($xuanConfig)): ?>
<style>
#chatBtn {padding: 3px;}
#chatBtn .icon {font-size: 24px;}
</style>
<?php js::import($webRoot . 'data/xuanxuan/sdk/sdk.min.js'); ?>
<?php js::import($jsRoot . 'md5.js'); ?>
<?php js::set('xuanConfig', $xuanConfig); ?>
<script>
function showXuanClient()
{
window.xuan.show();
}
var $chatBtn = $('<a href="javascript:void(0)" id="chatBtn" class="btn btn-link"><i class="text-primary icon icon-chat"></i></a>');
$chatBtn.insertBefore('#globalSearchDiv').on('click', showXuanClient);
window.xuan = new Xuanxuan($.extend(xuanConfig, {preload: true}));
</script>
<?php endif; ?>
File diff suppressed because one or more lines are too long