Skip to content

Commit

Permalink
refactor(useSubscription.ts): only check device name
Browse files Browse the repository at this point in the history
  • Loading branch information
oucb authored and ysfscream committed Sep 15, 2023
1 parent 6c70a5d commit 7479124
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
15 changes: 3 additions & 12 deletions src/composables/config/useSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ type AddSubscriptionProps = Readonly<{

export const useSubscriptionGroup = () => {
const { t } = useI18n()
const { isGewuPugin } = useDriverInfo()
const checkDriverGroups = async (rule: unknown, value: string, callback: any) => {
const keys = Object.keys(value)
const values = Object.values(value)
Expand All @@ -163,18 +164,8 @@ export const useSubscriptionGroup = () => {
const nodeGroups = Object.entries(value)
nodeGroups.forEach(([key, groups]) => {
const groupLen = groups.length
if (groupLen) {
if (!re.test(key)) {
callback(new Error(t('config.subscribeSouthDriverDeviceIllegal')))
} else {
Object.values(groups).forEach((item) => {
// 数据更新
console.log(re.test(item))
if (!re.test(item)) {
callback(new Error(t('config.subscribeSouthDriverGroupIllegal')))
}
})
}
if (groupLen && isGewuPugin.value && !re.test(key)) {
callback(new Error(t('config.subscribeSouthDriverDeviceIllegal')))
}
})
if (!keys.length || isAllEmpty) {
Expand Down
4 changes: 0 additions & 4 deletions src/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,4 @@ export default {
zh: '注册的设备,名称只能包含数字和字母',
en: 'Subscribed devices, names can only contain numbers and letters',
},
subscribeSouthDriverGroupIllegal: {
zh: '设备下的分组,名称只能包含数字和字母',
en: 'The group name under the device can only contain numbers and letters',
},
}

0 comments on commit 7479124

Please sign in to comment.