SPA_RESOLVE_INIT = function ($el, $router) { let body = document.querySelector('body'); body.className = 'mdui-appbar-with-toolbar mdui-theme-primary-blue mdui-theme-accent-light-blue mdui-drawer-body-left mdui-loaded'; mdui.JQ($el).empty(); mdui.JQ($el).append(`
menu CloudSQL Admin Panel
exit_to_app
  • view_list
    数据库列表
  • person
    用户列表
  • info
    关于
  • `); //左侧菜单栏 let leftMenuButton = document.querySelector('span:nth-child(1).mdui-btn.mdui-btn-icon.mdui-ripple.mdui-ripple-white'), mainDrawer = new mdui.Drawer('#main-drawer'); Utils.handleEvent('click', { onElement: leftMenuButton, withCallback: function () { mainDrawer.toggle(); } }) let databaseListButton = document.querySelector('#main-drawer li:nth-child(1)'); Utils.handleEvent('click', { onElement: databaseListButton, withCallback: function () { window.location.hash = '/index/databaseList'; } }) let userListButton = document.querySelector('#main-drawer li:nth-child(2)'); Utils.handleEvent('click', { onElement: userListButton, withCallback: function () { window.location.hash = '/index/userList'; } }) //退出登录按钮 let signoutButton = document.querySelector('span:nth-child(4).mdui-btn.mdui-btn-icon.mdui-ripple.mdui-ripple-white i.mdui-icon.material-icons'); Utils.handleEvent('click', { onElement: signoutButton, withCallback: function () { Utils.ajaxGet('http://admin.cloudsql.1473.cn/v1/signout', function (response) { if (response.status == 'successed') { mdui.snackbar({ message: response.info }); window.location.hash = response.url; } else { console.log(response.info); console.log(response.error); mdui.snackbar({ message: response.info }); } }); } }) const inlineEl = document.querySelector('.mdui-container.main-container'); const inlineRoute = [{ path: '/index/main', fileName: 'src/components/main.js' }, { path: '/index/databaseList', fileName: 'src/components/databaseList.js' }, { path: '/index/userList', fileName: 'src/components/userList.js' }, ] const inlineRouter = new SPARouter(inlineEl, inlineRouter, 'hash'); inlineRouter.beforeEach((to, next) => { Utils.ajaxGet('http://admin.cloudsql.1473.cn/v1/index/signStatus', function (response) { if (response.status === 'signedin') { next(); } else { window.location.hash = '/signin'; } }); }); }