| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776 | 
							- define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
 
-     var Controller = {
 
-         index: function () {
 
-             // 初始化表格参数配置
 
-             Table.api.init({
 
-                 extend: {
 
-                     index_url: Config.api_url ? Config.api_url + '/addon/index' : "addon/downloaded",
 
-                     add_url: '',
 
-                     edit_url: '',
 
-                     del_url: '',
 
-                     multi_url: ''
 
-                 }
 
-             });
 
-             var table = $("#table");
 
-             // 弹窗自适应宽高
 
-             var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
 
-             var switch_local = function () {
 
-                 if ($(".btn-switch.active").data("type") != "local") {
 
-                     Layer.confirm(__('Store not available tips'), {
 
-                         title: __('Warmtips'),
 
-                         btn: [__('Switch to the local'), __('Try to reload')]
 
-                     }, function (index) {
 
-                         layer.close(index);
 
-                         $(".panel .nav-tabs").hide();
 
-                         $(".toolbar > *:not(:first)").hide();
 
-                         $(".btn-switch[data-type='local']").trigger("click");
 
-                     }, function (index) {
 
-                         layer.close(index);
 
-                         table.bootstrapTable('refresh');
 
-                     });
 
-                     return false;
 
-                 }
 
-             };
 
-             table.on('load-success.bs.table', function (e, json) {
 
-                 if (json && typeof json.category != 'undefined' && $(".nav-category li").length == 2) {
 
-                     $.each(json.category, function (i, j) {
 
-                         $("<li><a href='javascript:;' data-id='" + j.id + "'>" + j.name + "</a></li>").insertBefore($(".nav-category li:last"));
 
-                     });
 
-                 }
 
-                 if (typeof json.rows === 'undefined' && typeof json.code != 'undefined') {
 
-                     switch_local();
 
-                 }
 
-             });
 
-             table.on('load-error.bs.table', function (e, status, res) {
 
-                 console.log(e, status, res);
 
-                 switch_local();
 
-             });
 
-             table.on('post-body.bs.table', function (e, settings, json, xhr) {
 
-                 var parenttable = table.closest('.bootstrap-table');
 
-                 var d = $(".fixed-table-toolbar", parenttable).find(".search input");
 
-                 d.off("keyup drop blur");
 
-                 d.on("keyup", function (e) {
 
-                     if (e.keyCode == 13) {
 
-                         var that = this;
 
-                         var options = table.bootstrapTable('getOptions');
 
-                         var queryParams = options.queryParams;
 
-                         options.pageNumber = 1;
 
-                         options.queryParams = function (params) {
 
-                             var params = queryParams(params);
 
-                             params.search = $(that).val();
 
-                             return params;
 
-                         };
 
-                         table.bootstrapTable('refresh', {});
 
-                     }
 
-                 });
 
-             });
 
-             Template.helper("Moment", Moment);
 
-             Template.helper("addons", Config['addons']);
 
-             $("#faupload-addon").data("params", function () {
 
-                 var userinfo = Controller.api.userinfo.get();
 
-                 return {
 
-                     uid: userinfo ? userinfo.id : '',
 
-                     token: userinfo ? userinfo.token : '',
 
-                     version: Config.faversion
 
-                 };
 
-             });
 
-             // 初始化表格
 
-             table.bootstrapTable({
 
-                 url: $.fn.bootstrapTable.defaults.extend.index_url,
 
-                 pageSize: 50,
 
-                 queryParams: function (params) {
 
-                     var userinfo = Controller.api.userinfo.get();
 
-                     $.extend(params, {
 
-                         uid: userinfo ? userinfo.id : '',
 
-                         token: userinfo ? userinfo.token : '',
 
-                         domain: Config.domain,
 
-                         version: Config.faversion
 
-                     });
 
-                     return params;
 
-                 },
 
-                 columns: [
 
-                     [
 
-                         {field: 'id', title: 'ID', operate: false, visible: false},
 
-                         {
 
-                             field: 'home',
 
-                             title: __('Index'),
 
-                             width: '50px',
 
-                             formatter: Controller.api.formatter.home
 
-                         },
 
-                         {field: 'name', title: __('Name'), operate: false, visible: false, width: '120px'},
 
-                         {
 
-                             field: 'title',
 
-                             title: __('Title'),
 
-                             operate: 'LIKE',
 
-                             align: 'left',
 
-                             formatter: Controller.api.formatter.title
 
-                         },
 
-                         {field: 'intro', title: __('Intro'), operate: 'LIKE', align: 'left', class: 'visible-lg'},
 
-                         {
 
-                             field: 'author',
 
-                             title: __('Author'),
 
-                             operate: 'LIKE',
 
-                             width: '100px',
 
-                             formatter: Controller.api.formatter.author
 
-                         },
 
-                         {
 
-                             field: 'price',
 
-                             title: __('Price'),
 
-                             operate: 'LIKE',
 
-                             width: '100px',
 
-                             align: 'center',
 
-                             formatter: Controller.api.formatter.price
 
-                         },
 
-                         {
 
-                             field: 'downloads',
 
-                             title: __('Downloads'),
 
-                             operate: 'LIKE',
 
-                             width: '80px',
 
-                             align: 'center',
 
-                             formatter: Controller.api.formatter.downloads
 
-                         },
 
-                         {
 
-                             field: 'version',
 
-                             title: __('Version'),
 
-                             operate: 'LIKE',
 
-                             width: '80px',
 
-                             align: 'center',
 
-                             formatter: Controller.api.formatter.version
 
-                         },
 
-                         {
 
-                             field: 'toggle',
 
-                             title: __('Status'),
 
-                             width: '80px',
 
-                             formatter: Controller.api.formatter.toggle
 
-                         },
 
-                         {
 
-                             field: 'id',
 
-                             title: __('Operate'),
 
-                             table: table,
 
-                             formatter: Controller.api.formatter.operate,
 
-                             align: 'right'
 
-                         },
 
-                     ]
 
-                 ],
 
-                 responseHandler: function (res) {
 
-                     $.each(res.rows, function (i, j) {
 
-                         j.addon = typeof Config.addons[j.name] != 'undefined' ? Config.addons[j.name] : null;
 
-                     });
 
-                     return res;
 
-                 },
 
-                 dataType: 'jsonp',
 
-                 templateView: false,
 
-                 clickToSelect: false,
 
-                 search: true,
 
-                 showColumns: false,
 
-                 showToggle: false,
 
-                 showExport: false,
 
-                 showSearch: false,
 
-                 commonSearch: true,
 
-                 searchFormVisible: true,
 
-                 searchFormTemplate: 'searchformtpl',
 
-             });
 
-             // 为表格绑定事件
 
-             Table.api.bindevent(table);
 
-             // 离线安装
 
-             require(['upload'], function (Upload) {
 
-                 Upload.api.upload("#faupload-addon", function (data, ret) {
 
-                     Config['addons'][data.addon.name] = data.addon;
 
-                     var addon = data.addon;
 
-                     var testdata = data.addon.testdata;
 
-                     operate(data.addon.name, 'enable', false, function (data, ret) {
 
-                         Layer.alert(__('Offline installed tips') + (testdata ? __('Testdata tips') : ""), {
 
-                             btn: testdata ? [__('Import testdata'), __('Skip testdata')] : [__('OK')],
 
-                             title: __('Warning'),
 
-                             yes: function (index) {
 
-                                 if (testdata) {
 
-                                     Fast.api.ajax({
 
-                                         url: 'addon/testdata',
 
-                                         data: {
 
-                                             name: addon.name,
 
-                                             version: addon.version,
 
-                                             faversion: Config.faversion
 
-                                         }
 
-                                     }, function (data, ret) {
 
-                                         Layer.close(index);
 
-                                     });
 
-                                 } else {
 
-                                     Layer.close(index);
 
-                                 }
 
-                             },
 
-                             icon: 1
 
-                         });
 
-                     });
 
-                     return false;
 
-                 }, function (data, ret) {
 
-                     if (ret.msg && ret.msg.match(/(login|登录)/g)) {
 
-                         return Layer.alert(ret.msg, {
 
-                             title: __('Warning'),
 
-                             btn: [__('Login now')],
 
-                             yes: function (index, layero) {
 
-                                 $(".btn-userinfo").trigger("click");
 
-                             }
 
-                         });
 
-                     }
 
-                 });
 
-                 // 检测是否登录
 
-                 $(document).on("mousedown", "#faupload-addon", function (e) {
 
-                     var userinfo = Controller.api.userinfo.get();
 
-                     var uid = userinfo ? userinfo.id : 0;
 
-                     if (parseInt(uid) === 0) {
 
-                         $(".btn-userinfo").trigger("click");
 
-                         return false;
 
-                     }
 
-                 });
 
-             });
 
-             // 查看插件首页
 
-             $(document).on("click", ".btn-addonindex", function () {
 
-                 if ($(this).attr("href") == 'javascript:;') {
 
-                     Layer.msg(__('Not installed tips'), {icon: 7});
 
-                 } else if ($(this).closest(".operate").find("a.btn-enable").length > 0) {
 
-                     Layer.msg(__('Not enabled tips'), {icon: 7});
 
-                     return false;
 
-                 }
 
-             });
 
-             // 切换
 
-             $(document).on("click", ".btn-switch", function () {
 
-                 $(".btn-switch").removeClass("active");
 
-                 $(this).addClass("active");
 
-                 $("form.form-commonsearch input[name='type']").val($(this).data("type"));
 
-                 var method = $(this).data("type") == 'local' ? 'hideColumn' : 'showColumn';
 
-                 table.bootstrapTable(method, 'price');
 
-                 table.bootstrapTable(method, 'downloads');
 
-                 table.bootstrapTable('refresh', {url: ($(this).data("url") ? $(this).data("url") : $.fn.bootstrapTable.defaults.extend.index_url), pageNumber: 1});
 
-                 return false;
 
-             });
 
-             // 切换分类
 
-             $(document).on("click", ".nav-category li a", function () {
 
-                 $(".nav-category li").removeClass("active");
 
-                 $(this).parent().addClass("active");
 
-                 $("form.form-commonsearch input[name='category_id']").val($(this).data("id"));
 
-                 table.bootstrapTable('refresh', {url: $(this).data("url"), pageNumber: 1});
 
-                 return false;
 
-             });
 
-             var tables = [];
 
-             $(document).on("click", "#droptables", function () {
 
-                 if ($(this).prop("checked")) {
 
-                     Fast.api.ajax({
 
-                         url: "addon/get_table_list",
 
-                         async: false,
 
-                         data: {name: $(this).data("name")}
 
-                     }, function (data) {
 
-                         tables = data.tables;
 
-                         return false;
 
-                     });
 
-                     var html;
 
-                     html = tables.length > 0 ? '<div class="alert alert-warning-light droptablestips" style="max-width:480px;max-height:300px;overflow-y: auto;">' + __('The following data tables will be deleted') + ':<br>' + tables.join("<br>") + '</div>'
 
-                         : '<div class="alert alert-warning-light droptablestips">' + __('The Addon did not create a data table') + '</div>';
 
-                     $(html).insertAfter($(this).closest("p"));
 
-                 } else {
 
-                     $(".droptablestips").remove();
 
-                 }
 
-                 $(window).resize();
 
-             });
 
-             // 会员信息
 
-             $(document).on("click", ".btn-userinfo", function (e, name, version) {
 
-                 var that = this;
 
-                 var area = [$(window).width() > 800 ? '500px' : '95%', $(window).height() > 600 ? '400px' : '95%'];
 
-                 var userinfo = Controller.api.userinfo.get();
 
-                 if (!userinfo) {
 
-                     Layer.open({
 
-                         content: Template("logintpl", {}),
 
-                         zIndex: 99,
 
-                         area: area,
 
-                         title: __('Login FastAdmin'),
 
-                         resize: false,
 
-                         btn: [__('Login'), __('Register')],
 
-                         yes: function (index, layero) {
 
-                             Fast.api.ajax({
 
-                                 url: Config.api_url + '/user/login',
 
-                                 type: 'post',
 
-                                 data: {
 
-                                     account: $("#inputAccount", layero).val(),
 
-                                     password: $("#inputPassword", layero).val(),
 
-                                     version: Config.faversion,
 
-                                 }
 
-                             }, function (data, ret) {
 
-                                 Controller.api.userinfo.set(data);
 
-                                 Layer.closeAll();
 
-                                 Layer.alert(ret.msg, {title: __('Warning'), icon: 1});
 
-                                 return false;
 
-                             }, function (data, ret) {
 
-                             });
 
-                         },
 
-                         btn2: function () {
 
-                             return false;
 
-                         },
 
-                         success: function (layero, index) {
 
-                             this.checkEnterKey = function (event) {
 
-                                 if (event.keyCode === 13) {
 
-                                     $(".layui-layer-btn0").trigger("click");
 
-                                     return false;
 
-                                 }
 
-                             };
 
-                             $(document).on('keydown', this.checkEnterKey);
 
-                             $(".layui-layer-btn1", layero).prop("href", "https://www.fastadmin.net/user/register.html").prop("target", "_blank");
 
-                         },
 
-                         end: function () {
 
-                             $(document).off('keydown', this.checkEnterKey);
 
-                         }
 
-                     });
 
-                 } else {
 
-                     Fast.api.ajax({
 
-                         url: Config.api_url + '/user/index',
 
-                         data: {
 
-                             uid: userinfo.id,
 
-                             token: userinfo.token,
 
-                             version: Config.faversion,
 
-                         }
 
-                     }, function (data) {
 
-                         Layer.open({
 
-                             content: Template("userinfotpl", userinfo),
 
-                             area: area,
 
-                             title: __('Userinfo'),
 
-                             resize: false,
 
-                             btn: [__('Logout'), __('Close')],
 
-                             yes: function () {
 
-                                 Fast.api.ajax({
 
-                                     url: Config.api_url + '/user/logout',
 
-                                     data: {uid: userinfo.id, token: userinfo.token, version: Config.faversion}
 
-                                 }, function (data, ret) {
 
-                                     Controller.api.userinfo.set(null);
 
-                                     Layer.closeAll();
 
-                                     Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
 
-                                 }, function (data, ret) {
 
-                                     Controller.api.userinfo.set(null);
 
-                                     Layer.closeAll();
 
-                                     Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
 
-                                 });
 
-                             }
 
-                         });
 
-                         return false;
 
-                     }, function (data) {
 
-                         Controller.api.userinfo.set(null);
 
-                         $(that).trigger('click');
 
-                         return false;
 
-                     });
 
-                 }
 
-             });
 
-             //刷新授权
 
-             $(document).on("click", ".btn-authorization", function () {
 
-                 var userinfo = Controller.api.userinfo.get();
 
-                 if (!userinfo) {
 
-                     $(".btn-userinfo").trigger("click");
 
-                     return false;
 
-                 }
 
-                 Layer.confirm(__('Are you sure you want to refresh authorization?'), {icon: 3, title: __('Warmtips')}, function () {
 
-                     Fast.api.ajax({
 
-                         url: 'addon/authorization',
 
-                         data: {
 
-                             uid: userinfo.id,
 
-                             token: userinfo.token
 
-                         }
 
-                     }, function (data, ret) {
 
-                         $(".btn-refresh").trigger("click");
 
-                         Layer.closeAll();
 
-                     });
 
-                 });
 
-                 return false;
 
-             });
 
-             var install = function (name, version, force) {
 
-                 var userinfo = Controller.api.userinfo.get();
 
-                 var uid = userinfo ? userinfo.id : 0;
 
-                 var token = userinfo ? userinfo.token : '';
 
-                 Fast.api.ajax({
 
-                     url: 'addon/install',
 
-                     data: {
 
-                         name: name,
 
-                         force: force ? 1 : 0,
 
-                         uid: uid,
 
-                         token: token,
 
-                         version: version,
 
-                         faversion: Config.faversion
 
-                     }
 
-                 }, function (data, ret) {
 
-                     Layer.closeAll();
 
-                     Config['addons'][data.addon.name] = ret.data.addon;
 
-                     operate(data.addon.name, 'enable', false, function () {
 
-                         Layer.alert(__('Online installed tips') + (data.addon.testdata ? __('Testdata tips') : ""), {
 
-                             btn: data.addon.testdata ? [__('Import testdata'), __('Skip testdata')] : [__('OK')],
 
-                             title: __('Warning'),
 
-                             yes: function (index) {
 
-                                 if (data.addon.testdata) {
 
-                                     Fast.api.ajax({
 
-                                         url: 'addon/testdata',
 
-                                         data: {
 
-                                             name: name,
 
-                                             uid: uid,
 
-                                             token: token,
 
-                                             version: version,
 
-                                             faversion: Config.faversion
 
-                                         }
 
-                                     }, function (data, ret) {
 
-                                         Layer.close(index);
 
-                                     });
 
-                                 } else {
 
-                                     Layer.close(index);
 
-                                 }
 
-                             },
 
-                             icon: 1
 
-                         });
 
-                         Controller.api.refresh(table, name);
 
-                     });
 
-                 }, function (data, ret) {
 
-                     var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 650 ? '650px' : '95%', $(window).height() > 710 ? '710px' : '95%'];
 
-                     if (ret && ret.code === -2) {
 
-                         //如果登录已经超时,重新提醒登录
 
-                         if (uid && uid != ret.data.uid) {
 
-                             Controller.api.userinfo.set(null);
 
-                             $(".operate[data-name='" + name + "'] .btn-install").trigger("click");
 
-                             return;
 
-                         }
 
-                         top.Fast.api.open(ret.data.payurl, __('Pay now'), {
 
-                             area: area,
 
-                             end: function () {
 
-                                 Fast.api.ajax({
 
-                                     url: 'addon/isbuy',
 
-                                     data: {
 
-                                         name: name,
 
-                                         force: force ? 1 : 0,
 
-                                         uid: uid,
 
-                                         token: token,
 
-                                         version: version,
 
-                                         faversion: Config.faversion
 
-                                     }
 
-                                 }, function () {
 
-                                     top.Layer.alert(__('Pay successful tips'), {
 
-                                         btn: [__('Continue installation')],
 
-                                         title: __('Warning'),
 
-                                         icon: 1,
 
-                                         yes: function (index) {
 
-                                             top.Layer.close(index);
 
-                                             install(name, version);
 
-                                         }
 
-                                     });
 
-                                     return false;
 
-                                 }, function () {
 
-                                     console.log(__('Canceled'));
 
-                                     return false;
 
-                                 });
 
-                             }
 
-                         });
 
-                     } else if (ret && ret.code === -3) {
 
-                         //插件目录发现影响全局的文件
 
-                         Layer.open({
 
-                             content: Template("conflicttpl", ret.data),
 
-                             shade: 0.8,
 
-                             area: area,
 
-                             title: __('Warning'),
 
-                             btn: [__('Continue install'), __('Cancel')],
 
-                             end: function () {
 
-                             },
 
-                             yes: function () {
 
-                                 install(name, version, true);
 
-                             }
 
-                         });
 
-                     } else {
 
-                         Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
 
-                     }
 
-                     return false;
 
-                 });
 
-             };
 
-             var uninstall = function (name, force, droptables) {
 
-                 Fast.api.ajax({
 
-                     url: 'addon/uninstall',
 
-                     data: {name: name, force: force ? 1 : 0, droptables: droptables ? 1 : 0}
 
-                 }, function (data, ret) {
 
-                     delete Config['addons'][name];
 
-                     Layer.closeAll();
 
-                     Controller.api.refresh(table, name);
 
-                 }, function (data, ret) {
 
-                     if (ret && ret.code === -3) {
 
-                         //插件目录发现影响全局的文件
 
-                         Layer.open({
 
-                             content: Template("conflicttpl", ret.data),
 
-                             shade: 0.8,
 
-                             area: area,
 
-                             title: __('Warning'),
 
-                             btn: [__('Continue uninstall'), __('Cancel')],
 
-                             end: function () {
 
-                             },
 
-                             yes: function () {
 
-                                 uninstall(name, true, droptables);
 
-                             }
 
-                         });
 
-                     } else {
 
-                         Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
 
-                     }
 
-                     return false;
 
-                 });
 
-             };
 
-             var operate = function (name, action, force, success) {
 
-                 Fast.api.ajax({
 
-                     url: 'addon/state',
 
-                     data: {name: name, action: action, force: force ? 1 : 0}
 
-                 }, function (data, ret) {
 
-                     var addon = Config['addons'][name];
 
-                     addon.state = action === 'enable' ? 1 : 0;
 
-                     Layer.closeAll();
 
-                     if (typeof success === 'function') {
 
-                         success(data, ret);
 
-                     }
 
-                     Controller.api.refresh(table, name);
 
-                 }, function (data, ret) {
 
-                     if (ret && ret.code === -3) {
 
-                         //插件目录发现影响全局的文件
 
-                         Layer.open({
 
-                             content: Template("conflicttpl", ret.data),
 
-                             shade: 0.8,
 
-                             area: area,
 
-                             title: __('Warning'),
 
-                             btn: [__('Continue operate'), __('Cancel')],
 
-                             end: function () {
 
-                             },
 
-                             yes: function () {
 
-                                 operate(name, action, true, success);
 
-                             }
 
-                         });
 
-                     } else {
 
-                         Layer.alert(ret.msg, {title: __('Warning'), icon: 0});
 
-                     }
 
-                     return false;
 
-                 });
 
-             };
 
-             var upgrade = function (name, version) {
 
-                 var userinfo = Controller.api.userinfo.get();
 
-                 var uid = userinfo ? userinfo.id : 0;
 
-                 var token = userinfo ? userinfo.token : '';
 
-                 Fast.api.ajax({
 
-                     url: 'addon/upgrade',
 
-                     data: {name: name, uid: uid, token: token, version: version, faversion: Config.faversion}
 
-                 }, function (data, ret) {
 
-                     Config['addons'][name] = data.addon;
 
-                     Layer.closeAll();
 
-                     Controller.api.refresh(table, name);
 
-                 }, function (data, ret) {
 
-                     Layer.alert(ret.msg, {title: __('Warning')});
 
-                     return false;
 
-                 });
 
-             };
 
-             // 点击安装
 
-             $(document).on("click", ".btn-install", function () {
 
-                 var that = this;
 
-                 var name = $(this).closest(".operate").data("name");
 
-                 var version = $(this).data("version");
 
-                 var userinfo = Controller.api.userinfo.get();
 
-                 var uid = userinfo ? userinfo.id : 0;
 
-                 if (parseInt(uid) === 0) {
 
-                     return Layer.alert(__('Not login tips'), {
 
-                         title: __('Warning'),
 
-                         btn: [__('Login now')],
 
-                         yes: function (index, layero) {
 
-                             $(".btn-userinfo").trigger("click", name, version);
 
-                         },
 
-                         btn2: function () {
 
-                             install(name, version, false);
 
-                         }
 
-                     });
 
-                 }
 
-                 install(name, version, false);
 
-             });
 
-             // 点击卸载
 
-             $(document).on("click", ".btn-uninstall", function () {
 
-                 var name = $(this).closest(".operate").data('name');
 
-                 if (Config['addons'][name].state == 1) {
 
-                     Layer.alert(__('Please disable the add before trying to uninstall'), {icon: 7});
 
-                     return false;
 
-                 }
 
-                 Template.helper("__", __);
 
-                 Layer.confirm(Template("uninstalltpl", {addon: Config['addons'][name]}), {focusBtn: false}, function (index, layero) {
 
-                     uninstall(name, false, $("input[name='droptables']", layero).prop("checked"));
 
-                 });
 
-             });
 
-             // 点击配置
 
-             $(document).on("click", ".btn-config", function () {
 
-                 var name = $(this).closest(".operate").data("name");
 
-                 Fast.api.open("addon/config?name=" + name, __('Setting'));
 
-             });
 
-             // 点击启用/禁用
 
-             $(document).on("click", ".btn-enable,.btn-disable", function () {
 
-                 var name = $(this).data("name");
 
-                 var action = $(this).data("action");
 
-                 operate(name, action, false);
 
-             });
 
-             // 点击升级
 
-             $(document).on("click", ".btn-upgrade", function () {
 
-                 var name = $(this).closest(".operate").data('name');
 
-                 if (Config['addons'][name].state == 1) {
 
-                     Layer.alert(__('Please disable the add before trying to upgrade'), {icon: 7});
 
-                     return false;
 
-                 }
 
-                 var version = $(this).data("version");
 
-                 Layer.confirm(__('Upgrade tips', Config['addons'][name].title), function (index, layero) {
 
-                     upgrade(name, version);
 
-                 });
 
-             });
 
-             $(document).on("click", ".operate .btn-group .dropdown-toggle", function () {
 
-                 $(this).closest(".btn-group").toggleClass("dropup", $(document).height() - $(this).offset().top <= 200);
 
-             });
 
-             $(document).on("click", ".view-screenshots", function () {
 
-                 var row = Table.api.getrowbyindex(table, parseInt($(this).data("index")));
 
-                 var data = [];
 
-                 $.each(row.screenshots, function (i, j) {
 
-                     data.push({
 
-                         "src": j
 
-                     });
 
-                 });
 
-                 var json = {
 
-                     "title": row.title,
 
-                     "data": data
 
-                 };
 
-                 top.Layer.photos(top.JSON.parse(JSON.stringify({photos: json})));
 
-             });
 
-         },
 
