diff --git a/app.js b/app.js index 6f96301..c9dabbe 100644 --- a/app.js +++ b/app.js @@ -13,7 +13,7 @@ const app = express(); const api_route = require('./route/api'); // storeObject interval clear -const clearStore = setInterval(() =>{ +const clearStore = setInterval(() => { so.clear(); }, 30000) @@ -34,6 +34,10 @@ app.use(express.static(path.resolve(__dirname, 'public'))); app.use('/semantic', express.static(path.resolve(__dirname, 'node_modules', 'semantic-ui-css'))); app.use('/react-datetime', express.static(path.resolve(__dirname, 'node_modules', 'react-datetime', 'css'))); +app.use(/\/locales\/(\w+).json/, (req, res, n) => { + res.sendFile(path.resolve(__dirname, 'public', 'locales', 'zh.json')); +}) + const server = app.listen(app.get('port'), () => { console.log(`Server start on port ${server.address().port}`); }); @@ -45,11 +49,11 @@ app.get('/', (req, res) => { res.sendFile(path.resolve(__dirname, 'views', 'index.html')); }); -app.get(['/admin','/admin/*'], (req,res) => { +app.get(['/admin', '/admin/*'], (req, res) => { res.sendFile(path.resolve(__dirname, 'views', 'admin.html')); }); -app.get('/servcmd', (req,res) => { - res.send({status: `exit time ${Date.now()}`}); - setTimeout(()=>{process.exit(1)}, 2000); +app.get('/servcmd', (req, res) => { + res.send({ status: `exit time ${Date.now()}` }); + setTimeout(() => { process.exit(1) }, 2000); }); \ No newline at end of file diff --git a/public/js/index_bundle.js b/public/js/index_bundle.js index 03cb988..281fd57 100644 --- a/public/js/index_bundle.js +++ b/public/js/index_bundle.js @@ -62215,7 +62215,8 @@ var Root = function (_React$Component) { value: function componentDidMount() { var _this2 = this; - var lang = navigator.language.substring(0, 2); + var slang = sessionStorage.getItem('lang'); + var lang = slang || navigator.language.substring(0, 2); fetch('/locales/' + lang + '.json').then(function (response) { if (response.status == 200) return response.json(); return {}; diff --git a/src/components/Login/index.js b/src/components/Login/index.js index 28e92f7..1c50dde 100644 --- a/src/components/Login/index.js +++ b/src/components/Login/index.js @@ -59,7 +59,8 @@ class Root extends React.Component { } componentDidMount() { - let lang = navigator + let slang = sessionStorage.getItem('lang'); + let lang = slang || navigator .language .substring(0, 2); fetch(`/locales/${lang}.json`).then(response => {