Skip to content

Commit 5c18f93

Browse files
author
sheepzh
committed
Not allow to delay by default (#198)
1 parent 4f22c97 commit 5c18f93

File tree

2 files changed

+51
-54
lines changed

2 files changed

+51
-54
lines changed

src/app/components/limit/index.ts

Lines changed: 50 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,64 +17,61 @@ import { t } from "@app/locale"
1717
import { ElMessage } from "element-plus"
1818
import { handleWindowVisibleChange } from "@util/window"
1919

20-
const _default = defineComponent({
21-
name: "Limit",
22-
setup() {
23-
const url: Ref<string> = ref('')
24-
const onlyEnabled: Ref<boolean> = ref(false)
25-
const data: Ref<timer.limit.Item[]> = ref([])
26-
// Init and query
27-
const queryData = async () => {
28-
const list = await limitService.select({ filterDisabled: onlyEnabled.value, url: url.value || '' })
29-
data.value = list
30-
}
31-
queryData()
32-
// Query data if the window become visible
33-
handleWindowVisibleChange(queryData)
34-
// Init with url parameter
35-
const urlParam = useRoute().query['url'] as string
36-
useRouter().replace({ query: {} })
37-
urlParam && (url.value = decodeURIComponent(urlParam))
20+
const _default = defineComponent(() => {
21+
const url: Ref<string> = ref('')
22+
const onlyEnabled: Ref<boolean> = ref(false)
23+
const data: Ref<timer.limit.Item[]> = ref([])
24+
// Init and query
25+
const queryData = async () => {
26+
const list = await limitService.select({ filterDisabled: onlyEnabled.value, url: url.value || '' })
27+
data.value = list
28+
}
29+
queryData()
30+
// Query data if the window become visible
31+
handleWindowVisibleChange(queryData)
32+
// Init with url parameter
33+
const urlParam = useRoute().query['url'] as string
34+
useRouter().replace({ query: {} })
35+
urlParam && (url.value = decodeURIComponent(urlParam))
3836

39-
const modify: Ref = ref()
40-
const test: Ref = ref()
37+
const modify: Ref = ref()
38+
const test: Ref = ref()
4139

42-
return () => h(ContentContainer, {}, {
43-
filter: () => h(LimitFilter, {
44-
url: url.value,
45-
onlyEnabled: onlyEnabled.value,
46-
onChange(option: LimitFilterOption) {
47-
url.value = option.url
48-
onlyEnabled.value = option.onlyEnabled
40+
return () => h(ContentContainer, {}, {
41+
filter: () => h(LimitFilter, {
42+
url: url.value,
43+
onlyEnabled: onlyEnabled.value,
44+
onChange(option: LimitFilterOption) {
45+
url.value = option.url
46+
onlyEnabled.value = option.onlyEnabled
47+
queryData()
48+
},
49+
onCreate: () => modify.value?.create?.(),
50+
onTest: () => test.value?.show?.(),
51+
}),
52+
content: () => [
53+
h(LimitTable, {
54+
data: data.value,
55+
onDelayChange: (row: timer.limit.Item) => limitService.updateDelay(row),
56+
onEnabledChange: (row: timer.limit.Item) => limitService.updateEnabled(row),
57+
async onDelete(row: timer.limit.Item) {
58+
await limitService.remove(row)
59+
ElMessage.success(t(msg => msg.limit.message.deleted))
4960
queryData()
5061
},
51-
onCreate: () => modify.value?.create?.(),
52-
onTest: () => test.value?.show?.(),
62+
async onModify(row: timer.limit.Item) {
63+
modify.value?.modify?.(row)
64+
}
5365
}),
54-
content: () => [
55-
h(LimitTable, {
56-
data: data.value,
57-
onDelayChange: (row: timer.limit.Item) => limitService.updateDelay(row),
58-
onEnabledChange: (row: timer.limit.Item) => limitService.updateEnabled(row),
59-
async onDelete(row: timer.limit.Item) {
60-
await limitService.remove(row)
61-
ElMessage.success(t(msg => msg.limit.message.deleted))
62-
queryData()
63-
},
64-
async onModify(row: timer.limit.Item) {
65-
modify.value?.modify?.(row)
66-
}
67-
}),
68-
h(LimitModify, {
69-
ref: modify,
70-
onSave: queryData
71-
}),
72-
h(LimitTest, {
73-
ref: test
74-
}),
75-
]
76-
})
77-
}
66+
h(LimitModify, {
67+
ref: modify,
68+
onSave: queryData
69+
}),
70+
h(LimitTest, {
71+
ref: test
72+
}),
73+
]
74+
})
7875
})
7976

8077
export default _default

src/app/components/limit/modify/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const _default = defineComponent({
6161
ElMessage.warning(noTimeError)
6262
return
6363
}
64-
const toSave: timer.limit.Rule = { cond: condition, time: timeLimit, enabled: true, allowDelay: true }
64+
const toSave: timer.limit.Rule = { cond: condition, time: timeLimit, enabled: true, allowDelay: false }
6565
if (mode.value === 'modify' && modifyingItem) {
6666
toSave.enabled = modifyingItem.enabled
6767
toSave.allowDelay = modifyingItem.allowDelay

0 commit comments

Comments
 (0)