Skip to content

Commit 1205396

Browse files
author
fuyoo
committed
can add new 'list,set,hash' types data
1 parent 8ad87a9 commit 1205396

File tree

5 files changed

+219
-5
lines changed

5 files changed

+219
-5
lines changed

src/i18n/zh-CN/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default {
2323
},
2424
},
2525
keyForm: {
26-
label: ['键名','数据','过期时间'],
27-
msg: ["键是必须的","数据是必须的"]
26+
label: ['键名','数据','过期时间','字段'],
27+
msg: ["键是必须的","数据是必须的",'字段是必须的']
2828
},
2929
tabs: {
3030
tabName: ['状态', '数据'],

src/pages/host/components/CoKeys/actions.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { DialogApiInjection } from 'naive-ui/es/dialog/src/DialogProvider'
22
import NewStringForm from '@/pages/host/components/CoKeys/compoents/NewStringForm.vue'
3+
import NewSetForm from '@/pages/host/components/CoKeys/compoents/NewSetForm.vue'
4+
import NewListForm from '@/pages/host/components/CoKeys/compoents/NewListForm.vue'
5+
import NewHashForm from '@/pages/host/components/CoKeys/compoents/NewHashForm.vue'
36

47
export const options = [
58
{
@@ -42,7 +45,7 @@ export const addListKey = (dialog: DialogApiInjection, title?: string) => {
4245
dialog.create({
4346
title: title ?? 'New Key',
4447
content: () => {
45-
return <div>good job</div>
48+
return <NewListForm></NewListForm>
4649
},
4750
draggable: true,
4851
})
@@ -52,7 +55,7 @@ export const addHashKey = (dialog: DialogApiInjection, title?: string) => {
5255
dialog.create({
5356
title: title ?? 'New Key',
5457
content: () => {
55-
return <div>good job</div>
58+
return <NewHashForm></NewHashForm>
5659
},
5760
draggable: true,
5861
})
@@ -62,7 +65,7 @@ export const addSetKey = (dialog: DialogApiInjection, title?: string) => {
6265
dialog.create({
6366
title: title ?? 'New Key',
6467
content: () => {
65-
return <div>good job</div>
68+
return <NewSetForm></NewSetForm>
6669
},
6770
draggable: true,
6871
})
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<script setup lang="ts">
2+
import {useI18n} from "vue-i18n";
3+
import {type FormInst} from "naive-ui"
4+
import {useReqStore} from "@/stores/req.ts";
5+
6+
const {t} = useI18n()
7+
const form = reactive({
8+
key: "",
9+
expires: 0,
10+
field: "",
11+
data: ""
12+
})
13+
const formRef = shallowRef<FormInst | null>()
14+
const rules = {
15+
key: {
16+
required: true,
17+
renderMessage: () => t("keyForm.msg.0")
18+
},
19+
data: {
20+
required: true,
21+
renderMessage: () => t("keyForm.msg.1")
22+
},
23+
field: {
24+
required: true,
25+
renderMessage: () => t("keyForm.msg.2")
26+
}
27+
}
28+
const dialog =useDialog()
29+
const message = useMessage()
30+
const req = useReqStore()
31+
const submitFn = async () => {
32+
await formRef.value?.validate()
33+
await req.reqWithHost<boolean>({
34+
path:"/cmd",
35+
data: ['hset',form.key,form.field,form.data ]
36+
})
37+
if (form.expires > 0) {
38+
await req.reqWithHost<boolean>({
39+
path:"/cmd",
40+
data: ['expire',form.key,form.expires.toString()]
41+
})
42+
}
43+
44+
dialog.destroyAll()
45+
message.success("operate success")
46+
}
47+
</script>
48+
49+
<template>
50+
<n-form class="pt-5" ref="formRef" label-placement="left" label-width="100px" size="small" :model="form" :rules="rules">
51+
<n-form-item :label="$t('keyForm.label.0')" path="key" required>
52+
<n-input clearable v-model:value="form.key"></n-input>
53+
</n-form-item>
54+
<n-form-item :label="$t('keyForm.label.3')" path="field" required>
55+
<n-input clearable type="textarea" v-model:value="form.field"></n-input>
56+
</n-form-item>
57+
<n-form-item :label="$t('keyForm.label.1')" path="data" required>
58+
<n-input clearable type="textarea" v-model:value="form.data"></n-input>
59+
</n-form-item>
60+
<n-form-item :label="$t('keyForm.label.2')">
61+
<n-input-number class="w-full" v-model:value="form.expires">
62+
<template #suffix>
63+
s
64+
</template>
65+
</n-input-number>
66+
</n-form-item>
67+
<n-form-item label=" ">
68+
<n-button type="primary" @click="submitFn">{{ $t('actions.0') }}</n-button>
69+
</n-form-item>
70+
</n-form>
71+
</template>
72+
73+
<style scoped lang="scss">
74+
75+
</style>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<script setup lang="ts">
2+
import {useI18n} from "vue-i18n";
3+
import {type FormInst} from "naive-ui"
4+
import {useReqStore} from "@/stores/req.ts";
5+
6+
const {t} = useI18n()
7+
const form = reactive({
8+
key: "",
9+
expires: 0,
10+
data: ""
11+
})
12+
const formRef = shallowRef<FormInst | null>()
13+
const rules = {
14+
key: {
15+
required: true,
16+
renderMessage: () => t("keyForm.msg.0")
17+
},
18+
data: {
19+
required: true,
20+
renderMessage: () => t("keyForm.msg.1")
21+
}
22+
}
23+
const dialog =useDialog()
24+
const message = useMessage()
25+
const req = useReqStore()
26+
const submitFn = async () => {
27+
await formRef.value?.validate()
28+
await req.reqWithHost<boolean>({
29+
path:"/cmd",
30+
data: ['rpush',form.key,form.data ]
31+
})
32+
if (form.expires > 0) {
33+
await req.reqWithHost<boolean>({
34+
path:"/cmd",
35+
data: ['expire',form.key,form.expires.toString()]
36+
})
37+
}
38+
39+
dialog.destroyAll()
40+
message.success("operate success")
41+
}
42+
</script>
43+
44+
<template>
45+
<n-form class="pt-5" ref="formRef" label-placement="left" label-width="100px" size="small" :model="form" :rules="rules">
46+
<n-form-item :label="$t('keyForm.label.0')" path="key" required>
47+
<n-input clearable v-model:value="form.key"></n-input>
48+
</n-form-item>
49+
<n-form-item :label="$t('keyForm.label.1')" path="data" required>
50+
<n-input clearable type="textarea" v-model:value="form.data"></n-input>
51+
</n-form-item>
52+
53+
<n-form-item :label="$t('keyForm.label.2')">
54+
<n-input-number class="w-full" v-model:value="form.expires">
55+
<template #suffix>
56+
s
57+
</template>
58+
</n-input-number>
59+
</n-form-item>
60+
<n-form-item label=" ">
61+
<n-button type="primary" @click="submitFn">{{ $t('actions.0') }}</n-button>
62+
</n-form-item>
63+
</n-form>
64+
</template>
65+
66+
<style scoped lang="scss">
67+
68+
</style>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<script setup lang="ts">
2+
import {useI18n} from "vue-i18n";
3+
import {type FormInst} from "naive-ui"
4+
import {useReqStore} from "@/stores/req.ts";
5+
6+
const {t} = useI18n()
7+
const form = reactive({
8+
key: "",
9+
expires: 0,
10+
data: ""
11+
})
12+
const formRef = shallowRef<FormInst | null>()
13+
const rules = {
14+
key: {
15+
required: true,
16+
renderMessage: () => t("keyForm.msg.0")
17+
},
18+
data: {
19+
required: true,
20+
renderMessage: () => t("keyForm.msg.1")
21+
}
22+
}
23+
const dialog =useDialog()
24+
const message = useMessage()
25+
const req = useReqStore()
26+
const submitFn = async () => {
27+
await formRef.value?.validate()
28+
await req.reqWithHost<boolean>({
29+
path:"/cmd",
30+
data: ['sadd',form.key,form.data ]
31+
})
32+
if (form.expires > 0) {
33+
await req.reqWithHost<boolean>({
34+
path:"/cmd",
35+
data: ['expire',form.key,form.expires.toString()]
36+
})
37+
}
38+
39+
dialog.destroyAll()
40+
message.success("operate success")
41+
}
42+
</script>
43+
44+
<template>
45+
<n-form class="pt-5" ref="formRef" label-placement="left" label-width="100px" size="small" :model="form" :rules="rules">
46+
<n-form-item :label="$t('keyForm.label.0')" path="key" required>
47+
<n-input clearable v-model:value="form.key"></n-input>
48+
</n-form-item>
49+
<n-form-item :label="$t('keyForm.label.1')" path="data" required>
50+
<n-input clearable type="textarea" v-model:value="form.data"></n-input>
51+
</n-form-item>
52+
53+
<n-form-item :label="$t('keyForm.label.2')">
54+
<n-input-number class="w-full" v-model:value="form.expires">
55+
<template #suffix>
56+
s
57+
</template>
58+
</n-input-number>
59+
</n-form-item>
60+
<n-form-item label=" ">
61+
<n-button type="primary" @click="submitFn">{{ $t('actions.0') }}</n-button>
62+
</n-form-item>
63+
</n-form>
64+
</template>
65+
66+
<style scoped lang="scss">
67+
68+
</style>

0 commit comments

Comments
 (0)