1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-22 11:41:27 +08:00

优化代码

This commit is contained in:
xiaochong0302 2020-08-28 20:30:24 +08:00
parent 1faf364d54
commit 737ca424d0
18 changed files with 802 additions and 613 deletions

View File

@ -2,36 +2,127 @@
namespace App\Console\Tasks;
use App\Library\Cache\Backend\Redis as RedisCache;
use Phalcon\Cli\Task;
use Phalcon\Config;
class MaintainTask extends Task
{
public function mainAction()
{
$this->resetAnnotationAction();
$this->resetMetadataAction();
$this->resetVoltAction();
}
public function resetAnnotationsAction()
/**
* 重置注解
*
* @command: php console.php maintain reset_annotation
*/
public function resetAnnotationAction()
{
$dir = cache_path('annotations');
$config = $this->getConfig();
$cache = $this->getCache();
$redis = $cache->getRedis();
$dbIndex = $config->path('annotation.db');
$statsKey = $config->path('annotation.statsKey');
$redis->select($dbIndex);
$keys = $redis->sMembers($statsKey);
echo "start reset annotation..." . PHP_EOL;
if (count($keys) > 0) {
$keys = $this->handleKeys($keys);
$redis->del(...$keys);
$redis->del($statsKey);
}
echo "end reset annotation..." . PHP_EOL;
}
/**
* 重置元数据
*
* @command: php console.php maintain reset_metadata
*/
public function resetMetadataAction()
{
$config = $this->getConfig();
$cache = $this->getCache();
$redis = $cache->getRedis();
$dbIndex = $config->path('metadata.db');
$statsKey = $config->path('metadata.statsKey');
$redis->select($dbIndex);
$keys = $redis->sMembers($statsKey);
echo "start reset metadata..." . PHP_EOL;
if (count($keys) > 0) {
$keys = $this->handleKeys($keys);
$redis->del(...$keys);
$redis->del($statsKey);
}
echo "start reset metadata..." . PHP_EOL;
}
/**
* 重置模板
*
* @command: php console.php maintain reset_volt
*/
public function resetVoltAction()
{
echo "start reset volt..." . PHP_EOL;
$dir = cache_path('volt');
foreach (scandir($dir) as $file) {
if (strpos($file, '.php')) {
unlink($dir . '/' . $file);
}
}
echo "end reset volt..." . PHP_EOL;
}
public function resetModelsMetaDataAction()
protected function getConfig()
{
$dir = cache_path('metadata');
/**
* @var Config $config
*/
$config = $this->getDI()->get('config');
foreach (scandir($dir) as $file) {
if (strpos($file, '.php')) {
unlink($dir . '/' . $file);
}
}
return $config;
}
protected function getCache()
{
/**
* @var RedisCache $cache
*/
$cache = $this->getDI()->get('cache');
return $cache;
}
protected function handleKeys($keys)
{
return array_map(function ($key) {
return "_PHCR{$key}";
}, $keys);
}
}

View File

@ -4,11 +4,11 @@
<ul class="layui-nav">
{% for nav in navs.top %}
<li class="layui-nav-item">
<a href="{{ nav.url }}" target="{{ nav.target }}">{{ nav.name }}</a>
<a href="{{ nav.url }}" class="nav-{{ nav.id }}" target="{{ nav.target }}">{{ nav.name }}</a>
{% if nav.children %}
<dl class="layui-nav-child">
{% for child in nav.children %}
<dd><a href="{{ child.url }}" target="{{ child.target }}">{{ child.name }}</a></dd>
<dd><a href="{{ child.url }}" class="nav-{{ child.id }}" target="{{ child.target }}">{{ child.name }}</a></dd>
{% endfor %}
</dl>
{% endif %}
@ -24,10 +24,13 @@
<div class="user layui-layout-right">
<ul class="layui-nav">
<li class="layui-nav-item">
<a href="javascript:" class="kg-search" data-type="{{ s_type }}" data-query="{{ s_query }}" data-url="{{ s_url }}"><i class="layui-icon layui-icon-search"></i> 搜索</a>
<a href="javascript:" class="nav-search" data-type="{{ s_type }}" data-query="{{ s_query }}" data-url="{{ s_url }}"><i class="layui-icon layui-icon-search"></i> 搜索</a>
</li>
<li class="layui-nav-item">
<a href="{{ url({'for':'desktop.im.index'}) }}" target="im">微聊<span class="layui-badge-dot"></span></a>
<a href="{{ url({'for':'desktop.vip.index'}) }}" class="nav-vip" target="vip"><i class="layui-icon layui-icon-diamond"></i> 会员</a>
</li>
<li class="layui-nav-item">
<a href="{{ url({'for':'desktop.im.index'}) }}" class="nav-im" target="im"><i class="layui-icon layui-icon-chat"></i> 微聊</a>
</li>
{% if auth_user.id > 0 %}
<li class="layui-nav-item">

View File

