Skip to content

Commit

Permalink
'修复几个bug'
Browse files Browse the repository at this point in the history
  • Loading branch information
yidashi committed Feb 21, 2017
1 parent e1f90db commit da29eee
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 63 deletions.
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ BACKEND_PRETTY_URL = false
# Urls
# ----
SITE_URL = https://localhost:8080
FRONTEND_URL = https://localhost:8080
BACKEND_URL = https://localhost:8080/admin
// 文件访问地址
STORAGE_URL = https://localhost:8080/storage

# 搜索驱动(xunsearch需要安装xunsearch服务端)
SEARCH_ENGINE = local
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@
2. `composer install`

3. `php yii app`(windows 命令行乱码问题是因为windows命令行默认编码为gbk,项目编码为utf8,执行`chcp 65001`修改命令行编码为utf8即可。如在窗口中仍旧不能正确显示UTF-8字符。在命令行标题栏上点击右键,选择"属性"->"字体",将点阵字体修改为True Type字体"Lucida Console",然后点击确定将属性应用到当前窗口。)

4. `php yii serve` (自有服务器就不需要这一步了,下边的访问地址根据自己的服务器来)

5. 收工

前台访问地址: `https://localhost:8080/`

后台访问地址: `https://localhost:8080/admin/` 管理员 帐号 `hehe` 密码 `111111`

> 如果使用自己的服务器,修改下.env文件里 `SITE_URL` `FRONTEND_URL` `BACKEND_URL` `STORAGE_URL` 这几个配置

或者 直接访问项目地址用web方式安装!


## demo
Expand Down
2 changes: 1 addition & 1 deletion backend/static/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ body {
div.required label.control-label:after {
content: " *";
color: red;
}
}
td{word-break: break-all}
.table thead tr th {
padding: 8px 8px;
Expand Down
2 changes: 1 addition & 1 deletion backend/views/layouts/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li><?= Html::a('<i class="fa fa-home"></i>', Yii::$app->config->get('FRONTEND_URL'), ['target' => '_blank']) ?></li>
<li><?= Html::a('<i class="fa fa-home"></i>', Yii::$app->config->get('SITE_URL'), ['target' => '_blank']) ?></li>
<li id="log-dropdown" class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-warning"></i>
Expand Down
2 changes: 1 addition & 1 deletion common/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


Yii::setAlias('storagePath', '@root/web/storage');
Yii::setAlias('storageUrl', env('STORAGE_URL', env('FRONTEND_URL/storage')));
Yii::setAlias('storageUrl', env('SITE_URL') . '/storage');


Yii::$container->set('yii\widgets\LinkPager', ['maxButtonCount' => 5, 'firstPageLabel' => '首页', 'lastPageLabel' => '末页']);
Expand Down
18 changes: 15 additions & 3 deletions console/controllers/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace console\controllers;


use common\modules\user\models\User;
use yii\console\Controller;
use Yii;
use yii\helpers\Console;
Expand Down Expand Up @@ -187,23 +188,34 @@ public function actionInstall()
$this->setEnv('YII_ENV', $appStatus);
// 迁移
Yii::$app->runAction('migrate/up', ['interactive' => false]);
//创建默认用户
$this->runAction('create-admin', ['interactive' => $this->interactive]);
$this->setEnv('SITE_URL', $this->prompt('siteUrl'));
// 清缓存
Yii::$app->runAction('cache/flush-all', ['interactive' => false]);
$this->setInstalled();
$end = <<<STR
+=================================================+
| Installation completed successfully, Thanks you |
| 安装成功,感谢选择和使用 yii2cmf |
+-------------------------------------------------+
| 说明和注意事项: |
| 图片不能正常显示需要到.env文件里修改对应URL
+------------------------------------------+
| 默认后台账号:hehe 密码: 111111
+=================================================+
STR;

$this->stdout($end, Console::FG_GREEN);
}

public function actionCreateAdmin()
{
$user = new User();
$user->setScenario("create");
$user->email = '[email protected]';
$user->username = 'hehe';
$user->password = '111111';
$user->create();
}
public function actionReset()
{
if (!$this->checkInstalled()) {
Expand Down
4 changes: 2 additions & 2 deletions database/migrations/m160726_093217_create_user_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function up()
'updated_at' => Schema::TYPE_INTEGER . "(10) NOT NULL"
], $tableOptions);

