1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 13:51:37 +08:00

1.优化boostrap

2.优化logger
3.优化contact
This commit is contained in:
xiaochong0302 2024-12-16 20:27:40 +08:00
parent 56d7ddc7d4
commit f91118c45d
7 changed files with 17 additions and 39 deletions

View File

@ -38,11 +38,11 @@
{% endif %}
{% if contact_info.weibo %}
{% set link_url = 'https://weibo.com/u/%s'|format(contact_info.weibo) %}
<a class="weibo" href="{{ link_url }}" title="微博主页"><span class="iconfont icon-weibo"></span></a>
<a class="weibo" href="{{ link_url }}" title="微博主页" target="_blank"><span class="iconfont icon-weibo"></span></a>
{% endif %}
{% if contact_info.zhihu %}
{% set link_url = 'https://www.zhihu.com/people/%s'|format(contact_info.zhihu) %}
<a class="zhihu" href="{{ link_url }}" title="知乎主页"><span class="iconfont icon-zhihu"></span></a>
<a class="zhihu" href="{{ link_url }}" title="知乎主页" target="_blank"><span class="iconfont icon-zhihu"></span></a>
{% endif %}
{% if contact_info.email %}
{% set link_url = 'mailto:%s'|format(contact_info.email) %}
@ -53,7 +53,7 @@
{% endif %}
{% if contact_info.address %}
{% set link_url = 'https://map.baidu.com/search/%s?querytype=s&wd=%s'|format(contact_info.address,contact_info.address) %}
<a class="location" href="{{ link_url }}" title="联系地址:{{ contact_info.address }}"><span class="iconfont icon-location"></span></a>
<a class="location" href="{{ link_url }}" title="联系地址:{{ contact_info.address }}" target="_blank"><span class="iconfont icon-location"></span></a>
{% endif %}
</div>
{% endif %}

View File

@ -70,7 +70,7 @@ class CsrfToken
*/
$config = Di::getDefault()->getShared('config');
$lifetime = $config->path('csrf_token.lifetime') ?: $this->lifetime;
$lifetime = $config->path('csrf_token.lifetime', $this->lifetime);
return $lifetime + time();
}

View File

@ -19,15 +19,13 @@ class Logger
* @param string $channel
* @return FileLogger
*/
public function getInstance($channel = null)
public function getInstance($channel = 'common')
{
/**
* @var Config $config
*/
$config = Di::getDefault()->getShared('config');
$channel = $channel ? $channel : 'common';
$filename = sprintf('%s-%s.log', $channel, date('Y-m-d'));
$path = log_path($filename);

View File

@ -9,7 +9,6 @@ namespace App\Services\Logic\Chapter;
use App\Models\Chapter as ChapterModel;
use App\Models\ChapterUser as ChapterUserModel;
use App\Models\CourseUser as CourseUserModel;
use App\Models\User as UserModel;
use App\Repos\ChapterUser as ChapterUserRepo;
@ -37,9 +36,6 @@ trait ChapterUserTrait
$chapterUser = null;
/**
* @var CourseUserModel $courseUser
*/
$courseUser = $this->courseUser;
if ($courseUser) {

View File

@ -31,10 +31,9 @@ class ConsoleKernel extends Kernel
$this->loader = new Loader();
$this->initAppEnv();
$this->initAppConfig();
$this->initAppSetting();
$this->registerLoaders();
$this->registerServices();
$this->registerSettings();
$this->registerErrorHandler();
}

View File

@ -40,11 +40,10 @@ class HttpKernel extends Kernel
$this->loader = new Loader();
$this->initAppEnv();
$this->initAppConfig();
$this->initAppSetting();
$this->registerLoaders();
$this->registerServices();
$this->registerModules();
$this->registerSettings();
$this->registerErrorHandler();
}

View File

@ -8,6 +8,7 @@
namespace Bootstrap;
use Phalcon\Application;
use Phalcon\Config;
use Phalcon\Di;
use Phalcon\Loader;
@ -29,36 +30,21 @@ abstract class Kernel
*/
protected $loader;
/**
* @var array
*/
protected $config = [];
public function getApp()
{
return $this->app;
}
public function getDI()
{
return $this->di;
}
protected function initAppEnv()
{
require __DIR__ . '/Helper.php';
}
protected function initAppConfig()
protected function registerSettings()
{
$this->config = require config_path('config.php');
}
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
protected function initAppSetting()
{
ini_set('date.timezone', $this->config['timezone']);
ini_set('date.timezone', $config->get('timezone'));
if ($this->config['env'] == ENV_DEV) {
if ($config->get('env') == ENV_DEV) {
ini_set('display_errors', 1);
error_reporting(E_ALL);
} else {