@ -2,8 +2,8 @@
namespace App\Providers;
use Phalcon\Annotations\Adapter\Files as FileAnnotations;
use Phalcon\Annotations\Adapter\Memory as MemoryAnnotations;
use Phalcon\Annotations\Adapter\Redis as RedisAnnotations;
class Annotation extends Provider
{
@ -19,8 +19,13 @@ class Annotation extends Provider
if ($config->env == ENV_DEV) {
$annotations = new MemoryAnnotations();
} else {
$annotations = new FileAnnotations([
'annotationsDir' => cache_path() . '/annotations/',
$annotations = new RedisAnnotations([
'host' => $config->redis->host,
'port' => $config->redis->port,
'auth' => $config->redis->auth,
'index' => $config->annotation->db,
'lifetime' => $config->annotation->lifetime,
'statsKey' => $config->annotation->statsKey,
]);
}

View File

@ -4,6 +4,7 @@ namespace App\Providers;
use App\Library\Cache\Backend\Redis as RedisBackend;
use Phalcon\Cache\Frontend\Igbinary as IgbinaryFrontend;
use Phalcon\Config;
class Cache extends Provider
{
@ -12,19 +13,22 @@ class Cache extends Provider
public function register()
{
$this->di->setShared($this->serviceName, function () {
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
$config = $this->getShared('config');
$this->di->setShared($this->serviceName, function () use ($config) {
$frontend = new IgbinaryFrontend([
'lifetime' => $config->cache->lifetime,
'lifetime' => $config->path('cache.lifetime'),
]);
return new RedisBackend($frontend, [
'host' => $config->redis->host,
'port' => $config->redis->port,
'auth' => $config->redis->auth,
'index' => $config->cache->db,
'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'),
'index' => $config->path('cache.db'),
]);
});
}

View File

@ -2,7 +2,8 @@
namespace App\Providers;
use Phalcon\Crypt as PhalconCrypt;
use Phalcon\Config;
use Phalcon\Crypt as PhCrypt;
class Crypt extends Provider
{
@ -11,13 +12,16 @@ class Crypt extends Provider
public function register()
{
$this->di->setShared($this->serviceName, function () {
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
$config = $this->getShared('config');
$this->di->setShared($this->serviceName, function () use ($config) {
$crypt = new PhalconCrypt();
$crypt = new PhCrypt();
$crypt->setKey($config->key);
$crypt->setKey($config->get('key'));
return $crypt;
});

View File

@ -2,6 +2,7 @@
namespace App\Providers;
use Phalcon\Config;
use Phalcon\Db\Adapter\Pdo\Mysql as MySqlAdapter;
class Database extends Provider
@ -11,17 +12,20 @@ class Database extends Provider
public function register()
{
$this->di->setShared($this->serviceName, function () {
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
$config = $this->getShared('config');
$this->di->setShared($this->serviceName, function () use ($config) {
$options = [
'host' => $config->db->host,
'port' => $config->db->port,
'dbname' => $config->db->dbname,
'username' => $config->db->username,
'password' => $config->db->password,
'charset' => $config->db->charset,
'host' => $config->path('db.host'),
'port' => $config->path('db.port'),
'dbname' => $config->path('db.dbname'),
'username' => $config->path('db.username'),
'password' => $config->path('db.password'),
'charset' => $config->path('db.charset'),
'options' => [
\PDO::ATTR_EMULATE_PREPARES => false,
\PDO::ATTR_STRINGIFY_FETCHES => false,
@ -30,7 +34,7 @@ class Database extends Provider
$connection = new MySqlAdapter($options);
if ($config->env == ENV_DEV) {
if ($config->get('env') == ENV_DEV) {
$connection->setEventsManager($this->getEventsManager());
}

View File

@ -2,8 +2,9 @@
namespace App\Providers;
use Phalcon\Mvc\Model\MetaData\Files as FileMetaData;
use Phalcon\Config;
use Phalcon\Mvc\Model\MetaData\Memory as MemoryMetaData;
use Phalcon\Mvc\Model\MetaData\Redis as RedisMetaData;
class MetaData extends Provider
{
@ -12,15 +13,23 @@ class MetaData extends Provider
public function register()
{
$this->di->setShared($this->serviceName, function () {
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
$config = $this->getShared('config');
$this->di->setShared($this->serviceName, function () use ($config) {
if ($config->env == ENV_DEV) {
if ($config->get('env') == ENV_DEV) {
$metaData = new MemoryMetaData();
} else {
$metaData = new FileMetaData([
'metaDataDir' => cache_path() . '/metadata/',
$metaData = new RedisMetaData([
'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'),
'index' => $config->path('metadata.db'),
'statsKey' => $config->path('metadata.statsKey'),
'lifetime' => $config->path('metadata.lifetime'),
]);
}

View File

@ -2,6 +2,7 @@
namespace App\Providers;
use Phalcon\Config;
use Phalcon\Session\Adapter\Redis as RedisSession;
class Session extends Provider
@ -11,16 +12,19 @@ class Session extends Provider
public function register()
{
$this->di->setShared($this->serviceName, function () {
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
$config = $this->getShared('config');
$this->di->setShared($this->serviceName, function () use ($config) {
$session = new RedisSession([
'host' => $config->redis->host,
'port' => $config->redis->port,
'auth' => $config->redis->auth,
'index' => $config->session->db,
'lifetime' => $config->session->lifetime,
'host' => $config->path('redis.host'),
'port' => $config->path('redis.port'),
'auth' => $config->path('redis.auth'),
'index' => $config->path('session.db'),
'lifetime' => $config->path('session.lifetime'),
]);
$session->start();

View File

@ -2,7 +2,8 @@
namespace App\Providers;
use Phalcon\Mvc\Url as UrlResolver;
use Phalcon\Config;
use Phalcon\Mvc\Url as PhUrl;
class Url extends Provider
{
@ -11,14 +12,17 @@ class Url extends Provider
public function register()
{
$this->di->setShared($this->serviceName, function() {
/**
* @var Config $config
*/
$config = $this->di->getShared('config');
$config = $this->getShared('config');
$this->di->setShared($this->serviceName, function () use ($config) {
$url = new UrlResolver();
$url = new PhUrl();
$url->setBaseUri($config->base_uri);
$url->setStaticBaseUri($config->static_base_uri);
$url->setBaseUri($config->get('base_uri'));
$url->setStaticBaseUri($config->get('static_base_uri'));
return $url;
});

View File

@ -2,7 +2,7 @@
namespace App\Providers;
use Phalcon\Mvc\View\Engine\Volt as PhalconVolt;
use Phalcon\Mvc\View\Engine\Volt as PhVolt;
class Volt extends Provider
{
@ -13,7 +13,7 @@ class Volt extends Provider
{
$this->di->setShared('volt', function ($view, $di) {
$volt = new PhalconVolt($view, $di);
$volt = new PhVolt($view, $di);
$volt->setOptions([
'compiledPath' => cache_path() . '/volt/',

View File

@ -14,6 +14,7 @@ use App\Providers\Provider as AppProvider;
use Phalcon\Cli\Console;
use Phalcon\Di\FactoryDefault\Cli;
use Phalcon\Loader;
use Phalcon\Text;
class ConsoleKernel extends Kernel
{
@ -48,9 +49,9 @@ class ConsoleKernel extends Kernel
foreach ($_SERVER['argv'] as $k => $arg) {
if ($k == 1) {
$options['task'] = $arg;
$options['task'] = $this->handleTaskName($arg);
} elseif ($k == 2) {
$options['action'] = $arg;
$options['action'] = $this->handleActionName($arg);
} elseif ($k >= 3) {
$options['params'][] = $arg;
}
@ -80,8 +81,8 @@ class ConsoleKernel extends Kernel
protected function registerServices()
{
$providers = [
CacheProvider::class,
ConfigProvider::class,
CacheProvider::class,
CryptProvider::class,
DatabaseProvider::class,
EventsManagerProvider::class,
@ -106,4 +107,16 @@ class ConsoleKernel extends Kernel
return new ConsoleErrorHandler();
}
protected function handleTaskName($name)
{
return Text::uncamelize($name);
}
protected function handleActionName($name)
{
$name = Text::uncamelize($name);
return lcfirst(Text::camelize($name));
}
}

View File

@ -67,10 +67,10 @@ class HttpKernel extends Kernel
protected function registerServices()
{
$providers = [
ConfigProvider::class,
AnnotationProvider::class,
CacheProvider::class,
CookieProvider::class,
ConfigProvider::class,
CryptProvider::class,
CsrfTokenProvider::class,
DatabaseProvider::class,

View File

@ -8,7 +8,7 @@ $config = [];
$config['env'] = 'pro';
/**
* 加解密钥
* 密钥
*/
$config['key'] = 'mlq7jQ1Py8kTdW9m';
@ -83,27 +83,37 @@ $config['redis']['port'] = 6379;
$config['redis']['auth'] = '1qaz2wsx3edc';
/**
* 缓存所用redis库编号
* redis库编号
*/
$config['cache']['db'] = 0;
/**
* 缓存有效期(秒)
* 有效期(秒)
*/
$config['cache']['lifetime'] = 2 * 3600;
/**
* 会话所用redis库编号
* redis库编号
*/
$config['session']['db'] = 0;
/**
* 会话有效期(秒)
* 有效期(秒)
*/
$config['session']['lifetime'] = 24 * 3600;
/**
* 加密密钥
* redis库编号
*/
$config['metadata']['db'] = 2;
/**
* 有效期(秒)
*/
$config['metadata']['lifetime'] = 7 * 86400;
/**
* 密钥
*/
$config['jwt']['key'] = 'fu6ckEc8pv8k5K7m';
@ -123,7 +133,7 @@ $config['jwt']['leeway'] = 30;
$config['throttle']['enabled'] = true;
/**
* 限流有效期(秒)
* 有效期(秒)
*/
$config['throttle']['lifetime'] = 60;
@ -142,13 +152,4 @@ $config['websocket']['url'] = 'ws://127.0.0.1:8282';
*/
$config['websocket']['register_address'] = '127.0.0.1:1238';
/**
* 同步器设置
*/
$config['syncer']['recount_course'] = false;
$config['syncer']['recount_chapter'] = false;
$config['syncer']['recount_consult'] = false;
$config['syncer']['recount_review'] = false;
$config['syncer']['recount_comment'] = false;
return $config;

View File

@ -9,518 +9,433 @@ final class InsertSettingData extends AbstractMigration
public function up()
{
$rows = array(
0 =>
array(
'section' => 'captcha',
'item_key' => 'app_id',
'item_value' => '',
),
1 =>
array(
'section' => 'captcha',
'item_key' => 'secret_key',
'item_value' => '',
),
2 =>
array(
'section' => 'captcha',
'item_key' => 'enabled',
'item_value' => '0',
),
3 =>
array(
'section' => 'im.cs',
'item_key' => 'user1_id',
'item_value' => '',
),
4 =>
array(
'section' => 'im.cs',
'item_key' => 'enabled',
'item_value' => '0',
),
5 =>
array(
'section' => 'im.cs',
'item_key' => 'user3_id',
'item_value' => '',
),
6 =>
array(
'section' => 'im.cs',
'item_key' => 'user2_id',
'item_value' => '',
),
7 =>
array(
'section' => 'im.main',
'item_key' => 'msg_max_length',
'item_value' => '1000',
),
8 =>
array(
'section' => 'im.main',
'item_key' => 'title',
'item_value' => '菜鸟驿站',
),
9 =>
array(
'section' => 'im.main',
'item_key' => 'upload_img_enabled',
'item_value' => '0',
),
10 =>
array(
'section' => 'im.main',
'item_key' => 'upload_file_enabled',
'item_value' => '0',
),
11 =>
array(
'section' => 'im.main',
'item_key' => 'tool_audio_enabled',
'item_value' => '0',
),
12 =>
array(
'section' => 'im.main',
'item_key' => 'tool_video_enabled',
'item_value' => '0',
),
13 =>
array(
'section' => 'live',
'item_key' => 'push_domain',
'item_value' => 'push.abc.com',
),
14 =>
array(
'section' => 'live',
'item_key' => 'pull_trans_template',
'item_value' => '{"fd":{"id":"fd","bit_rate":"500","summary":"流畅","height":"540"},"sd":{"id":"sd","bit_rate":"1000","summary":"标清","height":"720"},"hd":{"id":"hd","bit_rate":"2000","summary":"高清","height":"1080"}}',
),
15 =>
array(
'section' => 'live',
'item_key' => 'pull_trans_enabled',
'item_value' => '1',
),
16 =>
array(
'section' => 'live',
'item_key' => 'pull_auth_enabled',
'item_value' => '1',
),
17 =>
array(
'section' => 'live',
'item_key' => 'push_auth_enabled',
'item_value' => '1',
),
18 =>
array(
'section' => 'live',
'item_key' => 'pull_protocol',
'item_value' => 'http',
),
19 =>
array(
'section' => 'live',
'item_key' => 'push_auth_delta',
'item_value' => '18000',
),
20 =>
array(
'section' => 'live',
'item_key' => 'pull_auth_delta',
'item_value' => '18000',
),
21 =>
array(
'section' => 'live',
'item_key' => 'pull_auth_key',
'item_value' => '',
),
22 =>
array(
'section' => 'live',
'item_key' => 'pull_domain',
'item_value' => 'play.abc.com',
),
23 =>
array(
'section' => 'live',
'item_key' => 'push_template',
'item_value' => '',
),
24 =>
array(
'section' => 'live',
'item_key' => 'push_auth_key',
'item_value' => '',
),
25 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_host',
'item_value' => 'smtp.163.com',
),
26 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_port',
'item_value' => '465',
),
27 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_encryption',
'item_value' => 'ssl',
),
28 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_username',
'item_value' => 'abc@163.com',
),
29 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_password',
'item_value' => '888888',
),
30 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_from_email',
'item_value' => 'abc@163.com',
),
31 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_from_name',
'item_value' => 'ABC有限公司',
),
32 =>
array(
'section' => 'mailer',
'item_key' => 'smtp_authentication',
'item_value' => '1',
),
33 =>
array(
'section' => 'pay.alipay',
'item_key' => 'public_key',
'item_value' => '',
),
34 =>
array(
'section' => 'pay.alipay',
'item_key' => 'private_key',
'item_value' => '',
),
35 =>
array(
'section' => 'pay.alipay',
'item_key' => 'enabled',
'item_value' => '1',
),
36 =>
array(
'section' => 'pay.alipay',
'item_key' => 'return_url',
'item_value' => '',
),
37 =>
array(
'section' => 'pay.alipay',
'item_key' => 'notify_url',
'item_value' => '',
),
38 =>
array(
'section' => 'pay.alipay',
'item_key' => 'app_id',
'item_value' => '',
),
39 =>
array(
'section' => 'pay.wxpay',
'item_key' => 'notify_url',
'item_value' => '',
),
40 =>
array(
'section' => 'pay.wxpay',
'item_key' => 'return_url',
'item_value' => '',
),
41 =>
array(
'section' => 'pay.wxpay',
'item_key' => 'app_id',
'item_value' => '',
),
42 =>
array(
'section' => 'pay.wxpay',
'item_key' => 'mch_id',
'item_value' => '',
),
43 =>
array(
'section' => 'pay.wxpay',
'item_key' => 'key',
'item_value' => '',
),
44 =>
array(
'section' => 'pay.wxpay',
'item_key' => 'enabled',
'item_value' => '1',
),
45 =>
array(
'section' => 'secret',
'item_key' => 'secret_key',
'item_value' => '',
),
46 =>
array(
'section' => 'secret',
'item_key' => 'secret_id',
'item_value' => '',
),
47 =>
array(
'section' => 'secret',
'item_key' => 'app_id',
'item_value' => '',
),
48 =>
array(
'section' => 'site',
'item_key' => 'keywords',
'item_value' => '开源网课系统,开源网校系统,开源网络教育平台,开源在线教育平台',
),
49 =>
array(
'section' => 'site',
'item_key' => 'analytics',
'item_value' => '',
),
50 =>
array(
'section' => 'site',
'item_key' => 'icp_sn',
'item_value' => '',
),
51 =>
array(
'section' => 'site',
'item_key' => 'icp_link',
'item_value' => 'http://www.miitbeian.gov.cn',
),
52 =>
array(
'section' => 'site',
'item_key' => 'police_sn',
'item_value' => '',
),
53 =>
array(
'section' => 'site',
'item_key' => 'police_link',
'item_value' => 'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=abc',
),
54 =>
array(
'section' => 'site',
'item_key' => 'copyright',
'item_value' => '2016-2020 深圳市酷瓜软件有限公司',
),
55 =>
array(
'section' => 'site',
'item_key' => 'base_url',
'item_value' => '',
),
56 =>
array(
'section' => 'site',
'item_key' => 'enabled',
'item_value' => '1',
),
57 =>
array(
'section' => 'site',
'item_key' => 'closed_tips',
'item_value' => '站点维护中,请稍后再访问。',
),
58 =>
array(
'section' => 'site',
'item_key' => 'description',
'item_value' => '酷瓜云课堂依托腾讯云基础服务使用C扩展框架PHALCON开发',
),
59 =>
array(
'section' => 'site',
'item_key' => 'title',
'item_value' => '酷瓜云课堂',
),
60 =>
array(
'section' => 'smser',
'item_key' => 'app_id',
'item_value' => '',
),
61 =>
array(
'section' => 'smser',
'item_key' => 'template',
'item_value' => '{"verify":{"id":"561282","content":"验证码:{1}{2} 分钟内有效,如非本人操作请忽略。"},"order":{"id":"561954","content":"下单成功,商品名称:{1},订单序号:{2},订单金额:¥{3}"},"refund":{"id":"561286","content":"退款成功,商品名称:{1},订单序号:{2},退款金额:¥{3}"},"live":{"id":"561288","content":"直播预告,课程名称:{1},章节名称:{2},开播时间:{3}"}}',
),
62 =>
array(
'section' => 'smser',
'item_key' => 'signature',
'item_value' => 'abc',
),
63 =>
array(
'section' => 'smser',
'item_key' => 'app_key',
'item_value' => '',
),
64 =>
array(
'section' => 'storage',
'item_key' => 'ci_protocol',
'item_value' => 'https',
),
65 =>
array(
'section' => 'storage',
'item_key' => 'bucket_name',
'item_value' => '',
),
66 =>
array(
'section' => 'storage',
'item_key' => 'ci_domain',
'item_value' => '',
),
67 =>
array(
'section' => 'storage',
'item_key' => 'bucket_region',
'item_value' => '',
),
68 =>
array(
'section' => 'storage',
'item_key' => 'bucket_protocol',
'item_value' => 'https',
),
69 =>
array(
'section' => 'storage',
'item_key' => 'bucket_domain',
'item_value' => '',
),
70 =>
array(
'section' => 'vod',
'item_key' => 'dist_protocol',
'item_value' => 'https',
),
71 =>
array(
'section' => 'vod',
'item_key' => 'watermark_enabled',
'item_value' => '1',
),
72 =>
array(
'section' => 'vod',
'item_key' => 'watermark_template',
'item_value' => '462027',
),
73 =>
array(
'section' => 'vod',
'item_key' => 'video_template',
'item_value' => '100210,100220,100230',
),
74 =>
array(
'section' => 'vod',
'item_key' => 'audio_format',
'item_value' => 'mp3',
),
75 =>
array(
'section' => 'vod',
'item_key' => 'video_format',
'item_value' => 'hls',
),
76 =>
array(
'section' => 'vod',
'item_key' => 'storage_type',
'item_value' => 'nearby',
),
77 =>
array(
'section' => 'vod',
'item_key' => 'storage_region',
'item_value' => '',
),
78 =>
array(
'section' => 'vod',
'item_key' => 'template',
'item_value' => '',
),
79 =>
array(
'section' => 'vod',
'item_key' => 'key_anti_ip_limit',
'item_value' => '',
),
80 =>
array(
'section' => 'vod',
'item_key' => 'dist_domain',
'item_value' => '',
),
81 =>
array(
'section' => 'vod',
'item_key' => 'audio_template',
'item_value' => '1110',
),
82 =>
array(
'section' => 'vod',
'item_key' => 'key_anti_key',
'item_value' => '',
),
83 =>
array(
'section' => 'vod',
'item_key' => 'key_anti_expiry',
'item_value' => '10800',
),
84 =>
array(
'section' => 'vod',
'item_key' => 'key_anti_enabled',
'item_value' => '1',
),
);
$rows = [
[
'section' => 'captcha',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'captcha',
'item_key' => 'secret_key',
'item_value' => '',
],
[
'section' => 'captcha',
'item_key' => 'enabled',
'item_value' => '0',
],
[
'section' => 'im.cs',
'item_key' => 'user1_id',
'item_value' => '',
],
[
'section' => 'im.cs',
'item_key' => 'enabled',
'item_value' => '0',
],
[
'section' => 'im.cs',
'item_key' => 'user3_id',
'item_value' => '',
],
[
'section' => 'im.cs',
'item_key' => 'user2_id',
'item_value' => '',
],
[
'section' => 'im.main',
'item_key' => 'msg_max_length',
'item_value' => '1000',
],
[
'section' => 'im.main',
'item_key' => 'title',
'item_value' => '菜鸟驿站',
],
[
'section' => 'im.main',
'item_key' => 'upload_img_enabled',
'item_value' => '0',
],
[
'section' => 'im.main',
'item_key' => 'upload_file_enabled',
'item_value' => '0',
],
[
'section' => 'im.main',
'item_key' => 'tool_audio_enabled',
'item_value' => '0',
],
[
'section' => 'im.main',
'item_key' => 'tool_video_enabled',
'item_value' => '0',
],
[
'section' => 'live',
'item_key' => 'push_domain',
'item_value' => 'push.abc.com',
],
[
'section' => 'live',
'item_key' => 'pull_trans_template',
'item_value' => '{"fd":{"id":"fd","bit_rate":"500","summary":"流畅","height":"540"},"sd":{"id":"sd","bit_rate":"1000","summary":"标清","height":"720"},"hd":{"id":"hd","bit_rate":"2000","summary":"高清","height":"1080"}}',
],
[
'section' => 'live',
'item_key' => 'pull_trans_enabled',
'item_value' => '1',
],
[
'section' => 'live',
'item_key' => 'pull_auth_enabled',
'item_value' => '1',
],
[
'section' => 'live',
'item_key' => 'push_auth_enabled',
'item_value' => '1',
],
[
'section' => 'live',
'item_key' => 'pull_protocol',
'item_value' => 'http',
],
[
'section' => 'live',
'item_key' => 'push_auth_delta',
'item_value' => '18000',
],
[
'section' => 'live',
'item_key' => 'pull_auth_delta',
'item_value' => '18000',
],
[
'section' => 'live',
'item_key' => 'pull_auth_key',
'item_value' => '',
],
[
'section' => 'live',
'item_key' => 'pull_domain',
'item_value' => 'play.abc.com',
],
[
'section' => 'live',
'item_key' => 'push_template',
'item_value' => '',
],
[
'section' => 'live',
'item_key' => 'push_auth_key',
'item_value' => '',
],
[
'section' => 'mailer',
'item_key' => 'smtp_host',
'item_value' => 'smtp.163.com',
],
[
'section' => 'mailer',
'item_key' => 'smtp_port',
'item_value' => '465',
],
[
'section' => 'mailer',
'item_key' => 'smtp_encryption',
'item_value' => 'ssl',
],
[
'section' => 'mailer',
'item_key' => 'smtp_username',
'item_value' => 'abc@163.com',
],
[
'section' => 'mailer',
'item_key' => 'smtp_password',
'item_value' => '888888',
],
[
'section' => 'mailer',
'item_key' => 'smtp_from_email',
'item_value' => 'abc@163.com',
],
[
'section' => 'mailer',
'item_key' => 'smtp_from_name',
'item_value' => 'ABC有限公司',
],
[
'section' => 'mailer',
'item_key' => 'smtp_authentication',
'item_value' => '1',
],
[
'section' => 'pay.alipay',
'item_key' => 'public_key',
'item_value' => '',
],
[
'section' => 'pay.alipay',
'item_key' => 'private_key',
'item_value' => '',
],
[
'section' => 'pay.alipay',
'item_key' => 'enabled',
'item_value' => '1',
],
[
'section' => 'pay.alipay',
'item_key' => 'return_url',
'item_value' => '',
],
[
'section' => 'pay.alipay',
'item_key' => 'notify_url',
'item_value' => '',
],
[
'section' => 'pay.alipay',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'pay.wxpay',
'item_key' => 'notify_url',
'item_value' => '',
],
[
'section' => 'pay.wxpay',
'item_key' => 'return_url',
'item_value' => '',
],
[
'section' => 'pay.wxpay',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'pay.wxpay',
'item_key' => 'mch_id',
'item_value' => '',
],
[
'section' => 'pay.wxpay',
'item_key' => 'key',
'item_value' => '',
],
[
'section' => 'pay.wxpay',
'item_key' => 'enabled',
'item_value' => '1',
],
[
'section' => 'secret',
'item_key' => 'secret_key',
'item_value' => '',
],
[
'section' => 'secret',
'item_key' => 'secret_id',
'item_value' => '',
],
[
'section' => 'secret',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'keywords',
'item_value' => '开源网课系统,开源网校系统,开源网络教育平台,开源在线教育平台',
],
[
'section' => 'site',
'item_key' => 'analytics',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'icp_sn',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'icp_link',
'item_value' => 'http://www.miitbeian.gov.cn',
],
[
'section' => 'site',
'item_key' => 'police_sn',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'police_link',
'item_value' => 'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=abc',
],
[
'section' => 'site',
'item_key' => 'copyright',
'item_value' => '2016-2020 深圳市酷瓜软件有限公司',
],
[
'section' => 'site',
'item_key' => 'base_url',
'item_value' => '',
],
[
'section' => 'site',
'item_key' => 'enabled',
'item_value' => '1',
],
[
'section' => 'site',
'item_key' => 'closed_tips',
'item_value' => '站点维护中,请稍后再访问。',
],
[
'section' => 'site',
'item_key' => 'description',
'item_value' => '酷瓜云课堂依托腾讯云基础服务使用C扩展框架PHALCON开发',
],
[
'section' => 'site',
'item_key' => 'title',
'item_value' => '酷瓜云课堂',
],
[
'section' => 'smser',
'item_key' => 'app_id',
'item_value' => '',
],
[
'section' => 'smser',
'item_key' => 'template',
'item_value' => '{"verify":{"id":"561282","content":"验证码:{1}{2} 分钟内有效,如非本人操作请忽略。"},"order":{"id":"561954","content":"下单成功,商品名称:{1},订单序号:{2},订单金额:¥{3}"},"refund":{"id":"561286","content":"退款成功,商品名称:{1},订单序号:{2},退款金额:¥{3}"},"live":{"id":"561288","content":"直播预告,课程名称:{1},章节名称:{2},开播时间:{3}"}}',
],
[
'section' => 'smser',
'item_key' => 'signature',
'item_value' => 'abc',
],
[
'section' => 'smser',
'item_key' => 'app_key',
'item_value' => '',
],
[
'section' => 'storage',
'item_key' => 'ci_protocol',
'item_value' => 'https',
],
[
'section' => 'storage',
'item_key' => 'bucket_name',
'item_value' => '',
],
[
'section' => 'storage',
'item_key' => 'ci_domain',
'item_value' => '',
],
[
'section' => 'storage',
'item_key' => 'bucket_region',
'item_value' => '',
],
[
'section' => 'storage',
'item_key' => 'bucket_protocol',
'item_value' => 'https',
],
[
'section' => 'storage',
'item_key' => 'bucket_domain',
'item_value' => '',
],
[
'section' => 'vod',
'item_key' => 'dist_protocol',
'item_value' => 'https',
],
[
'section' => 'vod',
'item_key' => 'watermark_enabled',
'item_value' => '1',
],
[
'section' => 'vod',
'item_key' => 'watermark_template',
'item_value' => '462027',
],
[
'section' => 'vod',
'item_key' => 'video_template',
'item_value' => '100210,100220,100230',
],
[
'section' => 'vod',
'item_key' => 'audio_format',
'item_value' => 'mp3',
],
[
'section' => 'vod',
'item_key' => 'video_format',
'item_value' => 'hls',
],
[
'section' => 'vod',
'item_key' => 'storage_type',
'item_value' => 'nearby',
],
[
'section' => 'vod',
'item_key' => 'storage_region',
'item_value' => '',
],
[
'section' => 'vod',
'item_key' => 'template',
'item_value' => '',
],
[
'section' => 'vod',
'item_key' => 'key_anti_ip_limit',
'item_value' => '',
],
[
'section' => 'vod',
'item_key' => 'dist_domain',
'item_value' => '',
],
[
'section' => 'vod',
'item_key' => 'audio_template',
'item_value' => '1110',
],
[
'section' => 'vod',
'item_key' => 'key_anti_key',
'item_value' => '',
],
[
'section' => 'vod',
'item_key' => 'key_anti_expiry',
'item_value' => '10800',
],
[
'section' => 'vod',
'item_key' => 'key_anti_enabled',
'item_value' => '1',
],
];
$this->table('kg_setting')->insert($rows)->save();
}

View File

@ -16,7 +16,7 @@ final class InsertUserData extends AbstractMigration
'salt' => 'MbZWxN3L',
];
$this->table('kg_account')->insert($account)->save();
$this->table('kg_account')->insert($account)->saveData();
$user = [
'id' => $account['id'],
@ -28,7 +28,7 @@ final class InsertUserData extends AbstractMigration
'edu_role' => 2,
];
$this->table('kg_user')->insert($user)->save();
$this->table('kg_user')->insert($user)->saveData();
$imUser = [
'id' => $user['id'],
@ -36,7 +36,7 @@ final class InsertUserData extends AbstractMigration
'avatar' => $user['avatar'],
];
$this->table('kg_im_user')->insert($imUser)->save();
$this->table('kg_im_user')->insert($imUser)->saveData();
}
public function down()

View File

@ -1,23 +1,155 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class InsertNavData extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change(): void
{
public function up()
{
$rows = [
[
'id' => 1,
'parent_id' => 0,
'level' => 1,
'name' => '首页',
'path' => ',1,',
'position' => 'top',
'target' => '_self',
'url' => '/',
'priority' => 1,
'published' => 1,
],
[
'id' => 2,
'parent_id' => 0,
'level' => 1,
'name' => '录播',
'path' => ',2,',
'position' => 'top',
'target' => '_self',
'url' => '/course/list?model=1',
'priority' => 2,
'published' => 1,
],
[
'id' => 3,
'parent_id' => 0,
'level' => 1,
'name' => '直播',
'path' => ',3,',
'position' => 'top',
'target' => '_self',
'url' => '/course/list?model=2',
'priority' => 3,
'published' => 1,
],
[
'id' => 4,
'parent_id' => 0,
'level' => 1,
'name' => '专栏',
'path' => ',4,',
'position' => 'top',
'target' => '_self',
'url' => '/course/list?model=3',
'priority' => 4,
'published' => 1,
],
[
'id' => 5,
'parent_id' => 0,
'level' => 1,
'name' => '名师',
'path' => ',5,',
'position' => 'top',
'target' => '_self',
'url' => '/teacher/list',
'priority' => 5,
'published' => 1,
],
[
'id' => 6,
'parent_id' => 0,
'level' => 1,
'name' => '群组',
'path' => ',6,',
'position' => 'top',
'target' => '_self',
'url' => '/im/group/list',
'priority' => 6,
'published' => 1,
],
[
'id' => 7,
'parent_id' => 0,
'level' => 1,
'name' => '关于我们',
'path' => ',7,',
'position' => 'bottom',
'target' => '_blank',
'url' => '#',
'priority' => 1,
'published' => 1,
],
[
'id' => 8,
'parent_id' => 0,
'level' => 1,
'name' => '联系我们',
'path' => ',8,',
'position' => 'bottom',
'target' => '_blank',
'url' => '#',
'priority' => 2,
'published' => 1,
],
[
'id' => 9,
'parent_id' => 0,
'level' => 1,
'name' => '人才招聘',
'path' => ',9,',
'position' => 'bottom',
'target' => '_blank',
'url' => '#',
'priority' => 3,
'published' => 1,
],
[
'id' => 10,
'parent_id' => 0,
'level' => 1,
'name' => '帮助中心',
'path' => ',10,',
'position' => 'bottom',
'target' => '_blank',
'url' => '/help',
'priority' => 4,
'published' => 1,
],
[
'id' => 11,
'parent_id' => 0,
'level' => 1,
'name' => '友情链接',
'path' => ',11,',
'position' => 'bottom',
'target' => '_blank',
'url' => '#',
'priority' => 5,
'published' => 1,
],
];
$this->table('kg_nav')->insert($rows)->save();
}
public function down()
{
$this->execute('DELETE FROM kg_nav');
}
}

View File

@ -105,7 +105,11 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () {
});
});
$('.kg-search').on('click', function () {
$('.kg-back').on('click', function () {
window.history.back();
});
$('.nav-search').on('click', function () {
var content = '<form action="' + $(this).data('url') + '">';
content += '<input type="text" name="query" autocomplete="off" placeholder="搜索内容,回车跳转">';
content += '<input type="hidden" name="type" value="' + $(this).data('type') + '">';
@ -132,10 +136,6 @@ layui.use(['jquery', 'form', 'element', 'layer', 'helper'], function () {
});
});
$('.kg-back').on('click', function () {
window.history.back();
});
$('body').on('click', '.layui-laypage > a', function () {
var url = $(this).data('url');
var target = $(this).data('target');

View File

@ -4,7 +4,7 @@ layui.use(['helper', 'util'], function () {
var util = layui.util;
util.fixbar({
bar1: window.im.cs.enabled === '1',
bar1: window.im.cs.enabled === '1' ? '&#xe626;' : false,
bar2: true,
click: function (type) {
if (type === 'bar1') {