add page chk login
This commit is contained in:
parent
e2040a181e
commit
52e18de9ac
@ -65,5 +65,6 @@
|
|||||||
"ERR8002": "資料更新失敗",
|
"ERR8002": "資料更新失敗",
|
||||||
"ERR8003": "資料刪除失敗",
|
"ERR8003": "資料刪除失敗",
|
||||||
"ERR8100": "DB連線失敗",
|
"ERR8100": "DB連線失敗",
|
||||||
"ERR9000": "操作權限不足"
|
"ERR9000": "操作權限不足",
|
||||||
|
"ERR9001": "登入Token無效"
|
||||||
}
|
}
|
@ -80128,6 +80128,10 @@ var _ActionLinkAdd = __webpack_require__(1080);
|
|||||||
|
|
||||||
var _ActionLinkAdd2 = _interopRequireDefault(_ActionLinkAdd);
|
var _ActionLinkAdd2 = _interopRequireDefault(_ActionLinkAdd);
|
||||||
|
|
||||||
|
var _IPCam = __webpack_require__(1127);
|
||||||
|
|
||||||
|
var _IPCam2 = _interopRequireDefault(_IPCam);
|
||||||
|
|
||||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
var Routes = _react2.default.createElement(
|
var Routes = _react2.default.createElement(
|
||||||
@ -80144,7 +80148,8 @@ var Routes = _react2.default.createElement(
|
|||||||
_react2.default.createElement(_reactRouter.Route, { path: 'modbus', component: _Modbus2.default }),
|
_react2.default.createElement(_reactRouter.Route, { path: 'modbus', component: _Modbus2.default }),
|
||||||
_react2.default.createElement(_reactRouter.Route, { path: 'link', component: _ActionLink2.default }),
|
_react2.default.createElement(_reactRouter.Route, { path: 'link', component: _ActionLink2.default }),
|
||||||
_react2.default.createElement(_reactRouter.Route, { path: 'addlink', component: _ActionLinkAdd2.default }),
|
_react2.default.createElement(_reactRouter.Route, { path: 'addlink', component: _ActionLinkAdd2.default }),
|
||||||
_react2.default.createElement(_reactRouter.Route, { path: 'modbuscmd', component: _ModbusCmd2.default })
|
_react2.default.createElement(_reactRouter.Route, { path: 'modbuscmd', component: _ModbusCmd2.default }),
|
||||||
|
_react2.default.createElement(_reactRouter.Route, { path: 'ipcam', component: _IPCam2.default })
|
||||||
);
|
);
|
||||||
|
|
||||||
exports.default = Routes;
|
exports.default = Routes;
|
||||||
@ -87352,6 +87357,9 @@ var MainMenu = function MainMenu(_ref) {
|
|||||||
_react2.default.createElement(_Item2.default, { toLink: '/admin/link', txt: i18n && 't' in i18n ? i18n.t('menu.item.link') : '', permission: permissions.link, onClick: function onClick() {
|
_react2.default.createElement(_Item2.default, { toLink: '/admin/link', txt: i18n && 't' in i18n ? i18n.t('menu.item.link') : '', permission: permissions.link, onClick: function onClick() {
|
||||||
return toggleMenu();
|
return toggleMenu();
|
||||||
} }),
|
} }),
|
||||||
|
_react2.default.createElement(_Item2.default, { toLink: '/admin/ipcam', txt: i18n && 't' in i18n ? i18n.t('menu.item.ipcam') : '', permission: permissions.ipcam, onClick: function onClick() {
|
||||||
|
return toggleMenu();
|
||||||
|
} }),
|
||||||
_react2.default.createElement(_Item2.default, { toLink: '/admin', txt: i18n && 't' in i18n ? i18n.t('menu.item.logout') : '', permission: true, onClick: function onClick() {
|
_react2.default.createElement(_Item2.default, { toLink: '/admin', txt: i18n && 't' in i18n ? i18n.t('menu.item.logout') : '', permission: true, onClick: function onClick() {
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
location.replace('/');
|
location.replace('/');
|
||||||
@ -91414,6 +91422,10 @@ var PageRoot = function (_React$Component) {
|
|||||||
_createClass(PageRoot, [{
|
_createClass(PageRoot, [{
|
||||||
key: 'componentDidMount',
|
key: 'componentDidMount',
|
||||||
value: function componentDidMount() {
|
value: function componentDidMount() {
|
||||||
|
fetch('/api/system/chklogin', (0, _actions.getRequest)()).then(function (response) {
|
||||||
|
return response.json();
|
||||||
|
}).then(function (json) {
|
||||||
|
if (json.status != 1) return location.replace('/');
|
||||||
var lang = navigator.language.substring(0, 2);
|
var lang = navigator.language.substring(0, 2);
|
||||||
fetch('/locales/' + lang + '.json').then(function (response) {
|
fetch('/locales/' + lang + '.json').then(function (response) {
|
||||||
if (response.status == 200) return response.json();
|
if (response.status == 200) return response.json();
|
||||||
@ -91427,6 +91439,7 @@ var PageRoot = function (_React$Component) {
|
|||||||
store.dispatch((0, _actions.set_i18n)(_i18next2.default));
|
store.dispatch((0, _actions.set_i18n)(_i18next2.default));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'render',
|
key: 'render',
|
||||||
@ -91444,5 +91457,97 @@ var PageRoot = function (_React$Component) {
|
|||||||
|
|
||||||
_reactDom2.default.render(_react2.default.createElement(PageRoot, null), document.getElementById('app'));
|
_reactDom2.default.render(_react2.default.createElement(PageRoot, null), document.getElementById('app'));
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
/* 1125 */,
|
||||||
|
/* 1126 */
|
||||||
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||||
|
|
||||||
|
var _react = __webpack_require__(0);
|
||||||
|
|
||||||
|
var _react2 = _interopRequireDefault(_react);
|
||||||
|
|
||||||
|
__webpack_require__(13);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||||
|
|
||||||
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||||
|
|
||||||
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||||
|
|
||||||
|
var IPCamPage = function (_React$Component) {
|
||||||
|
_inherits(IPCamPage, _React$Component);
|
||||||
|
|
||||||
|
function IPCamPage() {
|
||||||
|
_classCallCheck(this, IPCamPage);
|
||||||
|
|
||||||
|
return _possibleConstructorReturn(this, (IPCamPage.__proto__ || Object.getPrototypeOf(IPCamPage)).apply(this, arguments));
|
||||||
|
}
|
||||||
|
|
||||||
|
_createClass(IPCamPage, [{
|
||||||
|
key: 'render',
|
||||||
|
value: function render() {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
|
return IPCamPage;
|
||||||
|
}(_react2.default.Component);
|
||||||
|
|
||||||
|
exports.default = IPCamPage;
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
/* 1127 */
|
||||||
|
/***/ (function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", {
|
||||||
|
value: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var _reactRedux = __webpack_require__(30);
|
||||||
|
|
||||||
|
var _actions = __webpack_require__(24);
|
||||||
|
|
||||||
|
var _IPCam = __webpack_require__(1126);
|
||||||
|
|
||||||
|
var _IPCam2 = _interopRequireDefault(_IPCam);
|
||||||
|
|
||||||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||||
|
|
||||||
|
var mapStateToProps = function mapStateToProps(state) {
|
||||||
|
return {
|
||||||
|
i18n: state.i18n
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
var mapDispatchToProps = function mapDispatchToProps(dispatch, ownProps) {
|
||||||
|
return {
|
||||||
|
showDialog: function showDialog(msg) {
|
||||||
|
dispatch((0, _actions.add_dialog_msg)(msg));
|
||||||
|
},
|
||||||
|
toggleLoading: function toggleLoading() {
|
||||||
|
var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
||||||
|
|
||||||
|
dispatch((0, _actions.toggle_loading)(flag));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_IPCam2.default);
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
/******/ ]);
|
/******/ ]);
|
@ -272,6 +272,7 @@
|
|||||||
"modbus": "Modbus",
|
"modbus": "Modbus",
|
||||||
"modbuscmd": "Modbus CMD",
|
"modbuscmd": "Modbus CMD",
|
||||||
"link": "連動",
|
"link": "連動",
|
||||||
|
"ipcam": "網路攝影機",
|
||||||
"logout": "登出"
|
"logout": "登出"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -393,6 +393,13 @@ router
|
|||||||
return n();
|
return n();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.post('/chklogin', (req,res,n) => {
|
||||||
|
if(!tool.checkPermission(req)) return n('ERR9001');
|
||||||
|
res.api_res = {
|
||||||
|
record: []
|
||||||
|
}
|
||||||
|
n();
|
||||||
|
})
|
||||||
.all('*', rt.send);
|
.all('*', rt.send);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
@ -8,6 +8,7 @@ import routes from './routes';
|
|||||||
import thunk from 'redux-thunk';
|
import thunk from 'redux-thunk';
|
||||||
import {set_i18n} from './actions';
|
import {set_i18n} from './actions';
|
||||||
import i18next from 'i18next';
|
import i18next from 'i18next';
|
||||||
|
import {getRequest} from './actions';
|
||||||
|
|
||||||
const middleware = [thunk];
|
const middleware = [thunk];
|
||||||
|
|
||||||
@ -34,6 +35,10 @@ const store = createStore(reducers, NODE_ENV && NODE_ENV == 'production' ? apply
|
|||||||
class PageRoot extends React.Component {
|
class PageRoot extends React.Component {
|
||||||
|
|
||||||
componentDidMount(){
|
componentDidMount(){
|
||||||
|
fetch('/api/system/chklogin', getRequest())
|
||||||
|
.then(response=>response.json())
|
||||||
|
.then(json => {
|
||||||
|
if(json.status != 1) return location.replace('/');
|
||||||
let lang = navigator
|
let lang = navigator
|
||||||
.language
|
.language
|
||||||
.substring(0, 2);
|
.substring(0, 2);
|
||||||
@ -50,6 +55,7 @@ class PageRoot extends React.Component {
|
|||||||
store.dispatch(set_i18n(i18next));
|
store.dispatch(set_i18n(i18next));
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -18,6 +18,7 @@ const MainMenu = ({i18n, show, toggleMenu, children, permissions, showDashboard,
|
|||||||
<MItem toLink="/admin/modbus" txt={i18n && 't' in i18n ? i18n.t('menu.item.modbus') : ''} permission={permissions.modbus} onClick={()=>toggleMenu()} />
|
<MItem toLink="/admin/modbus" txt={i18n && 't' in i18n ? i18n.t('menu.item.modbus') : ''} permission={permissions.modbus} onClick={()=>toggleMenu()} />
|
||||||
<MItem toLink="/admin/modbuscmd" txt={i18n && 't' in i18n ? i18n.t('menu.item.modbuscmd') : ''} permission={permissions.modbus} onClick={()=>toggleMenu()} />
|
<MItem toLink="/admin/modbuscmd" txt={i18n && 't' in i18n ? i18n.t('menu.item.modbuscmd') : ''} permission={permissions.modbus} onClick={()=>toggleMenu()} />
|
||||||
<MItem toLink="/admin/link" txt={i18n && 't' in i18n ? i18n.t('menu.item.link') : ''} permission={permissions.link} onClick={()=>toggleMenu()} />
|
<MItem toLink="/admin/link" txt={i18n && 't' in i18n ? i18n.t('menu.item.link') : ''} permission={permissions.link} onClick={()=>toggleMenu()} />
|
||||||
|
<MItem toLink="/admin/ipcam" txt={i18n && 't' in i18n ? i18n.t('menu.item.ipcam') : ''} permission={permissions.ipcam} onClick={()=>toggleMenu()} />
|
||||||
<MItem toLink="/admin" txt={i18n && 't' in i18n ? i18n.t('menu.item.logout') : ''} permission={true} onClick={()=>{
|
<MItem toLink="/admin" txt={i18n && 't' in i18n ? i18n.t('menu.item.logout') : ''} permission={true} onClick={()=>{
|
||||||
sessionStorage.clear();
|
sessionStorage.clear();
|
||||||
location.replace('/');
|
location.replace('/');
|
||||||
|
@ -13,6 +13,7 @@ import Modbus from './containers/AdminPage/Modbus';
|
|||||||
import ModbusCmd from './containers/AdminPage/ModbusCmd';
|
import ModbusCmd from './containers/AdminPage/ModbusCmd';
|
||||||
import ActionLink from './containers/AdminPage/ActionLink';
|
import ActionLink from './containers/AdminPage/ActionLink';
|
||||||
import ActionLinkAdd from './containers/AdminPage/ActionLinkAdd';
|
import ActionLinkAdd from './containers/AdminPage/ActionLinkAdd';
|
||||||
|
import IPCam from './containers/AdminPage/IPCam';
|
||||||
|
|
||||||
const Routes = (
|
const Routes = (
|
||||||
<Route path="/admin" component={AdminPage}>
|
<Route path="/admin" component={AdminPage}>
|
||||||
@ -28,6 +29,7 @@ const Routes = (
|
|||||||
<Route path="link" component={ActionLink} />
|
<Route path="link" component={ActionLink} />
|
||||||
<Route path="addlink" component={ActionLinkAdd} />
|
<Route path="addlink" component={ActionLinkAdd} />
|
||||||
<Route path="modbuscmd" component={ModbusCmd} />
|
<Route path="modbuscmd" component={ModbusCmd} />
|
||||||
|
<Route path="ipcam" component={IPCam} />
|
||||||
</Route>
|
</Route>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user