Skip to content

Merge Develop #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
May 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
25288f0
fix(event): LoginEvent
lisgroup Apr 25, 2019
e95fccb
fix(repo): 变量不存在报错问题
lisgroup Apr 25, 2019
d9d24fd
fix(repo): 变量不存在报错问题
lisgroup Apr 25, 2019
52ab8d8
add: wj
lisgroup Apr 26, 2019
b111e1b
delete: test
lisgroup Apr 26, 2019
03e14ab
add: 算法.md
lisgroup Apr 27, 2019
e261854
update: md
lisgroup Apr 28, 2019
c037d97
fix(repo): 修改活动表的名称
lisgroup Apr 28, 2019
04a8247
fix(control): `website` 字段可空
lisgroup Apr 29, 2019
2b46d80
update: readme
lisgroup Apr 30, 2019
0220f01
update: readme
lisgroup May 1, 2019
7e8f92b
fix(websocket): 获取用户信息
lisgroup May 1, 2019
b0c8e5c
fix(event): 请求返回的数据入队列
lisgroup May 3, 2019
09007fe
fix(repo): 暂不使用队列
lisgroup May 3, 2019
bc5ea54
fix(view): 增加刷新功能
lisgroup May 3, 2019
5ab5422
chore(view): 构建前端
lisgroup May 3, 2019
01e3fe1
fix(socket): 获取进度
lisgroup May 4, 2019
3b3054c
fix(repo): 更新数据库字段
lisgroup May 4, 2019
9ca78cb
fix(repo): 进度条的逻辑
lisgroup May 4, 2019
ff29b9e
fix(view): 进度条
lisgroup May 4, 2019
8426110
fix(repo): 使用 $total_excel 计算值
lisgroup May 4, 2019
6cedda9
fix(repo): 进度条完成后台功能
lisgroup May 4, 2019
e96c961
fix(socket): 获取数据
lisgroup May 4, 2019
8537a78
fix(view): websocket 获取数据列表
lisgroup May 5, 2019
f23eb0d
fix: url
lisgroup May 5, 2019
f4d909e
fix: 提供数据方法
lisgroup May 5, 2019
c9a8e7a
fix: 根据 api_excel_id 获取完成率
lisgroup May 5, 2019
0f8dc32
fix: 限制单个连接请求次数
lisgroup May 5, 2019
86423c4
fix: rate 未开启状态为 0
lisgroup May 5, 2019
92adfb4
fix: 任务完成后再输出客户端一次结果
lisgroup May 5, 2019
247885f
chore(view): 构建前端
lisgroup May 5, 2019
7aa8acf
fix(view): 增加 websocket 配置
lisgroup May 5, 2019
233c094
chore(view): 构建前端
lisgroup May 5, 2019
01408a2
fix: 老数据获取列表
lisgroup May 5, 2019
de72aa7
fix(control): 初始化
lisgroup May 6, 2019
81e0b34
fix(view): websocket 分页可能导致的问题
lisgroup May 7, 2019
bd3a625
fix(repo): 记录时间
lisgroup May 7, 2019
71b986e
fix(control): 查询指定字段防止数据过大
lisgroup May 7, 2019
47211e1
add: config
lisgroup May 8, 2019
748613a
add: config
lisgroup May 8, 2019
206af1a
update: config 操作
lisgroup May 8, 2019
6710b4f
Merge remote-tracking branch 'origin/develop' into develop
lisgroup May 9, 2019
a5c9a7b
fix(control): 配置存入缓存
lisgroup May 9, 2019
05e35c3
fix(view): 获取和更新数据
lisgroup May 9, 2019
d8f2407
fix(control): 开启权限验证
lisgroup May 10, 2019
9b80102
fix(control): 根据条件查询不同效果
lisgroup May 10, 2019
741114b
chore(view): 构建前端
lisgroup May 10, 2019
1fd226f
update: README.md
lisgroup May 11, 2019
5544035
update: README.md
lisgroup May 11, 2019
c29e57a
update: README.md
lisgroup May 12, 2019
3b0901a
add: README.md
lisgroup May 13, 2019
ae2785d
update: README.md
lisgroup May 13, 2019
8d2c02d
fix(view): 设置超时后重新发起请求
lisgroup May 14, 2019
390bb15
fix(view): 登录日志为 line
lisgroup May 14, 2019
ee5f065
chore(view): 构建前端
lisgroup May 14, 2019
a1aa264
fix(control): 登录日志 m-d 格式
lisgroup May 14, 2019
cc352cd
chore(view): 构建前端
lisgroup May 16, 2019
a71cf22
fix(view): 开启 history 模式
lisgroup May 16, 2019
ee33d10
fix(view): 服务器暂未配置 history 模式
lisgroup May 16, 2019
36e0d2a
chore(view): 构建前端
lisgroup May 16, 2019
d484b79
cheat: .travis.yml
lisgroup May 17, 2019
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
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: php

