diff --git a/spug_web/src/index.js b/spug_web/src/index.js index d741272b..7e5fce5c 100644 --- a/spug_web/src/index.js +++ b/spug_web/src/index.js @@ -8,7 +8,7 @@ import ReactDOM from 'react-dom'; import { Router } from 'react-router-dom'; import { ConfigProvider } from 'antd'; import zhCN from 'antd/es/locale/zh_CN'; -import history from 'libs/history'; +import { history, updatePermissions } from 'libs'; import './index.css'; import App from './App'; import moment from 'moment'; @@ -16,6 +16,7 @@ import 'moment/locale/zh-cn'; import * as serviceWorker from './serviceWorker'; moment.locale('zh-cn'); +updatePermissions() ReactDOM.render( diff --git a/spug_web/src/libs/functools.js b/spug_web/src/libs/functools.js index dd2f9dc9..a2148e4f 100644 --- a/spug_web/src/libs/functools.js +++ b/spug_web/src/libs/functools.js @@ -9,10 +9,10 @@ let Permission = { permissions: [] }; -export function updatePermissions(isSupper, hostPerms, data) { - Permission.isSuper = isSupper; - Permission.hostPerms = hostPerms; - Permission.permissions = data; +export function updatePermissions() { + Permission.isSuper = localStorage.getItem('is_supper') === 'true'; + Permission.hostPerms = JSON.parse(localStorage.getItem('host_perms') || []); + Permission.permissions = JSON.parse(localStorage.getItem('permissions') || []); } // 前端页面的权限判断(仅作为前端功能展示的控制,具体权限控制应在后端实现) diff --git a/spug_web/src/libs/index.js b/spug_web/src/libs/index.js index d423d5e8..4a07165a 100644 --- a/spug_web/src/libs/index.js +++ b/spug_web/src/libs/index.js @@ -4,8 +4,10 @@ * Released under the AGPL-3.0 License. */ import _http from './http'; +import _history from './history'; export * from './functools'; export * from './router'; export const http = _http; +export const history = _history; export const VERSION = 'v2.3.8'; diff --git a/spug_web/src/pages/deploy/request/Ext2Form.js b/spug_web/src/pages/deploy/request/Ext2Form.js index 4c25bd23..f1c98504 100644 --- a/spug_web/src/pages/deploy/request/Ext2Form.js +++ b/spug_web/src/pages/deploy/request/Ext2Form.js @@ -5,7 +5,7 @@ */ import React from 'react'; import { observer } from 'mobx-react'; -import { Modal, Form, Input, Tag, Upload, message, Button, Icon } from 'antd'; +import { Modal, Form, Input, Tag, Upload, message, Button } from 'antd'; import hostStore from 'pages/host/store'; import http from 'libs/http'; import store from './store'; diff --git a/spug_web/src/pages/login/index.js b/spug_web/src/pages/login/index.js index c832885c..5b0711a1 100644 --- a/spug_web/src/pages/login/index.js +++ b/spug_web/src/pages/login/index.js @@ -64,7 +64,7 @@ class LoginIndex extends React.Component { localStorage.setItem('is_supper', data['is_supper']); localStorage.setItem('permissions', JSON.stringify(data['permissions'])); localStorage.setItem('host_perms', JSON.stringify(data['host_perms'])); - updatePermissions(data['is_supper'], data['host_perms'], data['permissions']); + updatePermissions(); if (history.location.state && history.location.state['from']) { history.push(history.location.state['from']) } else { diff --git a/spug_web/src/pages/ssh/index.js b/spug_web/src/pages/ssh/index.js index 35549cb7..9a104b46 100644 --- a/spug_web/src/pages/ssh/index.js +++ b/spug_web/src/pages/ssh/index.js @@ -5,6 +5,7 @@ */ import React from 'react'; import { Button } from 'antd'; +import { AuthDiv } from 'components'; import { Terminal } from 'xterm'; import { FitAddon } from 'xterm-addon-fit'; import FileManager from './FileManager'; @@ -82,12 +83,15 @@ class WebSSH extends React.Component {
{host.name} | {host.username}@{host.hostname}:{host.port}
- + + +
this.container = ref}/>
- +
) } diff --git a/spug_web/src/pages/system/role/codes.js b/spug_web/src/pages/system/role/codes.js index 3a16155c..dd9892dc 100644 --- a/spug_web/src/pages/system/role/codes.js +++ b/spug_web/src/pages/system/role/codes.js @@ -26,6 +26,12 @@ export default [{ {key: 'del', label: '删除主机'}, {key: 'console', label: 'Console'}, ] + }, { + key: 'console', + label: 'Console', + perms: [ + {key: 'manager', label: '文件管理器'}, + ] }] }, { key: 'exec',