Merge branch 'release/v1.2.4/develop_env_var'

This commit is contained in:
peterlu14
2022-07-07 09:35:39 +08:00
8 changed files with 137 additions and 9 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
"description": "Vue.js admin template",
"author": "smartapant <smartapant@gmail.com>",
"scripts": {
"serve": "vue-cli-service serve",
"serve": "vue-cli-service serve --mode development",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"lint:style": "stylelint --fix src/**/*.{vue,htm,html,css,sss,less,scss}",
+13 -5
View File
@@ -44,13 +44,22 @@ import '../registerServiceWorker'
localforage.config({ name: 'bioprovue' })
let MqttUrl
// for developer
if (process.env.NODE_ENV === 'development') {
MqttUrl = 'ws://192.168.5.240:8083'
} else {
// for user
MqttUrl = `ws://${location.href.split('/')[2]}:8083`
}
if (process.env.VUE_APP_BUILD_VERSION) {
// eslint-disable-next-line
const message = `%c${'Build_information:'}\n %c${'Version'}: %c${VERSION},\n %c${'Timestamp'}: %c${TIMESTAMP},\n %c${'Commit'}: %c${COMMIT}`
const message = `%c${'Build_information:'}\n %c${'Version'}: %c${VERSION},\n %c${'Timestamp'}: %c${TIMESTAMP},\n %c${'Commit'}: %c${COMMIT} %c${'Mqtt'}: %c${MqttUrl}`
// eslint-disable-next-line
console.info(
message,
'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;',
'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;', 'color: red;', 'color: blue;',
)
}
@@ -61,11 +70,10 @@ Vue.component('chart', ECharts)
Vue.use(VueWorker)
Vue.use(VueAxios, axios)
Vue.use(Toast)
// Vue.use(VueMqtt, 'ws://52.194.17.114:8083')
Vue.use(VueMqtt, 'ws://' + location.href.split('/')[2] + ':8083')
// Vue.use(VueMqtt, 'ws://' + location.href.split('/')[2] + ':8083')
// Vue.use(VueMqtt, 'ws://' + '192.168.151.125' + ':8083')
// Vue.use(VueMqtt, 'ws://' + '192.168.3.211' + ':8083')
Vue.use(VueMqtt, MqttUrl)
Vue.prototype.API = api
Vue.prototype.GLOBAL = global_
+115
View File
@@ -0,0 +1,115 @@
<template>
<va-card class="flex xl3 md3 sm12 xs12" title="MQTT">
<div class="row ma-1 text-center">
<va-button @click="getControllerID">Controller-ID</va-button>
<div class="flex-center">
{{ controllerID }}
</div>
</div>
<div class="row ma-1 text-start" v-if="controllerID !== ''">
<va-button @click="getHardwareInfo">HardwareInfo</va-button>
<div class="">
{{ responseMessage }}
</div>
</div>
</va-card>
</template>
<script>
import api from '@/data/api'
export default {
name: 'Developer',
components: {
},
data () {
return {
controllerID: '',
responseMessage: '',
}
},
mqtt: {
async '+/get_device_info_all/+' (data, topic) {
console.log('get_device_info_all', String.fromCharCode.apply(null, data))
},
async '+/hardware_device/+' (data, topic) {
console.log('hardware_device', String.fromCharCode.apply(null, data))
},
async '+/hardware_datetime/+' (data, topic) {
console.log('hardware_datetime', String.fromCharCode.apply(null, data))
},
async '+/hardware_info/+' (data, topic) {
console.log('hardware_info', String.fromCharCode.apply(null, data))
this.responseMessage = String.fromCharCode.apply(null, data)
},
async '+/broadcast/+' (data, topic) {
console.log('broadcast', String.fromCharCode.apply(null, data))
},
},
methods: {
mqttPub: function (topic, mes) {
this.$mqtt.publish(topic, mes)
},
mqttSub: function (val) {
this.$mqtt.subscribe(val)
},
mqttUnSub: function (val) {
this.$mqtt.unsubscribe(val)
},
pageMqttSub: function (id) {
this.mqttSub(id + '/hardware_datetime/+')
this.mqttSub(id + '/hardware_device/+')
this.mqttSub(id + '/hardware_info/+')
this.mqttSub(id + '/broadcast')
this.mqttSub(id + '/get_device_info_all/+')
},
pageMqttUnSub: function (id) {
this.mqttUnSub(id + '/hardware_datetime/+')
this.mqttUnSub(id + '/hardware_device/+')
this.mqttUnSub(id + '/hardware_info/+')
this.mqttUnSub(id + '/broadcast')
this.mqttUnSub(id + '/get_device_info_all/+')
},
getControllerID: async function () {
try {
const response = await api.controller.getAll()
if (response.status === 200) {
if (response.data.length > 0) {
this.controllerID = response.data[0].mqtt_id
this.pageMqttSub(this.controllerID)
return true
}
this.controllerID = 'No Controller Info'
return false
}
this.controllerID = 'Wrong status ' + response.status
} catch (e) {
console.log(e)
this.controllerID = e
}
},
getHardwareDatetime: function () {
this.mqttPub(this.controllerID + '_user', JSON.stringify({
header: 'hardware_datetime/0',
content: String(Date.now()),
}))
},
getHardwareInfo: function () {
this.mqttPub(this.controllerID + '_user', JSON.stringify({
header: 'hardware_info/0',
}))
},
},
async mounted () {
},
destroyed () {
if (this.controllerID !== '') {
this.pageMqttUnSub(this.controllerID)
}
},
}
</script>
<style>
</style>
-1
View File
@@ -79,7 +79,6 @@ async function getAll () {
}
async function getByParentName (collectionType, parent, name) {
console.log(collectionType, parent, name)
const _header = auth.getHeader()
try {
return await api.axios.get(`/api/file/collection/get_by_parent_name/${collectionType}/${parent}/${name}`, { headers: _header })
-1
View File
@@ -13,7 +13,6 @@ async function create (_data) {
async function getAll () {
const _header = auth.getHeader()
console.log(_header)
try {
return await api.axios.get('/api/controller/get/all', { headers: _header })
} catch (e) {
-1
View File
@@ -13,7 +13,6 @@ async function create (_data) {
async function getAll () {
const _header = auth.getHeader()
console.log(_header)
try {
return await api.axios.get('/api/task/get/all', { headers: _header })
} catch (e) {
+5
View File
@@ -153,6 +153,11 @@ export default new Router({
path: 'developer',
component: () => import('../components/developer/Developer.vue'),
},
{
name: 'debug',
path: 'debug',
component: () => import('../components/debug/Debug.vue'),
},
{
name: 'statistics',
path: 'statistics',
+3
View File
@@ -54,6 +54,9 @@ module.exports = {
TIMESTAMP: JSON.stringify(timeStamp),
COMMIT: JSON.stringify(getLastCommitHash()),
}),
new webpack.EnvironmentPlugin({
VUE_APP_BUILD_VERSION: '1.0.0',
}),
],
},
css: {