php:
- 7.0.27
- 7.1.13
- 7.2.1
- 7.3.1

before_script:
- cd laravel
- composer install

script: composer info
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ npm run dev

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

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

# ssl 配置
Expand Down Expand Up @@ -217,8 +217,8 @@ upstream laravels {
server {
listen 80;
# 别忘了绑Host哟
server_name www.bus.com;
root /home/www/vueBus/laravel/public;
server_name www.guke1.com;
root /home/www/laravel-vue-admin/laravel/public;
access_log /home/wwwlogs/nginx/$server_name.access.log;
autoindex off;
index index.html index.htm;
Expand Down
1 change: 1 addition & 0 deletions admin/config/dev.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
BASE_API: '"http://localhost:8000"',
WEBSOCKET: '"ws://127.0.0.1:5200"',
})
1 change: 1 addition & 0 deletions admin/config/prod.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
module.exports = {
NODE_ENV: '"production"',
BASE_API: '"https://www.guke1.com"',
WEBSOCKET: '"wss://www.guke1.com/ws"',
}
37 changes: 37 additions & 0 deletions admin/src/api/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import request from '@/utils/request'

export function getList(params) {
return request({
url: '/api/config',
method: 'get',
params
})
}

export function postAdd(params) {
return request.post('/api/config', params)
}

export function edit(id) {
return request.get('/api/config/' + id)
}

export function postEdit(id, params) {
return request.patch('/api/config/' + id, params)
}

export function deleteAct(id) {
return request.delete('/api/config/' + id)
}

