2019-02-19 09:52:13 +00:00
|
|
|
/*
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
| SkyCaiji (蓝天采集器)
|
|
|
|
|--------------------------------------------------------------------------
|
2019-06-23 02:20:58 +00:00
|
|
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
2019-02-19 09:52:13 +00:00
|
|
|
|--------------------------------------------------------------------------
|
2019-06-23 02:20:58 +00:00
|
|
|
| 使用协议 https://www.skycaiji.com/licenses
|
2019-02-19 09:52:13 +00:00
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
*/
|
2019-06-23 02:20:58 +00:00
|
|
|
'use strict';function DevelopClass(){this.packTypes={};this.downFrameworkSize=0;this.downFrameworkNum=0}
|
2019-02-19 09:52:13 +00:00
|
|
|
DevelopClass.prototype={constructor:DevelopClass,release_cms:function(config){var $_o=this;$('#form_cms select[name="cms_name"]').bind('change',function(){if($(this).val()=='custom'){$('#cms_name_custom').show()}else{$('#cms_name_custom').hide()}});$('#add_param').bind('click',function(){windowModal('参数',ulink('Develop/cmsAddParam'))});$('#param_list').on('click','.param-key',function(){var parentObj=$(this).parents('tr[id^="param_"]').eq(0);var paramval=parentObj.find('input[name="params[]"]').val();var objid=parentObj.attr('id');windowModal('参数',ulink('Develop/cmsAddParam?objid=_objid_¶m=_param_',{'_objid_':objid,'_param_':paramval}))});$('#param_list').on('click','.delete-param',function(){$(this).parents('tr').eq(0).remove()});if(config&&!$.isEmptyObject(config)){$('#form_cms [name="name"]').val(config.name);var cmsnameOpt=$('#form_cms [name="cms_name"] option[value="'+config.cms_name+'"]');if(cmsnameOpt.length>0){$('#form_cms [name="cms_name"]').val(config.cms_name)}else{$('#form_cms [name="cms_name"]').val('custom').trigger('change');$('#form_cms [name="cms_name_custom"]').val(config.cms_name)}
|
|
|
|
$('#form_cms [name="identifier"]').val(config.identifier);$('#form_cms [name="copyright"]').val(config.copyright);if(config.is_edit){$('#form_cms [name="cms_name"]').attr("disabled","disabled");$('#form_cms [name="cms_name_custom"]').attr("disabled","disabled");$('#form_cms [name="identifier"]').attr("disabled","disabled");$('#form_cms [name="copyright"]').attr("disabled","disabled")}
|
2020-05-17 16:36:31 +00:00
|
|
|
if(config.params){for(var i in config.params){$_o.add_cms_param(config.params[i])}}}},init_cms_param:function(){var $_o=this;$('#win_form_param select[name="param[type]"]').bind('change',function(){$('#win_form_param .param-type-select').hide();var curType=$(this).val();if(curType=='select_val'||curType=='select_func'){$('#win_form_param .param-type-select[data-select="'+curType+'"]').show()}});$('#win_form_param').submit(function(){var checkKey=!0;var curKey=$('#win_form_param [name="param[key]"]').val();var objid=$('#win_form_param input[name="objid"]').val();if(objid){if(curKey==$('#'+objid).find('.param-key').attr('data-val')){checkKey=!1}}
|
|
|
|
if(checkKey){var hasKey=!1;$('#param_list .param-key').each(function(){if(curKey==$(this).attr('data-val')){hasKey=!0;return!1}});if(hasKey){toastr.error('变量名已存在!');return!1}}
|
|
|
|
$.ajax({type:'POST',dataType:'json',url:$(this).attr('action'),data:$(this).serialize(),success:function(data){if(data.code==1){$_o.add_cms_param(data.data,objid);$('#myModal').modal('hide')}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1})},load_cms_param:function(param){if(param){$('#win_form_param [name="param[key]"]').val(param.key);$('#win_form_param [name="param[require]"][value="'+param.require+'"]').prop('checked',!0);$('#win_form_param [name="param[name]"]').val(param.name);$('#win_form_param [name="param[type]"]').val(param.type).trigger('change');$('#win_form_param [name="param[select_val]"]').val(param.select_val);$('#win_form_param [name="param[select_func]"]').val(param.select_func)}},add_cms_param:function(param,objid){var paramHtml='<td><a href="javascript:;" class="param-key" data-val="_keyval_">_key_</a></td><td>_require_</td><td>_name_</td><td>_type_</td>'+'<td><a href="javascript:;" class="glyphicon glyphicon-remove delete-param"></a><input type="hidden" name="params[]" value="_param_"/></td>';paramHtml=paramHtml.replace('_keyval_',param.key).replace('_key_',param.key).replace('_require_',(param.require>0?'是':'否')).replace('_name_',param.name).replace('_type_',param.type_name).replace('_param_',url_base64encode(JSON.stringify(param)));if(objid){$('#'+objid).html(paramHtml)}else{$('#param_list tbody').append('<tr id="param_'+generateUUID()+'">'+paramHtml+'</tr>')}},app:function(app){var $_o=this;$('#newest_version').bind('click',function(){confirmRight('确定升级至新版本?',function(){var app=$('#form_app [name="app"]').val();windowModal('正在升级...',ulink('Admin/App/upgrade?app=_app_',{'_app_':app}))})});$('#add_pack').bind('click',function(){windowModal('扩展',ulink('Develop/appAddPack'))});$('#pack_list').on('click','.pack-name',function(){var parentObj=$(this).parents('tr[id^="pack_"]').eq(0);var packval=parentObj.find('input[name="packs[]"]').val();var objid=parentObj.attr('id');windowModal('扩展',ulink('Develop/appAddPack?objid=_objid_&pack=_pack_',{'_objid_':objid,'_pack_':packval}))});$('#pack_list').on('click','.delete-pack',function(){$(this).parents('tr').eq(0).remove()});eleExchange('#pack_list','.up-pack','.down-pack','tr[id^="pack_"]');$('#form_app').on('change','select[name="framework"]',function(){$('[id^="framework_vers_"]').hide();var name=$(this).val();if(name){$('[id^="framework_vers_'+name+'"]').show()}});$('#form_app').on('click','#install_framework',function(){var btnObj=$(this);btnObj.attr('disabled',!0);btnObj.html('正在检索文件...');$.ajax({type:'get',dataType:'json',url:ulink('develop/installFramework?op=files&app='+$('#form_app [name="app"]').val()),success:function(data){if(data.code==1){var list=data.data;btnObj.html('<span class="status">正在下载...</span> <span class="num">'+$_o.downFrameworkSize+'</span>\/'+parseInt(list.size/1024)+'kb - <span class="perct">'+parseInt(($_o.downFrameworkSize/list.size)*100)+'</span>%');$_o.down_framework(list,list.list[0])}else{btnObj.attr('disabled',!1);$('#install_framework_error').html(data.msg?data.msg:'没有获取到文件')}}})});if(app){if(app.config){var config=app.config;$('#form_app [name="name"]').val(config.name);$('#form_app [name="desc"]').val(config.desc);$('#form_app [name="app"]').val(app.app);$('#form_app [name="website"]').val(config.website);$('#form_app [name="author"]').val(config.author);$('#form_app [name="version"]').val(config.version);$('#form_app [name="phpv"]').val(config.phpv);$('#form_app [name="agreement"]').val(config.agreement);$('#form_app select[name="framework"]').val(config.framework).trigger('change');if(config.framework){$('input[type="radio"][name="framework_version['+config.framework+']"][value="'+config.framework_version+'"]').prop('checked','checked')}
|
2019-06-23 02:20:58 +00:00
|
|
|
if(config.packs){for(var i in config.packs){$_o.add_app_pack(config.packs[i])}}}
|
2020-05-17 16:36:31 +00:00
|
|
|
if(app.app_class){var appClass=app.app_class;$('#form_app [name="install"]').val(appClass.install);$('#form_app [name="uninstall"]').val(appClass.uninstall);$('#form_app [name="upgrade"]').val(appClass.upgrade)}}},add_app_pack:function(pack,objid){var packHtml='<td><a href="javascript:;" class="pack-name" data-val="_nameval_">_name_</a></td><td>_type_</td><td>_link_</td><td>'+'<a href="javascript:;" class="glyphicon glyphicon-arrow-up up-pack" title="上移"></a>'+' <a href="javascript:;" class="glyphicon glyphicon-arrow-down down-pack" title="下移"></a>'+' <a href="javascript:;" class="glyphicon glyphicon-remove delete-pack" title="删除"></a>'+'<input type="hidden" name="packs[]" value="_pack_"/></td>';packHtml=packHtml.replace('_nameval_',pack.name).replace('_name_',pack.name).replace('_type_',this.packTypes[pack.type]).replace('_link_',pack.nav_link).replace('_pack_',url_base64encode(JSON.stringify(pack)));if(objid){$('#'+objid).html(packHtml)}else{$('#pack_list tbody').append('<tr id="pack_'+generateUUID()+'">'+packHtml+'</tr>')}},init_app_pack:function(){var $_o=this;$('#win_form_pack').submit(function(){var checkName=!0;var curName=$('#win_form_pack [name="pack[name]"]').val();var objid=$('#win_form_pack input[name="objid"]').val();if(objid){if(curName==$('#'+objid).find('.pack-name').attr('data-val')){checkName=!1}}
|
|
|
|
if(checkName){var hasName=!1;$('#pack_list .pack-name').each(function(){if(curName==$(this).attr('data-val')){hasName=!0;return!1}});if(hasName){toastr.error('名称已存在!');return!1}}
|
2019-09-25 07:45:58 +00:00
|
|
|
$.ajax({type:'POST',dataType:'json',url:$(this).attr('action'),data:$(this).serialize(),success:function(data){if(data.code==1){$_o.add_app_pack(data.data,objid);$('#myModal').modal('hide')}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1});$('#win_form_pack [name="pack[type]"]').bind('change',function(){var type=$(this).val();$(this).siblings('.help-block').each(function(){if($(this).hasClass('type-'+type)){$(this).show()}else{$(this).hide()}})})},load_app_pack:function(pack){if(pack){$('#win_form_pack [name="pack[name]"]').val(pack.name);$('#win_form_pack [name="pack[type]"]').val(pack.type).trigger('change');$('#win_form_pack [name="pack[nav_link]"]').val(pack.nav_link);$('#win_form_pack [name="pack[target]"][value="'+parseInt(pack.target)+'"]').prop('checked','checked')}},down_framework:function(list,size){var $_o=this;$.ajax({type:'get',dataType:'json',url:ulink('develop/installFramework?op=down&app='+$('#form_app [name="app"]').val()),data:{'size':list.size,'start_size':size.start,'end_size':size.end,'id':size.id},success:function(data){if(data.code==1){$_o.downFrameworkSize+=size.end-size.start+1;$_o.downFrameworkNum++;$('#install_framework').find('.num').text(parseInt($_o.downFrameworkSize/1024)+'kb');$('#install_framework').find('.perct').text(parseInt(($_o.downFrameworkSize/list.size)*100));if(list.list.length>size.id&&list.list[size.id]){$_o.down_framework(list,list.list[size.id])}}else{$('#install_framework_error').append('<p>下载片段文件'+size.id+'失败</p>')}},error:function(){$('#install_framework_error').append('<p>获取片段文件'+size.id+'失败</p>')},complete:function(){if($_o.downFrameworkNum==list.list.length){$('#install_framework').find('.num').text(parseInt(list.size/1024)+'kb');$('#install_framework').find('.perct').text(100);$('#install_framework').find('.status').text('下载完成,正在安装...');$.ajax({type:'get',dataType:'json',url:ulink('develop/installFramework?op=install&app='+$('#form_app [name="app"]').val()),data:{size:list.size},success:function(data){if(data.code==1){ajaxDataMsg(data)}else{$('#install_framework_error').html(data.msg?data.msg:'<p>文件缺失,请刷新界面重新下载</p>')}}})}}})},func:function(config){var $_o=this;$('#add_method').bind('click',function(){$_o.func_add_method()});$('#form_func').on('click','.delete-method',function(){$(this).parents('tr').remove()});if(config&&!$.isEmptyObject(config)){for(var i in config){$('#form_func [name="'+i+'"]').val(config[i])}
|
|
|
|
$('#form_func [name="module"]').attr('disabled','disabled');$('#form_func [name="identifier"]').attr('disabled','disabled');$('#form_func [name="copyright"]').attr('disabled','disabled')}},func_add_method:function(method,desc){method=method?method:'';desc=desc?desc:'';var tr='<tr><td><input type="text" name="methods[method][]" value="'+htmlspecialchars(method)+'" class="form-control" /></td>'+'<td><input type="text" name="methods[comment][]" class="form-control" value="'+htmlspecialchars(desc)+'" /></td>'+'<td><a href="javascript:;" class="glyphicon glyphicon-remove delete-method" style="margin-top:8px;"></a></td></tr>';$('#form_func table.method_list tbody').append(tr)}}
|
2019-02-19 09:52:13 +00:00
|
|
|
var developClass=new DevelopClass()
|