系统安装跳过云编译和插件安装

This commit is contained in:
赵海雷 2026-09-30 19:35:07 +08:00
parent 0866419430
commit d6e965ba1b
5 changed files with 132 additions and 561 deletions

View File

@ -113,14 +113,6 @@ class Index extends BaseInstall
}
}
public function build()
{
$install_user = Cache::get('install_user');
$token = ( new LoginService() )->login($install_user[ 'username' ], $install_user[ 'password' ]);
$this->assign('token', $token[ 'token' ]);
return $this->fetch('index/step-4');
}
/**
* 安装成功
* @return string
@ -130,7 +122,7 @@ class Index extends BaseInstall
Cache::delete('install_data');
Cache::delete('install_status');
$this->assign('is_build', request()->get('is_build', 1));
return $this->fetch('index/step-5');
return $this->fetch('index/step-4');
}
/**
@ -381,9 +373,6 @@ class Index extends BaseInstall
]);
}
// 安装插件
$this->installAddon();
$fp = fopen($this->lock_file, 'wb');
if (!$fp) {
$this->setSuccessLog([ "写入失败,请检查目录" . dirname(__FILE__, 2) . "是否可写入!'", 'error' ]);
@ -404,42 +393,6 @@ class Index extends BaseInstall
}
}
/**
* 安装插件
* @return true
*/
public function installAddon()
{
$root_path = str_replace("\\", DIRECTORY_SEPARATOR, dirname(__FILE__, 4));
$root_path = str_replace("../", DIRECTORY_SEPARATOR, $root_path);
$addon_path = $root_path . DIRECTORY_SEPARATOR . 'addon';
$files = get_files_by_dir($addon_path);
if (!empty($files)) {
$addon = [];
foreach ($files as $path) {
$data = ( new CoreAddonService() )->getAddonConfig($path);
if (isset($data[ 'key' ])) {
if ($data[ 'type' ] == 'app') {
$install_service = ( new CoreAddonInstallService($data[ 'key' ]) );
$install_service->installCheck();
$install_service->install();
} else {
$addon[] = $data;
}
}
}
if (!empty($addon)) {
foreach ($addon as $k => $v) {
$install_service = ( new CoreAddonInstallService($v[ 'key' ]) );
$install_service->installCheck();
$install_service->install();
}
}
}
return true;
}
/**
* 安装sql
* @param array $data

View File

@ -59,14 +59,8 @@
<div id="point2" class="c-step"></div>
</div>
</div>
<div class="processBar">
<div class="text" style="margin: 10px -50px;"><span class='poetry'>4.代码编译</span></div>
<div id="line3" class="bar">
<div id="point3" class="c-step"></div>
</div>
</div>
<div class="processBar" style="width:10px;">
<div class="text" style="margin: 10px -39px;"><span class='poetry'>5.安装完成</span></div>
<div class="text" style="margin: 10px -39px;"><span class='poetry'>4.安装完成</span></div>
<div id="line4" class="bar" style="width: 0;">
<div id="point4" class="c-step"></div>
</div>

View File

@ -326,7 +326,7 @@
success : function(data) {
if(data.code == 1){
installAfterData(function(){
window.location.href = '{$root_url}/install.php/index/build';
window.location.href = '{$root_url}/install.php/index/installSuccess';
})
}
}

View File

@ -1,376 +1,143 @@
{extend name="base"/}
{block name="resources"}
<style>
.layui-layer-title {
border-bottom: 0!important;
}
.auth-layer {
padding: 20px;
}
.auth-layer .layui-form-item {
margin-bottom: 18px;
position: relative;
}
.auth-layer .layui-form-item .error {
color: red;
font-size: 12px;
position: absolute;
line-height: 1;
top: 42px;
display: none;
}
.auth-layer .layui-form-item button,.auth-layer .layui-form-item .layui-input {
height: 40px;
width: 100%;
}
.auth-layer .layui-form-item .layui-word-aux {
line-height: 1;
}
.auth-layer .to-buy {
text-align: right;
}
.auth-layer .to-buy a {
height: 40px;
line-height: 40px;
color: #409eff;
border: 1px solid #409eff;
display:block;
text-align: center;
border-radius: 2px;
}
.auth-layer .link {
text-align: right;
margin-bottom: 0;
}
.auth-layer .link a {
color: #409eff;
}
.build-warp {
margin-left: 50px;
padding: 20px;
margin-right: 50px;
background: #F7F9FA;
border-radius: 5px;
height: 60vh;
overflow-y: scroll;
}
.build-warp::-webkit-scrollbar {
width: 6px;
border-radius: 4px;
}
.build-warp::-webkit-scrollbar-track {
background-color: rgba(0, 0, 0, 0.1);
}
.build-warp::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.3);
border-radius: 4px;
}
.build-warp .msg-item {
margin: 20px 0;
}
.build-warp .msg-item p {
white-space: pre-wrap;
font-size: 13px;
font-family: Monaco,Menlo,Consolas,monospace;
}
.build-log .msg-item:first-child {
margin-top: 0;
}
.build-warp .msg-item .symbol {
margin-right: 10px;
}
.build-warp .msg-item .error {
background-color: #c0392b;
margin-right: 10px;
padding: 2px 3px;
color: #fff;
line-height: 1;
font-size: 12px;
}
.build-warp .build-progress {
display: none;
}
.install-content-procedure .content-procedure-item:first-of-type{
background: url("INSTALL_IMG/complete_two.png") no-repeat center / contain;
color: #fff;
}
.install-content-procedure .content-procedure-item:nth-child(2), .install-content-procedure .content-procedure-item:nth-child(3){
background: url("INSTALL_IMG/complete_four.png") no-repeat center / contain;
color: #fff;
}
.install-content-procedure .content-procedure-item:nth-child(4){
background: url("INSTALL_IMG/complete_three.png") no-repeat center / contain;
color: #fff;
}
.install-content-procedure{border: none;}
.pop-link-wrap{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.pop-link-wrap .link-text{
font-size: 14px;
}
.pop-link-wrap .link-text:nth-child(2){
margin-top: 10px;
}
.pop-link-wrap .link-text:nth-child(2) a{
color: var(--base-color);
}
.pop-link-wrap .link-btn{
margin-top: 40px;
}
.pop-link-wrap button{
width: 160px;
height: 40px;
background: var(--base-color);
color: #fff !important;
}
</style>
{/block}
{block name="main"}
<div class="build-warp">
<div class="build-log"></div>
<div class="build-progress">
<div class="msg-item">
<span class="symbol"> > </span>
<span class="content"></span>
</div>
</div>
<div class="install-success">
<div class="install-success-box">
<div class="success-img">
<img class="install-success-pic" src="INSTALL_IMG/success_img.png" alt="">
</div>
<div class="install-success-text">
{if $is_build == 1}
<p class="install-success-title">恭喜您!已成功安装{$install_config.website_name}。</p>
{/if}
{if $is_build == 0}
<p class="install-success-title">安装过程已结束,您还需要手动编译,才能正常使用! </p>
<p class="install-success-desc">如何手动编译请参考如下链接 <a href="{$install_config.build_manual}" target="_blank">{$install_config.build_manual}</a></p>
{/if}
<p class="install-success-desc">建议删除安装目录install后使用</p>
</div>
</div>
</div>
<div class="other-links">
<div class="back">
<p class="other-links-title">您现在可以访问:</p>
<ul class="other-links-list">
<li class="other-links-item" onclick="visitFn('admin')">
<div class="other-links-pic">
<img src="INSTALL_IMG/web.jpg" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >网站后台</a>
</li>
<li class="other-links-item" onclick="visitFn('web')">
<div class="other-links-pic">
<img src="INSTALL_IMG/site_web.png" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >网站电脑端</a>
</li>
<li class="other-links-item" onclick="visitFn('wap')">
<div class="other-links-pic">
<img src="INSTALL_IMG/site_h5.png" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >网站手机端</a>
</li>
{notempty name="$install_config['website_url']"}
<li class="other-links-item" onclick="window.open('{$install_config.website_url}')">
<div class="other-links-pic">
<img src="INSTALL_IMG/admin.jpg" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >{$install_config.website_name}官方网站</a>
</li>
{/notempty}
</ul>
</div>
</div>
<div class="other-links"></div>
<template id="authLayer">
<div class="layui-form auth-layer">
<div class="bind-auth layui-hide">
<div class="layui-form-item">
<input type="text" name="auth_code" placeholder="请输入授权码" autocomplete="off" class="layui-input">
<div class="error">请输入授权码</div>
</div>
<div class="layui-form-item">
<input type="text" name="auth_secret" placeholder="请输入授权秘钥" autocomplete="off" class="layui-input">
<div class="error">请输入授权秘钥</div>
</div>
<div class="layui-form-item">
<button class="layui-btn" lay-submit lay-filter="authInfoForm">立即绑定</button>
</div>
<div class="layui-form-item to-buy">
<a href="javascript:;" onclick="prev()">返回上一步</a>
</div>
</div>
<div class="options">
<div class="layui-form-item">
<button class="layui-btn" onclick="toBindAuthCode()">已授权,立即绑定授权</button>
</div>
<div class="layui-form-item to-buy">
<a href="javascript:;" onclick="installSuccess(0)" target="_blank">我是开发者,自行编译</a>
</div>
<div class="layui-form-item to-buy">
<a href="javascript:;" onclick="applyExperience()" style="color:#21ba45;border-color:#21ba45;">立即安装使用免费版</a>
</div>
{notempty name="$install_config['build_manual']"}
<div class="layui-form-item link">
<a href="{$install_config['build_manual']}" target="_blank">安装帮助指引</a>
</div>
{/notempty}
</div>
</div>
</template>
{/block}
{block name="script"}
<script>
ControlContent(3);
ControlContent(4);
const visitFn = (type)=>{
let tips = window.localStorage.getItem('pageToLinkTips')
if(tips){
pageToLink(type)
return false
}
layer.open({
type: 1, // page 层类型
area: ['400px', '230px'],
title: '提示',
shade: 0.6, // 遮罩透明度
shadeClose: true, // 点击遮罩区域,关闭弹层
anim: 0, // 0-6 的动画形式,-1 不开启
content: `
<div class="pop-link-wrap">
<p class="link-text">首次运行,请配置伪静态,才能正常使用。</p>
<p class="link-text">伪静态如何配置请<a href="https://www.kancloud.cn/niushop/niushop_v6/3226724" class="other-links-text" target="_blank">参考手册</a></p>
<p class="link-btn">
<button onclick="pageToLink('${type}')" class="layui-btn visit-btn layui-border">确定</button>
<button onclick="pageToLink('${type}', ${true})" class="layui-btn visit-btn layui-border">已配置,不需要在提示</button>
</p>
</div>
`
});
}
const REQUEST_HEADER = { token: '{$token}' }
var authinfo = null
var form = null
var submitTag = false
layui.use('form', function(){
form = layui.form;
form.on('submit(authInfoForm)', function(data){
var isVerify = true
if ($('[name="auth_code"]').val() == '') {
$('[name="auth_code"]').next().show()
isVerify = false
} else {
$('[name="auth_code"]').next().hide()
}
if ($('[name="auth_secret"]').val() == '') {
$('[name="auth_secret"]').next().show()
isVerify = false
} else {
$('[name="auth_secret"]').next().hide()
}
isVerify && bindAuthCode()
});
});
function toBindAuthCode() {
$('.bind-auth').removeClass('layui-hide')
$('.options').addClass('layui-hide')
}
function prev() {
$('.bind-auth').addClass('layui-hide')
$('.options').removeClass('layui-hide')
}
function bindAuthCode() {
if (submitTag) return
submitTag = true
$.ajax({
url: '{$root_url}/index.php/adminapi/niucloud/authinfo',
headers: REQUEST_HEADER,
data: {
auth_code: $('[name="auth_code"]').val(),
auth_secret: $('[name="auth_secret"]').val()
},
type: "post",
dataType: 'json',
success: function(res){
if (res.code) {
layer.closeAll()
$('.build-progress').show()
getCloudBuildTask()
} else {
layer.msg(res.msg)
}
submitTag = false
}
});
}
function applyExperience() {
if (submitTag) return
submitTag = true
$.ajax({
url: '{$root_url}/index.php/adminapi/niucloud/apply/experience',
headers: REQUEST_HEADER,
type: "get",
dataType: 'json',
success: function(res){
if (res.code) {
layer.closeAll()
$('.build-progress').show()
getCloudBuildTask()
} else {
layer.msg(res.msg)
}
submitTag = false
}
});
}
// 获取授权信息
function getAuthinfo() {
$.ajax({
url: '{$root_url}/index.php/adminapi/niucloud/authinfo',
headers: REQUEST_HEADER,
type: "get",
async: false,
dataType: 'json',
success: function(res){
if (res.code && res.data) {
getCloudBuildTask()
} else {
showAuthLayer()
}
}
});
}
getAuthinfo()
function showAuthLayer() {
layer.open({
type: 1,
title: '绑定授权码云编译',
area: ['400px'],
content: $('#authLayer').html(),
btn: [],
closeBtn: false
});
}
function installSuccess(isBuild = 1) {
window.location.href = '{$root_url}/install.php/index/installSuccess' + (isBuild ? '' : '?is_build=0');
}
function buildProgress() {
const frames = makeIterator(['/', '—', '\\', '|'])
setInterval(() => {
$('.build-progress .content').text(frames.next().value)
}, 150)
}
buildProgress()
function makeIterator(array) {
var nextIndex = 0
return {
next() {
if ((nextIndex + 1) == array.length) {
nextIndex = 0
}
return { value: array[nextIndex++] }
}
}
}
function getCloudBuildTask() {
$.ajax({
url: '{$root_url}/index.php/adminapi/niucloud/build',
headers: REQUEST_HEADER,
type: "get",
dataType: 'json',
success: function(res){
if (res.data) {
getCloudBuildLog()
} else {
cloudBuild()
}
}
});
}
var cloudBuildLog = []
function getCloudBuildLog() {
$.ajax({
url: '{$root_url}/index.php/adminapi/niucloud/build/log',
headers: REQUEST_HEADER,
type: "get",
dataType: 'json',
success: function(res){
if (!res.data) {
if (cloudBuildLog.length) {
installSuccess()
}
return
}
const data = res.data.data ?? []
let error = ''
if (data[0] && data[0].length) {
if (cloudBuildLog.length == 0) {
$('.build-progress').show()
$('.build-log').html('')
}
data[0].forEach(item => {
if (!cloudBuildLog.includes(item.action)) {
$('.build-log').append(`<div class="msg-item"><span class="symbol"> > </span><span class="content">正在执行:${item.action}</span></div>`)
cloudBuildLog.push(item.action)
if (item.code == 0) {
error = item.msg
$('.build-log').append(`<div class="msg-item"><span class="symbol"> > </span><span class="error">error</span><span class="content">${item.msg}</span></div>`)
$('.build-log').append(`<div class="msg-item"><span class="symbol"> > </span><span class="content">编译失败请不要关闭当前页面,请访问官方网站联系客服解决处理问题</span></div>`)
}
}
})
}
if (error) {
$('.build-progress').hide()
return
}
setTimeout(() => {
getCloudBuildLog()
}, 2000)
}
});
}
function cloudBuild() {
$.ajax({
url: '{$root_url}/index.php/adminapi/niucloud/build/install',
headers: REQUEST_HEADER,
type: "post",
dataType: 'json',
success: function(res){
if (res.code) {
getCloudBuildLog()
} else {
if (res.msg.indexOf('队列') != -1) {
$('.build-log').append(`<div class="msg-item"><span class="symbol"> > </span><span class="content">一键云安装小程序队列任务过多,请耐心等待</span></div>`)
setTimeout(function (){
cloudBuild()
}, 10000)
} else {
$('.build-log').append(`<div class="msg-item"><span class="symbol"> > </span><span class="error">error</span><span class="content">${res.msg}</span></div>`)
$('.build-log').append(`<div class="msg-item"><span class="symbol"> > </span><span class="content">编译失败请不要关闭当前页面,请访问官方网站联系客服解决处理问题</span></div>`)
}
}
}
})
}
// 页面跳转
function pageToLink(type,flag = false){
if(flag){
window.localStorage.setItem('pageToLinkTips', true)
}
if(type == 'admin'){
layer.closeAll()
window.open('{$root_url}/admin/')
}else if(type == 'web'){
layer.closeAll()
window.open('{$root_url}/web/')
}else if(type == 'wap'){
layer.closeAll()
window.open('{$root_url}/wap/')
}
}
</script>
{/block}

View File

@ -1,143 +0,0 @@
{extend name="base"/}
{block name="resources"}
<style>
.install-content-procedure .content-procedure-item:first-of-type{
background: url("INSTALL_IMG/complete_two.png") no-repeat center / contain;
color: #fff;
}
.install-content-procedure .content-procedure-item:nth-child(2), .install-content-procedure .content-procedure-item:nth-child(3){
background: url("INSTALL_IMG/complete_four.png") no-repeat center / contain;
color: #fff;
}
.install-content-procedure .content-procedure-item:nth-child(4){
background: url("INSTALL_IMG/complete_three.png") no-repeat center / contain;
color: #fff;
}
.install-content-procedure{border: none;}
.pop-link-wrap{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.pop-link-wrap .link-text{
font-size: 14px;
}
.pop-link-wrap .link-text:nth-child(2){
margin-top: 10px;
}
.pop-link-wrap .link-text:nth-child(2) a{
color: var(--base-color);
}
.pop-link-wrap .link-btn{
margin-top: 40px;
}
.pop-link-wrap button{
width: 160px;
height: 40px;
background: var(--base-color);
color: #fff !important;
}
</style>
{/block}
{block name="main"}
<div class="install-success">
<div class="install-success-box">
<div class="success-img">
<img class="install-success-pic" src="INSTALL_IMG/success_img.png" alt="">
</div>
<div class="install-success-text">
{if $is_build == 1}
<p class="install-success-title">恭喜您!已成功安装{$install_config.website_name}。</p>
{/if}
{if $is_build == 0}
<p class="install-success-title">安装过程已结束,您还需要手动编译,才能正常使用! </p>
<p class="install-success-desc">如何手动编译请参考如下链接 <a href="{$install_config.build_manual}" target="_blank">{$install_config.build_manual}</a></p>
{/if}
<p class="install-success-desc">建议删除安装目录install后使用</p>
</div>
</div>
</div>
<div class="other-links">
<div class="back">
<p class="other-links-title">您现在可以访问:</p>
<ul class="other-links-list">
<li class="other-links-item" onclick="visitFn('admin')">
<div class="other-links-pic">
<img src="INSTALL_IMG/web.jpg" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >网站后台</a>
</li>
<li class="other-links-item" onclick="visitFn('web')">
<div class="other-links-pic">
<img src="INSTALL_IMG/site_web.png" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >网站电脑端</a>
</li>
<li class="other-links-item" onclick="visitFn('wap')">
<div class="other-links-pic">
<img src="INSTALL_IMG/site_h5.png" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >网站手机端</a>
</li>
{notempty name="$install_config['website_url']"}
<li class="other-links-item" onclick="window.open('{$install_config.website_url}')">
<div class="other-links-pic">
<img src="INSTALL_IMG/admin.jpg" alt="">
</div>
<a href="javascript:void(0)" class="other-links-text" >{$install_config.website_name}官方网站</a>
</li>
{/notempty}
</ul>
</div>
</div>
{/block}
{block name="script"}
<script>
ControlContent(4);
const visitFn = (type)=>{
let tips = window.localStorage.getItem('pageToLinkTips')
if(tips){
pageToLink(type)
return false
}
layer.open({
type: 1, // page 层类型
area: ['400px', '230px'],
title: '提示',
shade: 0.6, // 遮罩透明度
shadeClose: true, // 点击遮罩区域,关闭弹层
anim: 0, // 0-6 的动画形式,-1 不开启
content: `
<div class="pop-link-wrap">
<p class="link-text">首次运行,请配置伪静态,才能正常使用。</p>
<p class="link-text">伪静态如何配置请<a href="https://www.kancloud.cn/niushop/niushop_v6/3226724" class="other-links-text" target="_blank">参考手册</a></p>
<p class="link-btn">
<button onclick="pageToLink('${type}')" class="layui-btn visit-btn layui-border">确定</button>
<button onclick="pageToLink('${type}', ${true})" class="layui-btn visit-btn layui-border">已配置,不需要在提示</button>
</p>
</div>
`
});
}
// 页面跳转
function pageToLink(type,flag = false){
if(flag){
window.localStorage.setItem('pageToLinkTips', true)
}
if(type == 'admin'){
layer.closeAll()
window.open('{$root_url}/admin/')
}else if(type == 'web'){
layer.closeAll()
window.open('{$root_url}/web/')
}else if(type == 'wap'){
layer.closeAll()
window.open('{$root_url}/wap/')
}
}
</script>
{/block}