Skip to content

Commit a698a85

Browse files
authored
Merge pull request #2 from lisgroup/develop
Merge Develop
2 parents ff34609 + d484b79 commit a698a85

File tree

232 files changed

+1759
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+1759
-182
lines changed

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
php:
4+
- 7.0.27
5+
- 7.1.13
6+
- 7.2.1
7+
- 7.3.1
8+
9+
before_script:
10+
- cd laravel
11+
- composer install
12+
13+
script: composer info

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ npm run dev
138138

139139
# 打包(可选)
140140
npm run build
141-
# 将 dist 目录下的文件 copy 到 php/public 目录。
142141
```
142+
~~npm run build 命令会自动将 dist 目录下的文件 copy 到 laravel/public 目录下。~~
143143

144144
## 域名绑定
145145
域名需要绑定到根目录,即项目的 laravel/public 目录下。
@@ -149,7 +149,7 @@ npm run build
149149
```shell
150150
server {
151151
listen 443 ssl;
152-
root /www/vueBus/laravel/public;
152+
root /www/laravel-vue-admin/laravel/public;
153153
server_name www.guke1.com; # 改为绑定证书的域名
154154

155155
# ssl 配置
@@ -217,8 +217,8 @@ upstream laravels {
217217
server {
218218
listen 80;
219219
# 别忘了绑Host哟
220-
server_name www.bus.com;
221-
root /home/www/vueBus/laravel/public;
220+
server_name www.guke1.com;
221+
root /home/www/laravel-vue-admin/laravel/public;
222222
access_log /home/wwwlogs/nginx/$server_name.access.log;
223223
autoindex off;
224224
index index.html index.htm;

admin/config/dev.env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ const prodEnv = require('./prod.env')
55
module.exports = merge(prodEnv, {
66
NODE_ENV: '"development"',
77
BASE_API: '"http://localhost:8000"',
8+
WEBSOCKET: '"ws://127.0.0.1:5200"',
89
})

admin/config/prod.env.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
module.exports = {
33
NODE_ENV: '"production"',
44
BASE_API: '"https://www.guke1.com"',
5+
WEBSOCKET: '"wss://www.guke1.com/ws"',
56
}

admin/src/api/config.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import request from '@/utils/request'
2+
3+
export function getList(params) {
4+
return request({
5+
url: '/api/config',
6+
method: 'get',
7+
params
8+
})
9+
}
10+
11+
export function postAdd(params) {
12+
return request.post('/api/config', params)
13+
}
14+
15+
export function edit(id) {
16+
return request.get('/api/config/' + id)
17+
}
18+
19+
export function postEdit(id, params) {
20+
return request.patch('/api/config/' + id, params)
21+
}
22+
23+
export function deleteAct(id) {
24+
return request.delete('/api/config/' + id)
25+
}
26+
27+
/**
28+
* 搜索 config
29+
* @param params
30+
*/
31+
export function search(params) {
32+
return request({
33+
url: '/api/config_search',
34+
method: 'get',
35+
params
36+
})
37+
}

admin/src/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const routeTest = [
126126
export const constantRouterMap = [...routeBase, ...routeTest]
127127

128128
export default new Router({
129-
// mode: 'history', //后端支持可开
129+
// mode: 'history', // 后端支持可开
130130
scrollBehavior: () => ({ y: 0 }),
131131
routes: constantRouterMap
132132
})

admin/src/router/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const routeSuper = [
137137
{
138138
path: 'config',
139139
name: '配置管理',
140-
component: () => import('@/views/lines/index'),
140+
component: () => import('@/views/config/index'),
141141
meta: { title: '配置列表', icon: 'table', roles: [Super] }
142142
},
143143
{

admin/src/utils/request.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { getToken } from '@/utils/auth'
66
// 创建axios实例
77
const service = axios.create({
88
baseURL: process.env.BASE_API, // api 的 base_url
9-
timeout: 5000 // 请求超时时间
9+
timeout: 5000, // 请求超时时间
10+
retry: 3, // 全局的请求次数,请求的间隙
11+
retryDelay: 300
1012
})
1113

1214
// request拦截器
@@ -62,12 +64,39 @@ service.interceptors.response.use(
6264
},
6365
error => {
6466
console.log('err' + error) // for debug
65-
Message({
66-
message: error.message,
67-
type: 'error',
68-
duration: 5 * 1000
67+
const config = error.config
68+
console.log(config)
69+
// If config does not exist or the retry option is not set, reject
70+
if (!config || !config.retry) return Promise.reject(error)
71+
72+
// Set the variable for keeping track of the retry count
73+
config.__retryCount = config.__retryCount || 0
74+
75+
// Check if we've maxed out the total number of retries
76+
if (config.__retryCount >= config.retry) {
77+
// Reject with the error
78+
Message({
79+
message: error.message,
80+
type: 'error',
81+
duration: 5 * 1000
82+
})
83+
return Promise.reject(error)
84+
}
85+
86+
// Increase the retry count
87+
config.__retryCount += 1
88+
89+
// Create new promise to handle exponential backoff
90+
const backoff = new Promise(function(resolve) {
91+
setTimeout(function() {
92+
resolve()
93+
}, config.retryDelay || 1)
94+
})
95+
96+
// Return the promise in which recalls axios to retry the request
97+
return backoff.then(function() {
98+
return axios(config)
6999
})
70-
return Promise.reject(error)
71100
}
72101
)
73102

admin/src/views/api_excel/index.vue

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<el-button type="primary" size="medium">
55
<router-link to="/api_excel/add">上传测试</router-link>
66
</el-button>
7+
<el-button :loading="reload" type="primary" class="reload" plain @click="fetchData">{{ reload_name }}</el-button>
78
</el-row>
89
<el-table
910
v-loading="listLoading"
@@ -55,7 +56,7 @@
5556
</template>
5657
</el-table-column>
5758

58-
<el-table-column label="进度条" width="1" align="center" display="none">
59+
<el-table-column label="进度条" width="100" align="center" display="none">
5960
<template slot-scope="scope">
6061
<div v-if="scope.row.state === 0">
6162
<el-progress :text-inside="true" :stroke-width="18" :percentage="0"/>
@@ -67,7 +68,7 @@
6768
<el-progress :text-inside="true" :stroke-width="18" :percentage="100" status="success"/>
6869
</div>
6970
<div v-else>
70-
<el-progress :text-inside="true" :stroke-width="18" :percentage="50" status="exception"/>
71+
<el-progress :text-inside="true" :stroke-width="18" :percentage="scope.row.rate" status="exception"/>
7172
</div>
7273
</template>
7374
</el-table-column>
@@ -126,6 +127,7 @@
126127
</template>
127128

128129
<script>
130+
import { getToken } from '@/utils/auth'
129131
import { getList, deleteAct, search, startTask, download_log } from '@/api/api_excel'
130132
131133
export default {
@@ -141,6 +143,8 @@ export default {
141143
},
142144
data() {
143145
return {
146+
reload: false,
147+
reload_name: '点击刷新',
144148
list: null,
145149
listLoading: true,
146150
perpage: 10,
@@ -153,10 +157,12 @@ export default {
153157
},
154158
created() {
155159
this.listQuery = this.$route.query
156-
this.currentpage = parseInt(this.listQuery.page)
160+
const page = parseInt(this.listQuery.page)
161+
this.currentpage = isNaN(page) ? 1 : page
157162
const perPage = parseInt(this.$route.query.perPage)
158163
this.perpage = isNaN(perPage) ? this.perpage : perPage
159-
this.fetchData()
164+
// this.fetchData()
165+
this.initWebSocket()
160166
},
161167
destroyed() {
162168
this.websock.close() // 离开路由之后断开 websocket 连接
@@ -209,20 +215,22 @@ export default {
209215
type: msg,
210216
message: res.reason
211217
})
218+
this.initWebSocket()
212219
})
213220
}
214221
}
215222
})
216223
},
217-
initWebSocket(id) { // 初始化 weosocket
224+
initWebSocket() { // 初始化 weosocket
218225
if ('WebSocket' in window) {
219-
const url = 'wss://www.guke1.com/ws?id=' + id
226+
const url = process.env.WEBSOCKET + '?action=api_excel&token=' + getToken() + '&page=' + this.currentpage + '&perPage=' + this.perpage
220227
this.websock = new WebSocket(url)
221228
this.websock.onmessage = this.onmessage
222229
this.websock.onopen = this.onopen
223230
this.websock.onerror = this.onerror
224231
this.websock.onclose = this.close
225232
} else {
233+
this.fetchData()
226234
// 浏览器不支持 WebSocket,使用 ajax 轮询
227235
console.log('Your browser does not support WebSocket!')
228236
}
@@ -232,44 +240,60 @@ export default {
232240
// const rs = this.send(JSON.stringify(actions))
233241
// console.log(rs)
234242
},
235-
onerror() { // 连接建立失败重连
243+
onerror() {
244+
// 连接建立失败, 发送 http 请求获取数据
236245
// this.initWebSocket()
246+
this.fetchData()
237247
},
238248
onmessage(e) { // 数据接收
239-
console.log(e.data)
249+
// console.log(e.data)
240250
const data = JSON.parse(e.data)
241251
// this.list[2].rate = parseInt(data.data.rate)
242252
// console.log(this.list[2].rate)
243-
console.log(data)
253+
// console.log(data)
254+
// websocket 返回的数据
255+
this.list = data.data.data
256+
this.listLoading = false
257+
this.total = data.data.total
258+
this.url = data.data.appUrl
259+
// console.log('type', Object.prototype.toString.call(this.list))
260+
setTimeout(() => {
261+
this.reload = false
262+
this.reload_name = '刷新'
263+
}, 800)
244264
},
245265
send(Data) {
246266
this.websock.send(Data)
247267
},
248268
close() { // 关闭
249-
console.log('断开连接')
269+
// console.log('断开连接')
250270
},
251271
download(index, row) {
252272
window.location.href = this.url + row.finish_url
253273
},
254274
download_log(index, row) {
255275
download_log({ id: row.id }).then(res => {
256-
console.log(res)
276+
// console.log(res)
257277
if (res.code === 200) {
258278
window.location.href = this.url + res.data.failed_done_file
259279
}
260280
})
261281
},
262282
fetchData() {
263-
this.listLoading = true
283+
this.listLoading = this.reload = true
284+
this.reload_name = '加载中'
264285
const params = Object.assign({ 'page': this.listQuery.page }, { 'perPage': this.perpage })
265286
getList(params).then(response => {
266287
this.list = response.data.data
267288
this.listLoading = false
268289
this.total = response.data.total
269290
this.url = response.data.appUrl
270-
console.log('type', Object.prototype.toString.call(this.list))
271-
272-
this.initWebSocket(8)
291+
// console.log('type', Object.prototype.toString.call(this.list))
292+
setTimeout(() => {
293+
this.reload = false
294+
this.reload_name = '刷新'
295+
}, 800)
296+
// this.initWebSocket()
273297
})
274298
},
275299
handleEdit(index, row) {
@@ -354,4 +378,8 @@ export default {
354378
.pagination {
355379
margin: 20px auto;
356380
}
381+
.reload {
382+
margin-right: 300px;
383+
float: right;
384+
}
357385
</style>

0 commit comments

Comments
 (0)