mirror of
https://github.com/kokororin/typecho-plugin-Access.git
synced 2025-03-23 00:00:21 +08:00
前端暴露接口以支持pjax主题
This commit is contained in:
parent
0aa76d751e
commit
39d8429a93
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/Access_Bootstrap.php';
|
||||
|
||||
class Access_Action implements Widget_Interface_Do
|
||||
{
|
||||
|
||||
@ -10,8 +12,6 @@ class Access_Action implements Widget_Interface_Do
|
||||
{
|
||||
$this->response = Typecho_Response::getInstance();
|
||||
$this->request = Typecho_Request::getInstance();
|
||||
require_once __DIR__ . '/Access_Autoloader.php';
|
||||
Access_Autoloader::register();
|
||||
$this->access = new Access_Core();
|
||||
}
|
||||
|
||||
@ -27,7 +27,9 @@ class Access_Action implements Widget_Interface_Do
|
||||
{
|
||||
$image = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAQUAP8ALAAAAAABAAEAAAICRAEAOw==');
|
||||
$this->response->setContentType('image/gif');
|
||||
$this->access->writeLogs(null, $this->request->u, $this->request->cid, $this->request->mid);
|
||||
if ($this->access->config->writeType == 1) {
|
||||
$this->access->writeLogs(null, $this->request->u, $this->request->cid, $this->request->mid);
|
||||
}
|
||||
echo $image;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class Access_Plugin implements Typecho_Plugin_Interface
|
||||
'writeType', array(
|
||||
'0' => '后端',
|
||||
'1' => '前端',
|
||||
), '0', '日志写入类型:', '请选择日志写入类型,数据量大时(几万以上),后端写入可能会拖慢博客访问速度');
|
||||
), '0', '日志写入类型:', '请选择日志写入类型,如果写入速度较慢可选择前端写入日志。<br/>如果您使用了pjax,请在pjax相关事件中调用 window.Access.track() 方法。');
|
||||
$canAnalytize = new Typecho_Widget_Helper_Form_Element_Radio(
|
||||
'canAnalytize', array(
|
||||
'0' => '不允许',
|
||||
@ -197,8 +197,7 @@ class Access_Plugin implements Typecho_Plugin_Interface
|
||||
$index = rtrim(Helper::options()->index, '/');
|
||||
$access = new Access_Core();
|
||||
$parsedArchive = $access->parseArchive($archive);
|
||||
// TODO 兼容pjax
|
||||
echo "<script type=\"text/javascript\">(function(){var t=function(){var i=new Image();i.src='{$index}/access/log/track.gif?u='+location.pathname+location.search+location.hash+'&cid={$parsedArchive['content_id']}&mid={$parsedArchive['meta_id']}';};t();})();</script>";
|
||||
echo "<script type=\"text/javascript\">(function(w){var t=function(){var i=new Image();i.src='{$index}/access/log/track.gif?u='+location.pathname+location.search+location.hash+'&cid={$parsedArchive['content_id']}&mid={$parsedArchive['meta_id']}&rand='+new Date().getTime()};t();var a={};a.track=t;w.Access=a})(this);</script>";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user