-         add: function () {
 
-             Controller.api.bindevent();
 
-         },
 
-         config: function () {
 
-             $(document).on("click", ".nav-group li a[data-toggle='tab']", function () {
 
-                 if ($(this).attr("href") == "#all") {
 
-                     $(".tab-pane").addClass("active in");
 
-                 }
 
-                 return;
 
-                 var type = $(this).attr("href").substring(1);
 
-                 if (type == 'all') {
 
-                     $(".table-config tr").show();
 
-                 } else {
 
-                     $(".table-config tr").hide();
 
-                     $(".table-config tr[data-group='" + type + "']").show();
 
-                 }
 
-             });
 
-             Controller.api.bindevent();
 
-         },
 
-         api: {
 
-             formatter: {
 
-                 title: function (value, row, index) {
 
-                     if ($(".btn-switch.active").data("type") == "local") {
 
-                         // return value;
 
-                     }
 
-                     var title = '<a class="title" href="' + row.url + '" data-toggle="tooltip" title="' + __('View addon home page') + '" target="_blank">' + value + '</a>';
 
-                     if (row.screenshots && row.screenshots.length > 0) {
 
-                         title += ' <a href="javascript:;" data-index="' + index + '" class="view-screenshots text-success" title="' + __('View addon screenshots') + '" data-toggle="tooltip"><i class="fa fa-image"></i></a>';
 
-                     }
 
-                     return title;
 
-                 },
 
-                 operate: function (value, row, index) {
 
-                     return Template("operatetpl", {item: row, index: index});
 
-                 },
 
-                 toggle: function (value, row, index) {
 
-                     if (!row.addon) {
 
-                         return '';
 
-                     }
 
-                     return '<a href="javascript:;" data-toggle="tooltip" title="' + __('Click to toggle status') + '" class="btn btn-toggle btn-' + (row.addon.state == 1 ? "disable" : "enable") + '" data-action="' + (row.addon.state == 1 ? "disable" : "enable") + '" data-name="' + row.name + '"><i class="fa ' + (row.addon.state == 0 ? 'fa-toggle-on fa-rotate-180 text-gray' : 'fa-toggle-on text-success') + ' fa-2x"></i></a>';
 
-                 },
 
-                 author: function (value, row, index) {
 
-                     var url = 'javascript:';
 
-                     if (typeof row.homepage !== 'undefined') {
 
-                         url = row.homepage;
 
-                     } else if (typeof row.qq !== 'undefined' && row.qq) {
 
-                         url = 'https://wpa.qq.com/msgrd?v=3&uin=' + row.qq + '&site=fastadmin.net&menu=yes';
 
-                     }
 
-                     return '<a href="' + url + '" target="_blank" data-toggle="tooltip" class="text-primary">' + value + '</a>';
 
-                 },
 
-                 price: function (value, row, index) {
 
-                     if (isNaN(value)) {
 
-                         return value;
 
-                     }
 
-                     return parseFloat(value) == 0 ? '<span class="text-success">' + __('Free') + '</span>' : '<span class="text-danger">¥' + value + '</span>';
 
-                 },
 
-                 downloads: function (value, row, index) {
 
-                     return value;
 
-                 },
 
-                 version: function (value, row, index) {
 
-                     return row.addon && row.addon.version != row.version ? '<a href="' + row.url + '?version=' + row.version + '" target="_blank"><span class="releasetips text-primary" data-toggle="tooltip" title="' + __('New version tips', row.version) + '">' + row.addon.version + '<i></i></span></a>' : row.version;
 
-                 },
 
-                 home: function (value, row, index) {
 
-                     return row.addon && parseInt(row.addon.state) > 0 ? '<a href="' + row.addon.url + '" data-toggle="tooltip" title="' + __('View addon index page') + '" target="_blank"><i class="fa fa-home text-primary"></i></a>' : '<a href="javascript:;"><i class="fa fa-home text-gray"></i></a>';
 
-                 },
 
-             },
 
-             bindevent: function () {
 
-                 Form.api.bindevent($("form[role=form]"));
 
-             },
 
-             userinfo: {
 
-                 get: function () {
 
-                     var userinfo = localStorage.getItem("fastadmin_userinfo");
 
-                     return userinfo ? JSON.parse(userinfo) : null;
 
-                 },
 
-                 set: function (data) {
 
-                     if (data) {
 
-                         localStorage.setItem("fastadmin_userinfo", JSON.stringify(data));
 
-                     } else {
 
-                         localStorage.removeItem("fastadmin_userinfo");
 
-                     }
 
-                 }
 
-             },
 
-             refresh: function (table, name) {
 
-                 //刷新左侧边栏
 
-                 Fast.api.refreshmenu();
 
-                 //刷新插件JS缓存
 
-                 Fast.api.ajax({url: require.toUrl('addons.js'), loading: false}, function () {
 
-                     return false;
 
-                 }, function () {
 
-                     return false;
 
-                 });
 
-                 //刷新行数据
 
-                 if ($(".operate[data-name='" + name + "']").length > 0) {
 
-                     var tr = $(".operate[data-name='" + name + "']").closest("tr[data-index]");
 
-                     var index = tr.data("index");
 
-                     var row = Table.api.getrowbyindex(table, index);
 
-                     row.addon = typeof Config['addons'][name] !== 'undefined' ? Config['addons'][name] : undefined;
 
-                     table.bootstrapTable("updateRow", {index: index, row: row});
 
-                 } else if ($(".btn-switch.active").data("type") == "local") {
 
-                     $(".btn-refresh").trigger("click");
 
-                 }
 
-             }
 
-         }
 
-     };
 
-     return Controller;
 
- });
 
 
  |