/**
* 搜索 config
* @param params
*/
export function search(params) {
return request({
url: '/api/config_search',
method: 'get',
params
})
}
2 changes: 1 addition & 1 deletion admin/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const routeTest = [
export const constantRouterMap = [...routeBase, ...routeTest]

export default new Router({
// mode: 'history', //后端支持可开
// mode: 'history', // 后端支持可开
scrollBehavior: () => ({ y: 0 }),
routes: constantRouterMap
})
2 changes: 1 addition & 1 deletion admin/src/router/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export const routeSuper = [
{
path: 'config',
name: '配置管理',
component: () => import('@/views/lines/index'),
component: () => import('@/views/config/index'),
meta: { title: '配置列表', icon: 'table', roles: [Super] }
},
{
Expand Down
41 changes: 35 additions & 6 deletions admin/src/utils/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { getToken } from '@/utils/auth'
// 创建axios实例
const service = axios.create({
baseURL: process.env.BASE_API, // api 的 base_url
timeout: 5000 // 请求超时时间
timeout: 5000, // 请求超时时间
retry: 3, // 全局的请求次数,请求的间隙
retryDelay: 300
})

// request拦截器
Expand Down Expand Up @@ -62,12 +64,39 @@ service.interceptors.response.use(
},
error => {
console.log('err' + error) // for debug
Message({
message: error.message,
type: 'error',
duration: 5 * 1000
const config = error.config
console.log(config)
// If config does not exist or the retry option is not set, reject
if (!config || !config.retry) return Promise.reject(error)

// Set the variable for keeping track of the retry count
config.__retryCount = config.__retryCount || 0

// Check if we've maxed out the total number of retries
if (config.__retryCount >= config.retry) {
// Reject with the error
Message({
message: error.message,
type: 'error',
duration: 5 * 1000
})
return Promise.reject(error)
}

// Increase the retry count
config.__retryCount += 1

// Create new promise to handle exponential backoff
const backoff = new Promise(function(resolve) {
setTimeout(function() {
resolve()
}, config.retryDelay || 1)
})

// Return the promise in which recalls axios to retry the request
return backoff.then(function() {
return axios(config)
})
return Promise.reject(error)
}
)

Expand Down
58 changes: 43 additions & 15 deletions admin/src/views/api_excel/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<el-button type="primary" size="medium">
<router-link to="/api_excel/add">上传测试</router-link>
</el-button>
<el-button :loading="reload" type="primary" class="reload" plain @click="fetchData">{{ reload_name }}</el-button>
</el-row>
<el-table
v-loading="listLoading"
Expand Down Expand Up @@ -55,7 +56,7 @@
</template>
</el-table-column>

<el-table-column label="进度条" width="1" align="center" display="none">
<el-table-column label="进度条" width="100" align="center" display="none">
<template slot-scope="scope">
<div v-if="scope.row.state === 0">
<el-progress :text-inside="true" :stroke-width="18" :percentage="0"/>
Expand All @@ -67,7 +68,7 @@
<el-progress :text-inside="true" :stroke-width="18" :percentage="100" status="success"/>
</div>
<div v-else>
<el-progress :text-inside="true" :stroke-width="18" :percentage="50" status="exception"/>
<el-progress :text-inside="true" :stroke-width="18" :percentage="scope.row.rate" status="exception"/>
</div>
</template>
</el-table-column>
Expand Down Expand Up @@ -126,6 +127,7 @@
</template>

<script>
import { getToken } from '@/utils/auth'
import { getList, deleteAct, search, startTask, download_log } from '@/api/api_excel'

export default {
Expand All @@ -141,6 +143,8 @@ export default {
},
data() {
return {
reload: false,
reload_name: '点击刷新',
list: null,
listLoading: true,
perpage: 10,
Expand All @@ -153,10 +157,12 @@ export default {
},
created() {
this.listQuery = this.$route.query
this.currentpage = parseInt(this.listQuery.page)
const page = parseInt(this.listQuery.page)
this.currentpage = isNaN(page) ? 1 : page
const perPage = parseInt(this.$route.query.perPage)
this.perpage = isNaN(perPage) ? this.perpage : perPage
this.fetchData()
// this.fetchData()
this.initWebSocket()
},
destroyed() {
this.websock.close() // 离开路由之后断开 websocket 连接
Expand Down Expand Up @@ -209,20 +215,22 @@ export default {
type: msg,
message: res.reason
})
this.initWebSocket()
})
}
}
})
},
initWebSocket(id) { // 初始化 weosocket
initWebSocket() { // 初始化 weosocket
if ('WebSocket' in window) {
const url = 'wss://www.guke1.com/ws?id=' + id
const url = process.env.WEBSOCKET + '?action=api_excel&token=' + getToken() + '&page=' + this.currentpage + '&perPage=' + this.perpage
this.websock = new WebSocket(url)
this.websock.onmessage = this.onmessage
this.websock.onopen = this.onopen
this.websock.onerror = this.onerror
this.websock.onclose = this.close
} else {
this.fetchData()
// 浏览器不支持 WebSocket,使用 ajax 轮询
console.log('Your browser does not support WebSocket!')
}
Expand All @@ -232,44 +240,60 @@ export default {
// const rs = this.send(JSON.stringify(actions))
// console.log(rs)
},
onerror() { // 连接建立失败重连
onerror() {
// 连接建立失败, 发送 http 请求获取数据
// this.initWebSocket()
this.fetchData()
},
onmessage(e) { // 数据接收
console.log(e.data)
// console.log(e.data)
const data = JSON.parse(e.data)
// this.list[2].rate = parseInt(data.data.rate)
// console.log(this.list[2].rate)
console.log(data)
// console.log(data)
// websocket 返回的数据
this.list = data.data.data
this.listLoading = false
this.total = data.data.total
this.url = data.data.appUrl
// console.log('type', Object.prototype.toString.call(this.list))
setTimeout(() => {
this.reload = false
this.reload_name = '刷新'
}, 800)
},
send(Data) {
this.websock.send(Data)
},
close() { // 关闭
console.log('断开连接')
// console.log('断开连接')
},
download(index, row) {
window.location.href = this.url + row.finish_url
},
download_log(index, row) {
download_log({ id: row.id }).then(res => {
console.log(res)
// console.log(res)
if (res.code === 200) {
window.location.href = this.url + res.data.failed_done_file
}
})
},
fetchData() {
this.listLoading = true
this.listLoading = this.reload = true
this.reload_name = '加载中'
const params = Object.assign({ 'page': this.listQuery.page }, { 'perPage': this.perpage })
getList(params).then(response => {
this.list = response.data.data
this.listLoading = false
this.total = response.data.total
this.url = response.data.appUrl
console.log('type', Object.prototype.toString.call(this.list))

this.initWebSocket(8)
// console.log('type', Object.prototype.toString.call(this.list))
setTimeout(() => {
this.reload = false
this.reload_name = '刷新'
}, 800)
// this.initWebSocket()
})
},
handleEdit(index, row) {
Expand Down Expand Up @@ -354,4 +378,8 @@ export default {
.pagination {
margin: 20px auto;
}
.reload {
margin-right: 300px;
float: right;
}
</style>
Loading