Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
b3d5efd5
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
b3d5efd5
编写于
9月 10, 2019
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
界面安装部分
上级
eee228f4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
105 addition
and
155 deletion
+105
-155
app/appinstall/config/appinstall.php
app/appinstall/config/appinstall.php
+1
-0
app/appinstall/modules/Database/controllers/ConfigController.php
...install/modules/Database/controllers/ConfigController.php
+41
-57
app/appinstall/modules/Database/views/config/addtestdata.php
app/appinstall/modules/Database/views/config/addtestdata.php
+10
-47
app/appinstall/modules/Database/views/config/complete.php
app/appinstall/modules/Database/views/config/complete.php
+1
-1
app/appinstall/modules/Database/views/config/migrate.php
app/appinstall/modules/Database/views/config/migrate.php
+12
-50
app/appinstall/modules/Database/views/config/migratesuccess.php
...pinstall/modules/Database/views/config/migratesuccess.php
+40
-0
未找到文件。
app/appinstall/config/appinstall.php
浏览文件 @
b3d5efd5
...
...
@@ -37,6 +37,7 @@ $config = [
'forceCopy'
=>
true
,
],
],
];
return
$config
;
\ No newline at end of file
app/appinstall/modules/Database/controllers/ConfigController.php
浏览文件 @
b3d5efd5
...
...
@@ -20,14 +20,14 @@ class ConfigController extends \yii\web\Controller
parent
::
init
();
}
public
$_migrateLog
=
''
;
//
public $_migrateLog = '';
// 安装默认第一步页面
public
function
actionIndex
()
{
$editForm
=
Yii
::
$app
->
request
->
post
(
'editForm'
);
if
(
$editForm
&&
$this
->
checkDatabaseData
(
$editForm
)
&&
$this
->
updateDatabase
(
$editForm
))
{
&&
$this
->
updateDatabase
Config
(
$editForm
))
{
Yii
::
$app
->
session
->
setFlash
(
'database-success'
,
'mysql config set success, mysql config file path: @common/config/main-local.php'
);
// 进行跳转
$homeUrl
=
Yii
::
$app
->
homeUrl
;
...
...
@@ -44,6 +44,25 @@ class ConfigController extends \yii\web\Controller
// 数据库migrate页面
public
function
actionMigrate
()
{
$isPost
=
Yii
::
$app
->
request
->
post
(
'isPost'
);
if
(
$isPost
)
{
// 进行数据库初始化
if
(
$this
->
runMigrate
())
{
$successInfo
=
'数据库migrate初始化完成'
;
$successInfo
=
$this
->
getSuccessHtml
(
$successInfo
);
//exit;
return
$this
->
render
(
'migratesuccess'
,
[
'successInfo'
=>
$successInfo
,
'nextUrl'
=>
Yii
::
$app
->
homeUrl
.
'/database/config/addtestdata'
,
'skipUrl'
=>
Yii
::
$app
->
homeUrl
.
'/database/config/complete'
,
]);
}
else
{
$errors
=
'migrate 失败,你可以在logs文件中查看具体原因(@appfront/config/main.php中log组件,对应的logFile配置,查看该log文件,如果没有可以手动创建该log文件,清空数据库,重新执行该操作)'
;
Yii
::
$app
->
session
->
setFlash
(
'migrate-errors'
,
$errors
);
}
}
$successInfo
=
Yii
::
$app
->
session
->
getFlash
(
'database-success'
);
$successInfo
=
$this
->
getSuccessHtml
(
$successInfo
);
$errorInfo
=
Yii
::
$app
->
session
->
getFlash
(
'migrate-errors'
);
...
...
@@ -52,19 +71,21 @@ class ConfigController extends \yii\web\Controller
return
$this
->
render
(
$this
->
action
->
id
,
[
'successInfo'
=>
$successInfo
,
'errorInfo'
=>
$errorInfo
,
'initUrl'
=>
Yii
::
$app
->
homeUrl
.
'/database/config/migrateprocess'
,
'nextUrl'
=>
Yii
::
$app
->
homeUrl
.
'/database/config/addtestdata'
,
'migrateLog'
=>
$this
->
_migrateLog
]);
}
// 产品测试数据添加
public
function
actionAddtestdata
()
{
$errorInfo
=
Yii
::
$app
->
session
->
getFlash
(
'add-test-errors'
);
$errorInfo
=
$this
->
getErrorHtml
(
$errorInfo
);
if
(
$this
->
addProductData
())
{
$successInfo
=
$this
->
getSuccessHtml
(
'产品测试数据添加成功'
);
}
else
{
$errorInfo
=
Yii
::
$app
->
session
->
getFlash
(
'add-test-data-errors'
);
$errorInfo
=
$this
->
getErrorHtml
(
$errorInfo
);
}
return
$this
->
render
(
$this
->
action
->
id
,
[
'errorInfo'
=>
$errorInfo
,
'successInfo'
=>
$successInfo
,
'initUrl'
=>
Yii
::
$app
->
homeUrl
.
'/database/config/addtestdatainit'
,
'nextUrl'
=>
Yii
::
$app
->
homeUrl
.
'/database/config/complete'
,
//'migrateLog' => $this->_migrateLog
...
...
@@ -72,7 +93,7 @@ class ConfigController extends \yii\web\Controller
}
// 进行sql migrate ,产品图片的复制
public
function
a
ctionAddtestdatainit
()
public
function
a
ddProductData
()
{
// 1. 图片的复制
$sourcePath
=
dirname
(
Yii
::
getAlias
(
'@common'
))
.
'/environments/test_data/appimage'
;
...
...
@@ -87,34 +108,15 @@ class ConfigController extends \yii\web\Controller
try
{
$result
=
$conn
->
createCommand
(
$sqlStr
)
->
execute
();
$innerTransaction
->
commit
();
echo
json_encode
([
'status'
=>
'success'
,
]);
exit
;
return
true
;
}
catch
(
\
Exception
$e
)
{
$innerTransaction
->
rollBack
();
$message
=
$e
->
getMessage
();
echo
json_encode
([
'status'
=>
'fail'
,
'info'
=>
$message
,
]);
exit
;
Yii
::
$app
->
session
->
setFlash
(
'add-test-data-errors'
,
$message
);
}
echo
json_encode
([
'status'
=>
'fail'
,
'info'
=>
'error'
,
]);
exit
;
}
// 进行数据库的migrate操作(ajax)
public
function
actionMigrateprocess
()
{
$this
->
runMigrate
();
exit
;
return
false
;
}
// 完成页面
...
...
@@ -124,7 +126,7 @@ class ConfigController extends \yii\web\Controller
}
// 进行数据库的信息的检查,以及将数据库信息写入文件
public
function
updateDatabase
(
$editForm
)
public
function
updateDatabase
Config
(
$editForm
)
{
$host
=
$editForm
[
'host'
];
$database
=
$editForm
[
'database'
];
...
...
@@ -242,42 +244,24 @@ class ConfigController extends \yii\web\Controller
*/
public
function
runMigrate
()
{
$bashPath
=
dirname
(
Yii
::
getAlias
(
'@appfront'
));
$oldApp
=
\
Yii
::
$app
;
Yii
::
$app
=
new
\
yii\console\Application
([
'id'
=>
'install-console'
,
'basePath'
=>
'@appfront'
,
'basePath'
=>
$bashPath
,
'components'
=>
[
'db'
=>
$oldApp
->
db
,
],
]);
$runResult
=
\
Yii
::
$app
->
runAction
(
'migrate/up'
,
[
'migrationPath'
=>
'@fecshop/migrations/mysqldb'
,
'interactive'
=>
false
]);
\
Yii
::
$app
=
$oldApp
;
return
$runResult
;
}
/*
public function runMigrate()
{
// 通过ob函数截取输出字符
ob_start
();
ob_implicit_flush
(
false
);
extract(['oldApp' => \Yii::$app], EXTR_OVERWRITE);
\Yii::$app = new \yii\console\Application([
'id' => 'install-console',
'basePath' => '@appfront',
'components' => [
'db' => $oldApp->db,
],
]);
$result = \Yii::$app->runAction('migrate/up', ['migrationPath' => '@fecshop/migrations/mysqldb', 'interactive' => false]);
$runResult
=
\
Yii
::
$app
->
runAction
(
'migrate/up'
,
[
'migrationPath'
=>
'@fecshop/migrations/mysqldb'
,
'interactive'
=>
false
]);
$post_log
=
ob_get_clean
();
Yii
::
info
(
$post_log
,
'fecshop_debug'
);
\
Yii
::
$app
=
$oldApp
;
$this->_migrateLog = ob_get_clean();
return true;
// $runResult 返回值,0代表执行完成,1代表执行出错。
return
$runResult
===
0
?
true
:
false
;
}
*/
// 创建文件夹,在图片文件复制的过程中使用。
public
function
dirMkdir
(
$path
=
''
,
$mode
=
0777
,
$recursive
=
true
)
...
...
app/appinstall/modules/Database/views/config/addtestdata.php
浏览文件 @
b3d5efd5
...
...
@@ -11,36 +11,31 @@
<br/>
<?php
echo
CRequest
::
getCsrfInputHtml
();
?>
<p>
此步骤执行
:
</p>
<p>
产品测试数据安装操作
:
</p>
<p>
1.产品测试数据sql安装
</p>
<p>
2.产品的图片复制
</p>
<p>
3.
请勿重复执行该步骤,因为插入的数据只能插入依次,
多次插入将会报错,
<p>
3.
<b>
请勿重复执行该步骤
</b>
,操作成功后,请勿刷新页面,因为插入的测试数据
多次插入将会报错,
如果您已经执行了插入的sql,点击跳过进入下一步即可。
</p>
<p>
4.如果您
不想安装测试数据,点击跳过按钮,进入下一步。
</p>
<p>
4.如果您
进行了重复操作,请清空数据库的表,从头开始安装
</p>
<br/>
<br/>
<button
type=
"button"
class=
"btn btn-default testDataInit"
>
测试产品数据安装
</button>
<button
type=
"button"
class=
"btn btn-default testDataSkip"
>
跳过
</button>
<button
type=
"button"
class=
"btn btn-default install-next"
style=
"display:none;"
>
下一步
</button>
<button
type=
"button"
class=
"btn btn-default install-next"
>
下一步
</button>
<br/>
<br/>
测试产品数据安装:
<span
class=
"logshort"
style=
"display:none;color:#cc0000;"
>
正在进行测试产品数据安装...
</span>
<span
class=
"logshort-complete"
style=
"display:none;color:green;"
>
测试产品数据安装完成,您可以点击下一步按钮,进行下一步的安装操作
</span>
<br/>
<textarea
class=
"initLog"
style=
"width:1200px;height:300px;"
></textarea>
<br/>
<br/>
<br/>
<br/>
<br/>
<script>
// add to cart js
...
...
@@ -49,39 +44,7 @@
$
(
"
.install-next
"
).
click
(
function
(){
window
.
location
.
href
=
"
<?=
$nextUrl
?>
"
;
});
$
(
"
.testDataSkip
"
).
click
(
function
(){
window
.
location
.
href
=
"
<?=
$nextUrl
?>
"
;
});
$
(
"
.testDataInit
"
).
click
(
function
(){
var
initUrl
=
"
<?=
$initUrl
?>
"
;
$
(
"
.logshort
"
).
show
();
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
type
:
'
post
'
,
dataType
:
'
json
'
,
data
:
{},
url
:
initUrl
,
success
:
function
(
data
,
textStatus
){
$
(
"
.logshort
"
).
hide
();
if
(
data
.
status
==
'
success
'
){
$
(
"
.logshort-complete
"
).
show
();
$
(
"
.testDataInit
"
).
hide
();
$
(
"
.testDataSkip
"
).
hide
();
$
(
"
.install-next
"
).
show
();
}
else
if
(
data
.
status
==
'
fail
'
){
$
(
"
.initLog
"
).
val
(
data
.
info
);
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
){
$
(
"
.logshort
"
).
hide
();
$
(
"
.initLog
"
).
val
(
XMLHttpRequest
.
responseText
);
}
});
});
});
<?php
$this
->
endBlock
();
?>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'db_init'
],
\
yii\web\View
::
POS_END
);
//将编写的js代码注册到页面底部 ?>
...
...
app/appinstall/modules/Database/views/config/complete.php
浏览文件 @
b3d5efd5
...
...
@@ -19,7 +19,7 @@
<p
style=
"font-size:16px;line-height:25px;"
>
3.后台默认用户名,用户名密码:
<span
style=
"color:#c7254e"
>
admin admin123
</span></p>
<p
style=
"font-size:16px;line-height:25px;"
>
4.访问后台,更改
<span
style=
"color:#c7254e"
>
admin
</span>
用户密码,然后根据文档进行后台配置
</p>
<p
style=
"font-size:16px;line-height:25px;"
>
4.访问后台
(访问nginx配置的后台appadmin域名)
,更改
<span
style=
"color:#c7254e"
>
admin
</span>
用户密码,然后根据文档进行后台配置
</p>
<br/>
...
...
app/appinstall/modules/Database/views/config/migrate.php
浏览文件 @
b3d5efd5
...
...
@@ -10,70 +10,32 @@
<br/>
<br/>
<?php
echo
CRequest
::
getCsrfInputHtml
();
?>
<p>
此步骤执行:
</p>
<p>
1.Fecmall 数据库表的migrate,进行数据库的初始化
</p>
<p>
2.初始化完成后,mysql的表以及索引,将会被建立, 以及初始数据
</p>
<br/>
<br/>
<button
type=
"button"
class=
"btn btn-default dbInit"
>
进行数据表初始化
</button>
<button
type=
"button"
class=
"btn btn-default install-next"
style=
"display:none;"
>
下一步
</button>
<p>
3.您需要等待一段时间,等待sql的执行完成
</p>
<br/>
<br/>
数据库初始化Log:
<span
class=
"logshort"
style=
"display:none;color:#cc0000;"
>
正在进行数据库初始化...
</span>
<span
class=
"logshort-complete"
style=
"display:none;color:green;"
>
数据库初始化完成,您可以点击下一步按钮,进行下一步的安装操作
</span>
<br/>
<textarea
class=
"initLog"
style=
"width:1200px;height:300px;"
></textarea>
<form
action=
""
method=
"post"
>
<?php
echo
CRequest
::
getCsrfInputHtml
();
?>
<input
type=
"hidden"
value=
"1"
name=
"isPost"
/>
<button
type=
"submit"
class=
"btn btn-default dbInit"
>
进行数据表初始化
</button>
<span
class=
"d_info"
style=
"margin-left:20px;display:none; color: #cc0000"
>
数据库migrate初始化中...
</span>
</form>
<script>
// add to cart js
<?php
$this
->
beginBlock
(
'db
_i
nit'
)
?>
<?php
$this
->
beginBlock
(
'db
I
nit'
)
?>
$
(
document
).
ready
(
function
(){
$
(
"
.
install-nex
t
"
).
click
(
function
(){
window
.
location
.
href
=
"
<?=
$nextUrl
?>
"
;
$
(
"
.
dbIni
t
"
).
click
(
function
(){
$
(
"
.d_info
"
).
show
()
;
});
$
(
"
.dbInit
"
).
click
(
function
(){
var
initUrl
=
"
<?=
$initUrl
?>
"
;
$
(
"
.logshort
"
).
show
();
$
.
ajax
({
async
:
true
,
timeout
:
6000
,
type
:
'
post
'
,
data
:
{},
url
:
initUrl
,
success
:
function
(
data
,
textStatus
){
$
(
"
.logshort
"
).
hide
();
$
(
"
.initLog
"
).
val
(
data
);
// #21 /www/web/develop/fecshop/appfront/web/install.php(20): yii\base\Application->run()
if
(
data
.
indexOf
(
'
appfront/web/install.php
'
)
!=
-
1
)
{
// 存在错误
}
else
{
// 不存在错误, 显示跳转下一步的按钮
$
(
"
.install-next
"
).
show
();
$
(
"
.logshort-complete
"
).
show
();
$
(
"
.dbInit
"
).
hide
();
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
){
$
(
"
.logshort
"
).
hide
();
$
(
"
.initLog
"
).
val
(
XMLHttpRequest
.
responseText
);
}
});
});
});
<?php
$this
->
endBlock
();
?>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'db
_i
nit'
],
\
yii\web\View
::
POS_END
);
//将编写的js代码注册到页面底部 ?>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'db
I
nit'
],
\
yii\web\View
::
POS_END
);
//将编写的js代码注册到页面底部 ?>
</
script
>
app/appinstall/modules/Database/views/config/migratesuccess.php
0 → 100644
浏览文件 @
b3d5efd5
<?php
use
fec\helpers\CRequest
;
?>
<h1>
Mysql数据库表初始化完成页面
</h1>
<br/>
<?=
$errorInfo
?>
<?=
$successInfo
?>
<br/>
<br/>
<p>
mysql migrate 数据库初始化完成,您可以进行产品测试数据的安装,
点击按钮
<span
style=
"color:#cc0000"
>
安装产品测试数据
</span>
即可。
</p>
<p>
如果您不想安装产品测试数据,请
<span
style=
"color:#cc0000"
>
点击
</span>
跳过按钮
</p>
<br/>
<br/>
<button
type=
"button"
class=
"btn btn-default dbNext"
>
安装产品测试数据
</button>
<button
type=
"button"
class=
"btn btn-default dbSkip"
>
跳过
</button>
<script>
// add to cart js
<?php
$this
->
beginBlock
(
'dbNext'
)
?>
$
(
document
).
ready
(
function
(){
$
(
"
.dbNext
"
).
click
(
function
(){
window
.
location
.
href
=
"
<?=
$nextUrl
?>
"
;
});
$
(
"
.dbSkip
"
).
click
(
function
(){
window
.
location
.
href
=
"
<?=
$skipUrl
?>
"
;
});
});
<?php
$this
->
endBlock
();
?>
<?php
$this
->
registerJs
(
$this
->
blocks
[
'dbNext'
],
\
yii\web\View
::
POS_END
);
//将编写的js代码注册到页面底部 ?>
</
script
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录