Skip to content

Commit

Permalink
Merge pull request UnicornTeam#1 from peacesky/Bug_Fix
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
Anderson-Liu authored Apr 2, 2018
2 parents ccc6452 + 352a340 commit 6734b17
Show file tree
Hide file tree
Showing 15 changed files with 467 additions and 186 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bootstrap-vue-experiments
# Cube Manager

> A Vue.js project
Expand Down Expand Up @@ -27,4 +27,8 @@ npm run e2e
npm test
```

## Backend Host
`http://localhost:5000`
You can change it in config/*.env.js

For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
67 changes: 67 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
- Store origin data when navigate to another page, and restore it when back to origin page.

- AP List、Client List初始化为空
- NFC Page 按钮关闭无操作
- RF Page 里的TPMS数字输入框太窄

Done [Check All]for const of obj NOT for const in obj

- INFO Update log 字体颜色太浅
Done WIFI 和 Client List
- 点击了下面任意按钮停止Scan
- WIFI 信道默认显示6
Done Client List 动态渲染

- 不同页面间的数据传递:
- NFC获取到数据后,通知RF界面展示通知
- NFC页面生命周期会不会被destroy?
- 返回后如何展示最新数据?
- 在RF页面监听NFC,点击携带数据跳转到NFC并渲染数据

- How axios deal with:
- 400 BAD Request
- 404 NOT FOUND
- 304 NOT MODIFIED
- 500 INTERNAL SERVER ERROR


- WIFI List 分页
- 测试能否正确处理INFO页面的304,增加其他页面的304处理逻辑

- Change all response parser correspond backend response api.NOTE: Use data-key to get data.

- Improve axios resp handler of above's http status:
- Handle 304 NOT MODIFIED in INFO page.

```
Handling Errors
axios.get('/user/12345')
.catch(function (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.config);
});
You can define a custom HTTP status code error range using the validateStatus config option.
axios.get('/user/12345', {
validateStatus: function (status) {
return status < 500; // Reject only if the status code is greater than or equal to 500
}
})
```


4 changes: 2 additions & 2 deletions config/dev.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ var prodEnv = require('./prod.env');

module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
BACKEND_HOST: '"http://localhost:5000"',
UPLOAD_API: '"//localhost:5000/upload"'
BACKEND_HOST: '"http://192.168.2.3:5000"',
UPLOAD_API: '"//192.168.2.3:5000/upload"'
});
4 changes: 2 additions & 2 deletions config/prod.env.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
NODE_ENV: '"production"',
BACKEND_HOST: '"http://localhost:5000"',
UPLOAD_API: '"//localhost:5000/upload"'
BACKEND_HOST: '"http://192.168.2.3:5000"',
UPLOAD_API: '"//192.168.2.3:5000/upload"'
};
4 changes: 2 additions & 2 deletions config/test.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ var devEnv = require('./dev.env')

module.exports = merge(devEnv, {
NODE_ENV: '"testing"',
BACKEND_HOST: '"http://localhost:5000"',
UPLOAD_API: '"//localhost:5000/upload"',
BACKEND_HOST: '"http://192.168.2.3:5000"',
UPLOAD_API: '"//192.168.2.3:5000/upload"',
});
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<meta http-equiv='refresh' name='viewport' content='width=device-width, initial-scale=1' />
<meta http-equiv='refresh' name='viewport' content='width=device-width' />
<title>Cube manage</title>
</head>
<body>
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"vant": "^1.0.2",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"vue-timers": "^1.2.0"
"vue-timers": "^1.2.0",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Vant from 'vant';
import 'vant/lib/vant-css/index.css';
import 'iview/dist/styles/iview.css';
import iView from 'iview';
import Vuex from 'vuex';
import VueTimers from 'vue-timers';
import App from './App';
import router from './router';
Expand All @@ -18,6 +19,7 @@ Vue.use(Vant);
Vue.use(BootstrapVue);
Vue.use(iView);
Vue.use(VueTimers);
Vue.use(Vuex);
Vue.config.productionTip = false;

/* eslint-disable no-new */
Expand Down
64 changes: 44 additions & 20 deletions src/views/HID/HID.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div style="margin: 10px">
<div class="board">
<cube-nav/>

<h1 class="text-center">Cube HID Manage</h1>
Expand All @@ -11,18 +11,12 @@
placeholder="Key">
</b-form-input>
<br/>

<h5>上传攻击脚本</h5>
<Upload
:data="extraData"
:before-upload="beforeUpload"
:action="uploadHost"
:on-success="onUploadSuccess"
:on-error="onUploadFail">
<Button type="ghost" icon="ios-cloud-upload-outline">Upload files</Button>
</Upload>
<div class="text-center">
<Button type="ghost" icon="ios-cloud-upload-outline" @click="onClickSubmit">Submit</Button>
</div>
<br/><br/>


<h5>Script</h5>
<b-table :items="items" :fields="fields">
<div slot="Run" slot-scope="data">
Expand All @@ -34,29 +28,47 @@

<script>
import CubeNav from '@/components/CubeNav';
import { Upload, Button } from 'iview';
import axios from 'axios';
export default {
name: 'HID',
components: {
CubeNav,
Upload,
Button,
},
data() {
return {
Key: null,
uploadHost: process.env.UPLOAD_API,
extraData: { type: 'HID-Script' },
fields: ['Info', 'Size', 'Run'],
fields: ['Info', 'Name', 'Run'],
items: [
{ Index: 0, Info: '539fsdf', Size: '522', Run: false },
{ Index: 1, Info: '54j3n4j', Size: '94', Run: false },
{ Index: 2, Info: 'ipfd93v', Size: '101', Run: false },
{ Index: 0, Info: '29d172a6', Name: '锁屏', Run: false },
{ Index: 1, Info: 'd2f392f1', Name: '添加用户', Run: false },
{ Index: 2, Info: '9209993f', Name: 'ShellCode', Run: false },
],
};
},
methods: {
serialSend(parameter) {
axios
.get(`${process.env.BACKEND_HOST}/serial_send/${parameter}`)
.then((response) => {
const result = response.data;
console.log(result);
this.$Message.success('Execute success.');
})
.catch((err) => {
console.log(err.response);
this.$Message.error('Execute fail.');
});
},
onClickSubmit() {
if (this.Key) {
this.serialSend(this.Key);
} else {
this.$Message.error('Please input Key before submit.');
}
},
onRead(file, content) {
console.log(file);
console.log(content);
Expand All @@ -67,15 +79,27 @@
// TODO: Deal with onClick logic.
onClick(index) {
console.log(index);
switch (index) {
case 0:
this.serialSend('ha');
break;
case 1:
this.serialSend('hb');
break;
case 2:
// 暂时不管
break;
default:
break;
}
},
beforeUpload(file) {
// TODO: Add more feature argument
console.log(file);
},
onUploadSuccess(response, file, fileList) {
onUploadSuccess(response) {
console.log(response);
this.$Message.success('Upload success');
fileList.remove(file);
},
onUploadFail(err) {
console.log(err);
Expand Down
Loading

0 comments on commit 6734b17

Please sign in to comment.