$this->insert('{{%user}}', [
/*$this->insert('{{%user}}', [
'username' => 'hehe',
'auth_key' => '1lQl4TG6sYlyWRqXZEWL0ZhQkPATVnMs',
'password_hash' => '$2y$13$lYlhIcBcs6jBr7yTd6YrWueckcs.Cvx70juIHs6wEfjtUwnA318VW',
Expand All @@ -65,7 +65,7 @@ public function up()
'locale' => 'zh-CN',
'created_at' => 1441766741,
'updated_at' => 1441766741,
]);
]);*/
}

/**
Expand Down
1 change: 0 additions & 1 deletion database/migrations/m161215_024158_create_book_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function up()
'id' => 'book',
'name' => '文档wiki',
'bootstrap' => 'app-frontend|app-backend',
'class' => 'common\\modules\\book\\Module',
'status' => 1,
'type' => 1,
'created_at' => time(),
Expand Down
22 changes: 2 additions & 20 deletions install/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public function actionSetSite()
if ($model->load(Yii::$app->request->post())) {

if ($model->validate() && $model->save()) {
$this->installDb();
$this->installConfig();
Yii::$app->setInstalled();
return $this->renderJson(true);
} else {
return $this->renderJson(false, current($model->getFirstErrors()));
Expand Down Expand Up @@ -141,6 +138,7 @@ public function actionSetAdmin()

\Yii::$app->getCache()->flush();
//安装完成
Yii::$app->setInstalled();
return $this->renderJson(true);

}
Expand Down Expand Up @@ -197,13 +195,7 @@ public function installConfig()
\Yii::$app->setKeys($this->envPath);
$data = \Yii::$app->getCache()->get(SiteForm::CACHE_KEY);
foreach ($data as $name => $value) {
$configName = preg_replace_callback('/([a-z]*)([A-Z].*)/', function ($matches) {
return $matches[1] . "." . strtolower($matches[2]);
}, $name);
Yii::$app->db->createCommand()->insert('{{%config}}',[
'name' => $configName,
'value' => $value
]);
Yii::$app->setEnv($name, $value);
}
return true;
}
Expand All @@ -220,15 +212,6 @@ public function createAdminUser()
if($user->create() == false) {
return current($user->getFirstErrors());
}
//添加管理员权限
$connection = \Yii::$app->getDb();
$connection->createCommand()
->insert('{{%auth_assignment}}', [
'item_name' => 'superAdmin',
'user_id' => $user->id,
"created_at" => time()
])->execute();

return null;
}

Expand Down Expand Up @@ -260,5 +243,4 @@ protected function addMigrationHistory($version)
'apply_time' => time(),
])->execute();
}

}
8 changes: 4 additions & 4 deletions install/models/AdminForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public function rules()
public function attributeLabels()
{
return [
'username' => 'username',
'password' => 'Password',
'passwordConfirm' => 'Password Confirm',
'email' => 'Email'
'username' => '用户名',
'password' => '密码',
'passwordConfirm' => '确认密码',
'email' => '邮箱'
];
}

Expand Down
6 changes: 3 additions & 3 deletions install/models/SiteForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ class SiteForm extends Model
{


public $appName;
public $SITE_URL = 'https://';

const CACHE_KEY = "install-site-form";

public function rules()
{
return [
[['appName',], 'string']
[['SITE_URL',], 'string']
];
}

public function attributeLabels()
{
return [
'appName' => '站点名称',
'SITE_URL' => '站点地址',
];
}

Expand Down
5 changes: 4 additions & 1 deletion install/static/css/install.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ body {
background: -ms-linear-gradient(top,#ccc,#fff);
background: linear-gradient(top,#ccc,#fff)
}

div.required label.control-label:after {
content: " *";
color: red;
}
#wrapper {
width: 800px;
}
Expand Down
22 changes: 11 additions & 11 deletions install/views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@
])
]
],
// [
// 'label' => '输入管理员信息',
// "url" => [
// "site/set-admin"
// ],
// "options" => [
// "data-url" => Url::to([
// "site/set-admin"
// ])
// ]
// ]
[
'label' => '输入管理员信息',
"url" => [
"site/set-admin"
],
"options" => [
"data-url" => Url::to([
"site/set-admin"
])
]
]
]
]);
?>
Expand Down
2 changes: 1 addition & 1 deletion install/views/site/setadmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
]
]);
?>
<?=$form->field($model, 'email')->textInput(['class' => 'form-control'])?>
<?=$form->field($model, 'username')->textInput(['class' => 'form-control'])?>
<?=$form->field($model, 'email')->textInput(['class' => 'form-control'])?>
<?=$form->field($model, 'password')->passwordInput(['class' => 'form-control'])?>
<?=$form->field($model, 'passwordConfirm')->passwordInput(['class' => 'form-control'])?>

Expand Down
2 changes: 1 addition & 1 deletion install/views/site/setsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
]
]);
?>
<?=$form->field($model, 'appName')->textInput(['autocomplete' => 'off','class' => 'form-control'])?>
<?=$form->field($model, 'SITE_URL')->textInput(['autocomplete' => 'off','class' => 'form-control'])?>

<?php \yii\widgets\ActiveForm::end(); ?>

0 comments on commit da29eee

Please sign in to comment.