Skip to content

Commit

Permalink
fix(components): dgiot-amis
Browse files Browse the repository at this point in the history
修复dgiot-amis 组件在切换账号后,认证仍为上一次的信息
  • Loading branch information
h7ml committed Jun 20, 2022
1 parent 5e2e19b commit 65c70a7
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 14 deletions.
30 changes: 21 additions & 9 deletions .cz-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ module.exports = {
{ value: 'feat', name: 'feat: 新增功能' },
{ value: 'fix', name: 'fix: 修复bug' },
{ value: 'docs', name: 'docs: 文档变更' },
{ value: 'style', name: 'style: 代码格式(不影响功能,例如空格、分号等格式修正)' },
{ value: 'refactor', name: 'refactor: 代码重构(不包括 bug 修复、功能新增)' },
{
value: 'style',
name: 'style: 代码格式(不影响功能,例如空格、分号等格式修正)',
},
{
value: 'refactor',
name: 'refactor: 代码重构(不包括 bug 修复、功能新增)',
},
{ value: 'perf', name: 'perf: 性能优化' },
{ value: 'test', name: 'test: 添加、修改测试用例' },
{ value: 'build', name: 'build: 构建流程、外部依赖变更(如升级 npm 包、修改 脚手架 配置等)' },
{
value: 'build',
name: 'build: 构建流程、外部依赖变更(如升级 npm 包、修改 脚手架 配置等)',
},
{ value: 'ci', name: 'ci: 修改 CI 配置、脚本' },
{ value: 'chore', name: 'chore: 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)' },
{ value: 'revert', name: 'revert: 回滚 commit' }
{
value: 'chore',
name: 'chore: 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)',
},
{ value: 'revert', name: 'revert: 回滚 commit' },
],
scopes: [
['projects', '项目搭建'],
Expand All @@ -21,11 +33,11 @@ module.exports = {
['deps', '项目依赖'],
['auth', '对 auth 修改'],
['other', '其他修改'],
['custom', '以上都不是?我要自定义']
['custom', '以上都不是?我要自定义'],
].map(([value, description]) => {
return {
value,
name: `${value.padEnd(30)} (${description})`
name: `${value.padEnd(30)} (${description})`,
}
}),
messages: {
Expand All @@ -36,9 +48,9 @@ module.exports = {
body: '填写更加详细的变更描述(可选)。使用 "|" 换行:\n',
breaking: '列举非兼容性重大的变更(可选):\n',
footer: '列举出所有变更的 ISSUES CLOSED(可选)。 例如: #31, #34:\n',
confirmCommit: '确认提交?'
confirmCommit: '确认提交?',
},
allowBreakingChanges: ['feat', 'fix'],
subjectLimit: 100,
breaklineChar: '|'
breaklineChar: '|',
}
7 changes: 5 additions & 2 deletions src/api/Dlink/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ export async function postTopic(Topic = '$dg/user/router/') {
const mqttInfo = {
href: location.href,
topic: Topic,
topicKey: Vue.prototype.$dgiotBus.getTopicKeyBypage(Topic.split('/')[2]),
splitTopicKey: Topic.split('/')[2],
topicKey:
typeof Topic == 'string'
? Vue.prototype.$dgiotBus.getTopicKeyBypage(Topic.split('/')[2])
: Topic,
splitTopicKey: typeof Topic == 'string' ? Topic.split('/')[2] : Topic,
}
console.groupCollapsed(
` href: ${mqttInfo.href} \n topic: ${mqttInfo.topic} \n topicKey: ${mqttInfo.topicKey} \n splitTopicKey: ${mqttInfo.splitTopicKey}`
Expand Down
5 changes: 3 additions & 2 deletions src/dgiot/components/DgiotAmis/render.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
</template>

<script>
import store from '@/store'
import { mapGetters } from 'vuex'
/**
* @description amis配置参数
Expand Down Expand Up @@ -119,8 +120,8 @@
_.merge(config.headers, {
author: 'iotn2n',
platform: 'amis',
departmentToken: this.departmentToken,
sessionToken: this.token,
departmentToken: store.getters['user/departmentToken'],
sessionToken: store.getters['user/token'],
})
if (method === 'get' && data) {
config.params = data
Expand Down
4 changes: 3 additions & 1 deletion src/views/CloudPressure/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,9 @@
delete device.objectId
delete device.endTime
delete device.startTime
// delete device.ip
// delete device.basedata
// delete device.devaddr
device.isEnable = false
device.devaddr = md5('Device' + Math.round(new Date()) + '').substring(
0,
Expand Down Expand Up @@ -968,7 +971,6 @@
limit: this.queryForm.limit,
count: 'objectId',
order: '-createdAt',
excludeKeys: 'product,content',
where: {
product: this.product,
},
Expand Down
28 changes: 28 additions & 0 deletions src/views/DeviceCloud/manage/devicelist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,34 @@
this.list = results
this.total = count
this.listLoading = false
// 订阅处理所有的设备
await this.subAllDevice()
},
async subAllDevice() {
const topics = []
this.list.forEach((item) => {
topics.push(
`/$dg/thing/device/${item.product.objectId}/${item.devaddr}/properties/publish`
)
})
await this.$subscribe(topics)
this.$dgiotBus.$on('/$dg/thing', (Msg) => {
console.log('收到消息', Msg)
const parseString = JSON.parse(Msg.payloadString)
console.log('收到消息', parseString)
if (parseString) {
const topicsKeys = Object.keys(parseString)
console.log(topicsKeys)
topicsKeys.forEach((t) => {
this.list.forEach((i) => {
if (i.objectId == t) {
const mergeInfo = _.merge(i, parseString[t])
console.log(`更新设备${i.name}`, mergeInfo)
}
})
})
}
})
},
},
}
Expand Down
29 changes: 29 additions & 0 deletions src/views/DeviceCloud/manage/home_index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,35 @@
this.list = list
this.total = total
this.listLoading = false
// 订阅处理所有的设备
await this.subAllDevice()
},
async subAllDevice() {
const topics = []
this.list.forEach((item) => {
topics.push(
`/$dg/thing/device/${item.product.objectId}/${item.devaddr}/properties/publish`
)
})
await this.$subscribe(topics)
// this.$dgiotBus.$off(this.$mqttInfo.topicKey)
this.$dgiotBus.$on('/$dg/thing', (Msg) => {
console.log('收到消息', Msg)
const parseString = JSON.parse(Msg.payloadString)
console.log('收到消息', parseString)
if (parseString) {
const topicsKeys = Object.keys(parseString)
console.log(topicsKeys)
topicsKeys.forEach((t) => {
this.list.forEach((i) => {
if (i.objectId == t) {
const mergeInfo = _.merge(i, parseString[t])
console.log(`更新设备${i.name}`, mergeInfo)
}
})
})
}
})
},
},
}
Expand Down

0 comments on commit 65c70a7

Please sign in to comment.