mirror of https://github.com/openspug/spug
A 增加功能权限文件管理器 #176
parent
9b18af192a
commit
367f21a640
|
@ -8,7 +8,7 @@ import ReactDOM from 'react-dom';
|
||||||
import { Router } from 'react-router-dom';
|
import { Router } from 'react-router-dom';
|
||||||
import { ConfigProvider } from 'antd';
|
import { ConfigProvider } from 'antd';
|
||||||
import zhCN from 'antd/es/locale/zh_CN';
|
import zhCN from 'antd/es/locale/zh_CN';
|
||||||
import history from 'libs/history';
|
import { history, updatePermissions } from 'libs';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import App from './App';
|
import App from './App';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
@ -16,6 +16,7 @@ import 'moment/locale/zh-cn';
|
||||||
import * as serviceWorker from './serviceWorker';
|
import * as serviceWorker from './serviceWorker';
|
||||||
|
|
||||||
moment.locale('zh-cn');
|
moment.locale('zh-cn');
|
||||||
|
updatePermissions()
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
|
|
|
@ -9,10 +9,10 @@ let Permission = {
|
||||||
permissions: []
|
permissions: []
|
||||||
};
|
};
|
||||||
|
|
||||||
export function updatePermissions(isSupper, hostPerms, data) {
|
export function updatePermissions() {
|
||||||
Permission.isSuper = isSupper;
|
Permission.isSuper = localStorage.getItem('is_supper') === 'true';
|
||||||
Permission.hostPerms = hostPerms;
|
Permission.hostPerms = JSON.parse(localStorage.getItem('host_perms') || []);
|
||||||
Permission.permissions = data;
|
Permission.permissions = JSON.parse(localStorage.getItem('permissions') || []);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 前端页面的权限判断(仅作为前端功能展示的控制,具体权限控制应在后端实现)
|
// 前端页面的权限判断(仅作为前端功能展示的控制,具体权限控制应在后端实现)
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
* Released under the AGPL-3.0 License.
|
* Released under the AGPL-3.0 License.
|
||||||
*/
|
*/
|
||||||
import _http from './http';
|
import _http from './http';
|
||||||
|
import _history from './history';
|
||||||
|
|
||||||
export * from './functools';
|
export * from './functools';
|
||||||
export * from './router';
|
export * from './router';
|
||||||
export const http = _http;
|
export const http = _http;
|
||||||
|
export const history = _history;
|
||||||
export const VERSION = 'v2.3.8';
|
export const VERSION = 'v2.3.8';
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { observer } from 'mobx-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 hostStore from 'pages/host/store';
|
||||||
import http from 'libs/http';
|
import http from 'libs/http';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
|
|
@ -64,7 +64,7 @@ class LoginIndex extends React.Component {
|
||||||
localStorage.setItem('is_supper', data['is_supper']);
|
localStorage.setItem('is_supper', data['is_supper']);
|
||||||
localStorage.setItem('permissions', JSON.stringify(data['permissions']));
|
localStorage.setItem('permissions', JSON.stringify(data['permissions']));
|
||||||
localStorage.setItem('host_perms', JSON.stringify(data['host_perms']));
|
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']) {
|
if (history.location.state && history.location.state['from']) {
|
||||||
history.push(history.location.state['from'])
|
history.push(history.location.state['from'])
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
|
import { AuthDiv } from 'components';
|
||||||
import { Terminal } from 'xterm';
|
import { Terminal } from 'xterm';
|
||||||
import { FitAddon } from 'xterm-addon-fit';
|
import { FitAddon } from 'xterm-addon-fit';
|
||||||
import FileManager from './FileManager';
|
import FileManager from './FileManager';
|
||||||
|
@ -82,12 +83,15 @@ class WebSSH extends React.Component {
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
<div>{host.name} | {host.username}@{host.hostname}:{host.port}</div>
|
<div>{host.name} | {host.username}@{host.hostname}:{host.port}</div>
|
||||||
<Button disabled={managerDisabled} type="primary" icon="folder-open" onClick={this.handleShow}>文件管理器</Button>
|
<AuthDiv auth="host.console.manager">
|
||||||
|
<Button disabled={managerDisabled} type="primary" icon="folder-open"
|
||||||
|
onClick={this.handleShow}>文件管理器</Button>
|
||||||
|
</AuthDiv>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.terminal}>
|
<div className={styles.terminal}>
|
||||||
<div ref={ref => this.container = ref}/>
|
<div ref={ref => this.container = ref}/>
|
||||||
</div>
|
</div>
|
||||||
<FileManager id={this.id} visible={visible} onClose={this.handleShow} />
|
<FileManager id={this.id} visible={visible} onClose={this.handleShow}/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,12 @@ export default [{
|
||||||
{key: 'del', label: '删除主机'},
|
{key: 'del', label: '删除主机'},
|
||||||
{key: 'console', label: 'Console'},
|
{key: 'console', label: 'Console'},
|
||||||
]
|
]
|
||||||
|
}, {
|
||||||
|
key: 'console',
|
||||||
|
label: 'Console',
|
||||||
|
perms: [
|
||||||
|
{key: 'manager', label: '文件管理器'},
|
||||||
|
]
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
key: 'exec',
|
key: 'exec',
|
||||||
|
|
Loading…
Reference in New Issue