Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
node_modules
.DS_STORE
yarn*
.idea
.idea/
package-lock*
dist/
11 changes: 11 additions & 0 deletions app/exam/Supportm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, {Component} from 'react'

export default class Supportm extends Component {

render(){
return <div className='full flex-center flex-column '>
<h1 className='text-center'>目前算法训练只支持PC版,请使用桌面浏览器登入</h1>

</div>
}
}
1 change: 1 addition & 0 deletions app/exam/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<head>
<meta charset="utf-8">
<title><%= htmlWebpackPlugin.options.title %></title>
<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-128577927-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
Expand Down
2 changes: 2 additions & 0 deletions app/exam/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Register from './Register'
import Activation from './Activation'
import RegisterSuccess from './RegisterSuccess'
import Home from './Home'
import Supportm from './Supportm'
import './styl/index.styl'

class App extends Component {
Expand All @@ -21,6 +22,7 @@ class App extends Component {
<Route path='/register' component={Register} />
<Route path='/regsucc' component={RegisterSuccess} />
<Route path='/activation' component={Activation} />
<Route path='/supportm' component={Supportm} />
</div>
</Router>
)
Expand Down
4 changes: 3 additions & 1 deletion app/exam/styl/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ div
align-items center
justify-content center
.flex-column
flex-direction column
flex-direction column
.text-center
text-align center
19 changes: 19 additions & 0 deletions scripts/lib/util/checkua.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* 检查ua
* @param userAgentInfo
* @returns {boolean}
* @constructor
*/
function IsPC(userAgentInfo) {
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}

module.exports = IsPC
10 changes: 7 additions & 3 deletions scripts/server/runner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path')
const express = require('express')
const chalk = require('chalk')
const IsPC = require(path.resolve(__dirname, '../lib/util/checkua.js'))
const godRegister = require(path.resolve(__dirname, '../../service/god/index.js'))
const opts = require('commander')
.version('1.0.0')
.usage('[options] <service ...>')
Expand All @@ -16,12 +18,14 @@ if( !( port && service) ) {
process.exit(1)
}



function run_service(service, port) {
const app = require('express')()

godRegister(app);
app.use((req,res, next) => {
let ispc = IsPC(req.headers['user-agent']);
if (!ispc) {
res.redirect('/supportm');
}
console.log('request:', req.path)
next()
})
Expand Down
13 changes: 13 additions & 0 deletions service/god/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require('path')
const fs = require('fs')
/**
* 全局服务注册函数
* 向express中注册路由
*/
function register(app) {
app.get('/supportm', function(req, res) {
res.sendFile(path.resolve(__dirname, '../../dist/exam/index.html'))
})
}

module.exports = register
2 changes: 1 addition & 1 deletion service/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ function register(app) {
})
}

module.exports = register
module.exports = register
6 changes: 6 additions & 0 deletions sql/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM mysql:5.7

MAINTAINER isam2016(isam2016@126.com)

# 拷贝建表语句
COPY 000001.sql /docker-entrypoint-initdb.d