更新前端文件
This commit is contained in:
290
public/static/admin/js/backend.js
Normal file
290
public/static/admin/js/backend.js
Normal file
@@ -0,0 +1,290 @@
|
||||
define(['jquery', 'hopscotch'], function($, hopscotch){
|
||||
var Backend = {
|
||||
|
||||
writeStorage: function(storage, key, value) {
|
||||
if (storage) {
|
||||
try {
|
||||
localStorage.setItem(key, value);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
helpIntro: function(){
|
||||
var placementRight = 'right';
|
||||
var placementLeft = 'left';
|
||||
|
||||
if ($('body').hasClass('rtl')) {
|
||||
placementRight = 'left';
|
||||
placementLeft = 'right';
|
||||
}
|
||||
|
||||
// Define the tour!
|
||||
var tour = {
|
||||
id: "Cube-intro",
|
||||
steps: [
|
||||
{
|
||||
target: 'make-small-nav',
|
||||
title: "设置小菜单按钮",
|
||||
content: "点击小菜单可以把左侧菜单变成小菜单,增大右侧操作区域!",
|
||||
placement: "bottom",
|
||||
zindex: 999,
|
||||
xOffset: -8
|
||||
},
|
||||
{
|
||||
target: 'config-tool-options',
|
||||
title: "后台配置工具",
|
||||
content: "配置后台主题色彩,定制头部、左侧菜单以及底部信息",
|
||||
placement: placementLeft,
|
||||
zindex: 999,
|
||||
fixedElement: true,
|
||||
xOffset: -55
|
||||
},
|
||||
{
|
||||
target: 'sidebar-nav',
|
||||
title: "左侧导航区域",
|
||||
content: "左侧功能导航区域。",
|
||||
placement: placementRight
|
||||
}
|
||||
],
|
||||
showPrevButton: true
|
||||
};
|
||||
|
||||
console.log(hopscotch);
|
||||
// Start the tour!
|
||||
hopscotch.startTour(tour);
|
||||
},
|
||||
|
||||
init: function () {
|
||||
$('.hopscotch').on('click', function(){
|
||||
Backend.helpIntro()
|
||||
})
|
||||
|
||||
var storage, fail, uid;
|
||||
try {
|
||||
uid = new Date;
|
||||
(storage = window.localStorage).setItem(uid, uid);
|
||||
fail = storage.getItem(uid) != uid;
|
||||
storage.removeItem(uid);
|
||||
fail && (storage = false);
|
||||
} catch (e) {}
|
||||
if (storage) {
|
||||
try {
|
||||
var usedSkin = localStorage.getItem('config-skin');
|
||||
if (usedSkin != '') {
|
||||
$('#skin-colors .skin-changer').removeClass('active');
|
||||
$('#skin-colors .skin-changer[data-skin="' + usedSkin + '"]').addClass('active');
|
||||
}
|
||||
var fixedHeader = localStorage.getItem('config-fixed-header');
|
||||
if (fixedHeader == 'fixed-header') {
|
||||
$('body').addClass(fixedHeader);
|
||||
$('#config-fixed-header').prop('checked', true);
|
||||
}
|
||||
var fixedFooter = localStorage.getItem('config-fixed-footer');
|
||||
if (fixedFooter == 'fixed-footer') {
|
||||
$('body').addClass(fixedFooter);
|
||||
$('#config-fixed-footer').prop('checked', true);
|
||||
}
|
||||
var boxedLayout = localStorage.getItem('config-boxed-layout');
|
||||
if (boxedLayout == 'boxed-layout') {
|
||||
$('body').addClass(boxedLayout);
|
||||
$('#config-boxed-layout').prop('checked', true);
|
||||
}
|
||||
var rtlLayout = localStorage.getItem('config-rtl-layout');
|
||||
if (rtlLayout == 'rtl') {
|
||||
$('body').addClass(rtlLayout);
|
||||
$('#config-rtl-layout').prop('checked', true);
|
||||
}
|
||||
var fixedLeftmenu = localStorage.getItem('config-fixed-leftmenu');
|
||||
if (fixedLeftmenu == 'fixed-leftmenu') {
|
||||
$('body').addClass(fixedLeftmenu);
|
||||
$('#config-fixed-sidebar').prop('checked', true);
|
||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
||||
$('#page-wrapper').removeClass('nav-small');
|
||||
}
|
||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||
alwaysVisible: true,
|
||||
iOSNativeScrolling: false,
|
||||
preventPageScrolling: true,
|
||||
contentClass: 'col-left-nano-content'
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
$('#config-tool-cog').on('click', function() {
|
||||
$('#config-tool').toggleClass('closed');
|
||||
});
|
||||
$('#config-fixed-header').on('change', function() {
|
||||
var fixedHeader = '';
|
||||
if ($(this).is(':checked')) {
|
||||
$('body').addClass('fixed-header');
|
||||
fixedHeader = 'fixed-header';
|
||||
} else {
|
||||
$('body').removeClass('fixed-header');
|
||||
if ($('#config-fixed-sidebar').is(':checked')) {
|
||||
$('#config-fixed-sidebar').prop('checked', false);
|
||||
$('#config-fixed-sidebar').trigger('change');
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
Backend.writeStorage(storage, 'config-fixed-header', fixedHeader);
|
||||
});
|
||||
$('#config-fixed-footer').on('change', function() {
|
||||
var fixedFooter = '';
|
||||
if ($(this).is(':checked')) {
|
||||
$('body').addClass('fixed-footer');
|
||||
fixedFooter = 'fixed-footer';
|
||||
} else {
|
||||
$('body').removeClass('fixed-footer');
|
||||
}
|
||||
Backend.writeStorage(storage, 'config-fixed-footer', fixedFooter);
|
||||
});
|
||||
$('#config-boxed-layout').on('change', function() {
|
||||
var boxedLayout = '';
|
||||
if ($(this).is(':checked')) {
|
||||
$('body').addClass('boxed-layout');
|
||||
boxedLayout = 'boxed-layout';
|
||||
} else {
|
||||
$('body').removeClass('boxed-layout');
|
||||
}
|
||||
Backend.writeStorage(storage, 'config-boxed-layout', boxedLayout);
|
||||
});
|
||||
$('#config-rtl-layout').on('change', function() {
|
||||
var rtlLayout = '';
|
||||
if ($(this).is(':checked')) {
|
||||
rtlLayout = 'rtl';
|
||||
} else {}
|
||||
Backend.writeStorage(storage, 'config-rtl-layout', rtlLayout);
|
||||
location.reload();
|
||||
});
|
||||
$('#config-fixed-sidebar').on('change', function() {
|
||||
var fixedSidebar = '';
|
||||
if ($(this).is(':checked')) {
|
||||
if (!$('#config-fixed-header').is(':checked')) {
|
||||
$('#config-fixed-header').prop('checked', true);
|
||||
$('#config-fixed-header').trigger('change');
|
||||
}
|
||||
if ($('#page-wrapper').hasClass('nav-small')) {
|
||||
$('#page-wrapper').removeClass('nav-small');
|
||||
}
|
||||
$('body').addClass('fixed-leftmenu');
|
||||
fixedSidebar = 'fixed-leftmenu';
|
||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||
alwaysVisible: true,
|
||||
iOSNativeScrolling: false,
|
||||
preventPageScrolling: true,
|
||||
contentClass: 'col-left-nano-content'
|
||||
});
|
||||
Backend.writeStorage(storage, 'config-fixed-leftmenu', fixedSidebar);
|
||||
} else {
|
||||
$('body').removeClass('fixed-leftmenu');
|
||||
Backend.writeStorage(storage, 'config-fixed-leftmenu', fixedSidebar);
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
if (!storage) {
|
||||
$('#config-fixed-header').prop('checked', false);
|
||||
$('#config-fixed-footer').prop('checked', false);
|
||||
$('#config-fixed-sidebar').prop('checked', false);
|
||||
$('#config-boxed-layout').prop('checked', false);
|
||||
$('#config-rtl-layout').prop('checked', false);
|
||||
}
|
||||
$('#skin-colors .skin-changer').on('click', function() {
|
||||
$('body').removeClassPrefix('theme-');
|
||||
$('body').addClass($(this).data('skin'));
|
||||
$('#skin-colors .skin-changer').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
Backend.writeStorage(storage, 'config-skin', $(this).data('skin'));
|
||||
});
|
||||
setTimeout(function() {
|
||||
$('#content-wrapper > .row').css({
|
||||
opacity: 1
|
||||
});
|
||||
}, 200);
|
||||
$('#sidebar-nav,#nav-col-submenu').on('click', '.dropdown-toggle', function(e) {
|
||||
e.preventDefault();
|
||||
var $item = $(this).parent();
|
||||
if (!$item.hasClass('open')) {
|
||||
$item.parent().find('.open .submenu').slideUp('fast');
|
||||
$item.parent().find('.open').toggleClass('open');
|
||||
}
|
||||
$item.toggleClass('open');
|
||||
if ($item.hasClass('open')) {
|
||||
$item.children('.submenu').slideDown('fast');
|
||||
} else {
|
||||
$item.children('.submenu').slideUp('fast');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav .dropdown-toggle', function(e) {
|
||||
if ($(document).width() >= 992) {
|
||||
var $item = $(this).parent();
|
||||
if ($('body').hasClass('fixed-leftmenu')) {
|
||||
var topPosition = $item.position().top;
|
||||
if ((topPosition + 4 * $(this).outerHeight()) >= $(window).height()) {
|
||||
topPosition -= 6 * $(this).outerHeight();
|
||||
}
|
||||
$('#nav-col-submenu').html($item.children('.submenu').clone());
|
||||
$('#nav-col-submenu > .submenu').css({
|
||||
'top': topPosition
|
||||
});
|
||||
}
|
||||
$item.addClass('open');
|
||||
$item.children('.submenu').slideDown('fast');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseleave', '#page-wrapper.nav-small #sidebar-nav > .nav-pills > li', function(e) {
|
||||
if ($(document).width() >= 992) {
|
||||
var $item = $(this);
|
||||
if ($item.hasClass('open')) {
|
||||
$item.find('.open .submenu').slideUp('fast');
|
||||
$item.find('.open').removeClass('open');
|
||||
$item.children('.submenu').slideUp('fast');
|
||||
}
|
||||
$item.removeClass('open');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseenter', '#page-wrapper.nav-small #sidebar-nav a:not(.dropdown-toggle)', function(e) {
|
||||
if ($('body').hasClass('fixed-leftmenu')) {
|
||||
$('#nav-col-submenu').html('');
|
||||
}
|
||||
});
|
||||
$('body').on('mouseleave', '#page-wrapper.nav-small #nav-col', function(e) {
|
||||
if ($('body').hasClass('fixed-leftmenu')) {
|
||||
$('#nav-col-submenu').html('');
|
||||
}
|
||||
});
|
||||
$('#make-small-nav').click(function(e) {
|
||||
$('#page-wrapper').toggleClass('nav-small');
|
||||
});
|
||||
|
||||
$('.mobile-search').click(function(e) {
|
||||
e.preventDefault();
|
||||
$('.mobile-search').addClass('active');
|
||||
$('.mobile-search form input.form-control').focus();
|
||||
});
|
||||
$(document).mouseup(function(e) {
|
||||
var container = $('.mobile-search');
|
||||
if (!container.is(e.target) && container.has(e.target).length === 0) {
|
||||
container.removeClass('active');
|
||||
}
|
||||
});
|
||||
$('.fixed-leftmenu #col-left').nanoScroller({
|
||||
alwaysVisible: false,
|
||||
iOSNativeScrolling: false,
|
||||
preventPageScrolling: true,
|
||||
contentClass: 'col-left-nano-content'
|
||||
});
|
||||
$("[data-toggle='tooltip']").each(function(index, el) {
|
||||
$(el).tooltip({
|
||||
placement: $(this).data("placement") || 'top'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Backend.init(); //默认初始化执行的代码
|
||||
return Backend;
|
||||
})
|
||||
@@ -1,10 +1,174 @@
|
||||
require.config({
|
||||
paths:{
|
||||
'vue':'/static/js/vue.js',
|
||||
"jquery":'/static/libs/jquery/jquery.min.js'
|
||||
}
|
||||
urlArgs: "v=" + '4.0.0',
|
||||
packages: [
|
||||
{
|
||||
name: 'moment',
|
||||
location: '/static/libs/moment',
|
||||
main: 'moment'
|
||||
}
|
||||
],
|
||||
include: ['jquery', 'drop', 'drag', 'form'],
|
||||
paths:{
|
||||
'backend': '../admin/js/backend',
|
||||
'form': '/static/js/require-form',
|
||||
'table': '/static/js/require-table',
|
||||
'upload': '/static/js/require-upload',
|
||||
'validator': '/static/js/require-validator',
|
||||
'drag': 'jquery.drag.min',
|
||||
'drop': 'jquery.drop.min',
|
||||
'echarts': 'echarts.min',
|
||||
'echarts-theme': 'echarts-theme',
|
||||
|
||||
"vue":'/static/libs/vue/dist/vue.min',
|
||||
"jquery":'/static/libs/jquery/jquery.min',
|
||||
"nanoscroller":"/static/libs/nanoscroller/jquery.nanoscroller.min",
|
||||
"slimscroll":"/static/js/jquery.slimscroll.min",
|
||||
"bootstrap":"/static/libs/bootstrap/js/bootstrap.min",
|
||||
'bootstrap-table-commonsearch': 'bootstrap-table-commonsearch',
|
||||
'bootstrap-table-template': 'bootstrap-table-template',
|
||||
//
|
||||
// 以下的包从bower的libs目录加载
|
||||
'jquery': '/static/libs/jquery/dist/jquery.min',
|
||||
'bootstrap': '/static/libs/bootstrap/dist/js/bootstrap.min',
|
||||
'bootstrap-datetimepicker': '/static/libs/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
|
||||
'bootstrap-daterangepicker': '/static/libs/bootstrap-daterangepicker/daterangepicker',
|
||||
'bootstrap-select': '/static/libs/bootstrap-select/dist/js/bootstrap-select.min',
|
||||
'bootstrap-select-lang': '/static/libs/bootstrap-select/dist/js/i18n/defaults-zh_CN',
|
||||
'bootstrap-table': '/static/libs/bootstrap-table/dist/bootstrap-table.min',
|
||||
'bootstrap-table-export': '/static/libs/bootstrap-table/dist/extensions/export/bootstrap-table-export.min',
|
||||
'bootstrap-table-mobile': '/static/libs/bootstrap-table/dist/extensions/mobile/bootstrap-table-mobile',
|
||||
'bootstrap-table-lang': '/static/libs/bootstrap-table/dist/locale/bootstrap-table-zh-CN',
|
||||
'bootstrap-slider': '/static/libs/bootstrap-slider/bootstrap-slider',
|
||||
'tableexport': '/static/libs/tableExport.jquery.plugin/tableExport.min',
|
||||
'dragsort': '/static/libs/fastadmin-dragsort/jquery.dragsort',
|
||||
'sortable': '/static/libs/Sortable/Sortable.min',
|
||||
'addtabs': '/static/libs/fastadmin-addtabs/jquery.addtabs',
|
||||
'slimscroll': '/static/libs/jquery-slimscroll/jquery.slimscroll',
|
||||
'validator-core': '/static/libs/nice-validator/dist/jquery.validator',
|
||||
'validator-lang': '/static/libs/nice-validator/dist/local/zh-CN',
|
||||
'plupload': '/static/libs/plupload/js/plupload.min',
|
||||
'toastr': '/static/libs/toastr/toastr',
|
||||
'jstree': '/static/libs/jstree/dist/jstree.min',
|
||||
'layer': '/static/libs/fastadmin-layer/dist/layer',
|
||||
'cookie': '/static/libs/jquery.cookie/jquery.cookie',
|
||||
'cxselect': '/static/libs/fastadmin-cxselect/js/jquery.cxselect',
|
||||
'template': '/static/libs/art-template/dist/template-native',
|
||||
'selectpage': '/static/libs/fastadmin-selectpage/selectpage',
|
||||
'citypicker': '/static/libs/fastadmin-citypicker/dist/js/city-picker.min',
|
||||
'citypicker-data': '/static/libs/fastadmin-citypicker/dist/js/city-picker.data',
|
||||
},
|
||||
shim:{
|
||||
"nanoscroller":['jquery'],
|
||||
"slimscroll":{
|
||||
deps: ['jquery'],
|
||||
exports: '$.fn.extend'
|
||||
},
|
||||
'bootstrap': ['jquery'],
|
||||
'bootstrap-table': {
|
||||
deps: [
|
||||
'bootstrap',
|
||||
// 'css!/static/libs/bootstrap-table/dist/bootstrap-table.min.css'
|
||||
],
|
||||
exports: '$.fn.bootstrapTable'
|
||||
},
|
||||
'bootstrap-table-lang': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-export': {
|
||||
deps: ['bootstrap-table', 'tableexport'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-mobile': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-advancedsearch': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-commonsearch': {
|
||||
deps: ['bootstrap-table'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'bootstrap-table-template': {
|
||||
deps: ['bootstrap-table', 'template'],
|
||||
exports: '$.fn.bootstrapTable.defaults'
|
||||
},
|
||||
'tableexport': {
|
||||
deps: ['jquery'],
|
||||
exports: '$.fn.extend'
|
||||
},
|
||||
'bootstrap-datetimepicker': [
|
||||
'moment/locale/zh-cn.js',
|
||||
// 'css!/static/libs/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
|
||||
],
|
||||
// 'bootstrap-select': ['css!/static/libs/bootstrap-select/dist/css/bootstrap-select.min.css',],
|
||||
'bootstrap-select-lang': ['bootstrap-select'],
|
||||
// 'toastr': ['css!/static/libs/toastr/toastr.min.css'],
|
||||
'jstree': ['css!/static/libs/jstree/dist/themes/default/style.css',],
|
||||
'plupload': {
|
||||
deps: ['/static/libs/plupload/js/moxie.min.js'],
|
||||
exports: "plupload"
|
||||
},
|
||||
// 'layer': ['css!/static/libs/fastadmin-layer/dist/theme/default/layer.css'],
|
||||
// 'validator-core': ['css!/static/libs/nice-validator/dist/jquery.validator.css'],
|
||||
'validator-lang': ['validator-core'],
|
||||
// 'selectpage': ['css!/static/libs/fastadmin-selectpage/selectpage.css'],
|
||||
'citypicker': ['citypicker-data', 'css!/static/libs/fastadmin-citypicker/dist/css/city-picker.css']
|
||||
},
|
||||
baseUrl:"/static/js/",
|
||||
map: {
|
||||
'*': {
|
||||
'css': '/static/libs/require-css/css.min.js'
|
||||
}
|
||||
},
|
||||
//baseUrl: '/static/admin/js/backend/',
|
||||
waitSeconds: 30,
|
||||
charset: 'utf-8' // 文件编码
|
||||
});
|
||||
|
||||
require(['vue', 'jquery'], function(Vue, $){
|
||||
require(['jquery', 'nanoscroller', 'bootstrap'], function($){
|
||||
$(function($) {
|
||||
require(['sent'], function(Sent){
|
||||
require(['backend', 'backend-init', 'addons'], function (Backend, undefined, Addons) {
|
||||
// 避免目录冲突
|
||||
require.config({baseUrl: '/static/admin/js/module/'});
|
||||
|
||||
var current_url = (window.location.pathname).split('/');
|
||||
if (typeof(isLoadModule) != "undefined" && isLoadModule) {
|
||||
require([current_url[2]], function(Controller){
|
||||
var action = current_url[3].split('.');
|
||||
if (Controller.hasOwnProperty(action[0])) {
|
||||
Controller[action[0]]();
|
||||
} else {
|
||||
if (Controller.hasOwnProperty("_empty")) {
|
||||
Controller._empty();
|
||||
}
|
||||
}
|
||||
}, function (e) {
|
||||
console.error(e); // 这里可捕获模块加载的错误
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
$.fn.removeClassPrefix = function(prefix) {
|
||||
this.each(function(i, el) {
|
||||
var classes = el.className.split(" ").filter(function(c) {
|
||||
return c.lastIndexOf(prefix, 0) !== 0;
|
||||
});
|
||||
el.className = classes.join(" ");
|
||||
});
|
||||
return this;
|
||||
};
|
||||
});
|
||||
|
||||
function setContentBody() {
|
||||
header_height = $('header#header-navbar').height();
|
||||
if ($(window).height() - header_height - 50 > $('#content-wrapper').height()) {
|
||||
$('#content-wrapper').height($(window).height() - header_height - 50);
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
8
public/static/admin/js/module/config.js
Normal file
8
public/static/admin/js/module/config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
define([], function(){
|
||||
var controller = {
|
||||
group: function(){
|
||||
}
|
||||
}
|
||||
|
||||
return controller;
|
||||
})
|
||||
9
public/static/admin/js/module/index.js
Normal file
9
public/static/admin/js/module/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
define(['vue'],function(Vue){
|
||||
var controller = {
|
||||
clear: function(){
|
||||
var vm = new Vue();
|
||||
}
|
||||
}
|
||||
|
||||
return controller;
|
||||
})
|
||||
Reference in New Issue
Block a user