From 64aeeffa04ad8a99229f3ef4ce4feb31f93d2470 Mon Sep 17 00:00:00 2001
From: zhaoxiang <756958008@qq.com>
Date: Mon, 21 Nov 2016 00:15:45 +0800
Subject: [PATCH] =?UTF-8?q?modified=20=E5=AE=8C=E6=88=90=E5=AE=89=E8=A3=85?=
 =?UTF-8?q?=E8=84=9A=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 application/install/controller/Index.php     | 33 +++++++++++++-------
 application/install/view/index/complete.html | 20 ++++++++++++
 application/install/view/index/step4.html    | 16 +++++++---
 3 files changed, 53 insertions(+), 16 deletions(-)
 create mode 100644 application/install/view/index/complete.html

diff --git a/application/install/controller/Index.php b/application/install/controller/Index.php
index b2cfb0b..acb53e4 100644
--- a/application/install/controller/Index.php
+++ b/application/install/controller/Index.php
@@ -96,11 +96,11 @@ class Index extends Controller {
             $this->error('环境检测没有通过,请调整环境后重试!', url('step3'));
         }else{
             $step = session('step');
-//            if( $step != 3){
-//                $this->error("请按顺序安装", url('index'));
-//            }else{
-                session('step', 4);
+            if( $step != 3){
+                $this->error("请按顺序安装", url('index'));
+            }else{
                 session('error', false);
+                echo $this->fetch();
                 $dbConfig = session('dbConfig');
                 $cacheConfig = session('cacheConfig');
                 $adminConfig = session('adminConfig');
@@ -140,9 +140,18 @@ class Index extends Controller {
                     $this->writeConfig($cacheConfig, 'cache', $extraConfPath);
                 }
                 $this->writeConfig($baseConfig, 'base', $extraConfPath);
-                return $this->fetch();
+                if(session('error')){
+                    $this->error('安装出错', url('index'));
+                }else{
+                    session('step', 4);
+                    $this->redirect('complete');
+                }
             }
-//        }
+        }
+    }
+
+    public function complete(){
+        return $this->fetch();
     }
 
     /**
@@ -154,7 +163,7 @@ class Index extends Controller {
      */
     private function writeConfig($config, $type, $path){
         if(is_array($config)){
-            showMsg('开始写入'.$type.'配置文件');
+            showMsg('开始写入配置文件...', 'info');
             //读取配置内容
             $conf = file_get_contents(APP_PATH . $this->request->module(). DS . 'data'. DS .$type.'.tpl');
             //替换配置项
@@ -163,9 +172,9 @@ class Index extends Controller {
             }
             //写入应用配置文件
             if(file_put_contents($path.$type.'.php', $conf)){
-                showMsg('配置文件'.$type.'写入成功', 'bg-success');
+                showMsg('写入配置文件'.$type.'...成功', 'success');
             }else{
-                showMsg('配置文件'.$type.'写入失败!', 'bg-danger');
+                showMsg('写入配置文件'.$type.'...失败!', 'danger');
                 session('error', true);
             }
             return true;
@@ -184,7 +193,7 @@ class Index extends Controller {
         $sql = explode(";\n", $sql);
 
         //开始安装
-        showMsg('开始安装数据库...');
+        showMsg('开始安装数据库...', 'info');
         foreach ($sql as $value) {
             $value = trim($value);
             if (empty($value)) continue;
@@ -193,9 +202,9 @@ class Index extends Controller {
                 $value = str_replace(" `{$name}", " `{$prefix}{$name}", $value);
                 $msg  = "创建数据表{$name}";
                 if (false !== $db->exec($value)) {
-                    showMsg($msg . '...成功');
+                    showMsg($msg . '...成功', 'success');
                 } else {
-                    showMsg($msg . '...失败!', 'error');
+                    showMsg($msg . '...失败!', 'danger');
                     session('error', true);
                 }
             } else {
diff --git a/application/install/view/index/complete.html b/application/install/view/index/complete.html
new file mode 100644
index 0000000..b540b9a
--- /dev/null
+++ b/application/install/view/index/complete.html
@@ -0,0 +1,20 @@
+{extend name="public/base" /}
+{block name="title"}系统安装Step4{/block}
+{block name="nav"}
+<li><a href="javascript:;">安装协议</a></li>
+<li><a href="javascript:;">参数设置</a></li>
+<li><a href="javascript:;">环境检测</a></li>
+<li class="active"><a href="javascript:;">开始安装</a></li>
+<li><a href="javascript:;">安装完成</a></li>
+{/block}
+{block name="main"}
+<div class="panel panel-default">
+    <div class="panel-heading">恭喜您,{:config('PRODUCT_NAME')} 安装完成!</div>
+    <div class="panel-body" style="font-size: 14px">
+        <div class="alert alert-success" role="alert">
+            <h4 align="center">{:config('PRODUCT_NAME')}提示您:您的系统已经成功安装,为了系统安全,请删除Install模块!</h4>
+        </div>
+        <a class="btn btn-primary btn-block" target="_blank" href="http://{:$_SERVER['HTTP_HOST']}">进入系统</a>
+    </div>
+</div>
+{/block}
\ No newline at end of file
diff --git a/application/install/view/index/step4.html b/application/install/view/index/step4.html
index 4db20b0..89039df 100644
--- a/application/install/view/index/step4.html
+++ b/application/install/view/index/step4.html
@@ -8,6 +8,16 @@
 <li><a href="javascript:;">安装完成</a></li>
 {/block}
 {block name="main"}
+<style>
+    .install-database {
+        height: 500px;
+        max-height: 500px;
+        overflow-y: scroll;
+    }
+    .install-database p{
+        padding: 15px;
+    }
+</style>
 <div class="panel panel-default">
     <div class="panel-heading">{:config('PRODUCT_NAME')} 开始安装</div>
     <div class="panel-body" style="font-size: 14px">
@@ -18,14 +28,12 @@
             function showMsg(msg, classname){
                 var li = document.createElement('p');
                 li.innerHTML = msg;
-                classname && li.setAttribute('class', classname);
+                classname && li.setAttribute('class', 'bg-' + classname);
                 list.appendChild(li);
                 document.scrollTop += 30;
             }
         </script>
-        <button class="am-radius am-btn am-btn-warning am-disabled">正在安装,请稍后...</button>
-        <a type="button" href="{:url('step4')}" class="btn btn-primary btn-block">下一步</a>
-        <a type="button" href="{:url('step2')}" class="btn btn-default btn-block">上一步</a>
+        <button class="btn btn-warning btn-block" disabled>正在安装,请稍后...</button>
     </div>
 </div>
 {/block}
\ No newline at end of file