Skip to content

Commit 46f303c

Browse files
author
fuyoo
committed
complete string type look,delete,modify.
1 parent 43ddaaf commit 46f303c

File tree

17 files changed

+298
-74
lines changed

17 files changed

+298
-74
lines changed

components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ declare module 'vue' {
1111
CoHostTab: typeof import('./src/components/CoHostTab.vue')['default']
1212
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
1313
NButton: typeof import('naive-ui')['NButton']
14+
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
1415
NDataTable: typeof import('naive-ui')['NDataTable']
1516
NDropdown: typeof import('naive-ui')['NDropdown']
17+
NEmpty: typeof import('naive-ui')['NEmpty']
1618
NInput: typeof import('naive-ui')['NInput']
1719
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
20+
NModalProvider: typeof import('naive-ui')['NModalProvider']
1821
NPopselect: typeof import('naive-ui')['NPopselect']
1922
NScrollbar: typeof import('naive-ui')['NScrollbar']
23+
NSpace: typeof import('naive-ui')['NSpace']
2024
NSplit: typeof import('naive-ui')['NSplit']
2125
NTabPane: typeof import('naive-ui')['NTabPane']
2226
NTabs: typeof import('naive-ui')['NTabs']

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,11 @@ export default [
3535
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
3636
},
3737
},
38+
{ parserOptions: {
39+
ecmaVersion: 2020,
40+
sourceType: 'module',
41+
ecmaFeatures: {
42+
jsx: true, // 确保开启 jsx 支持
43+
},
44+
}}
3845
]

src/App.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<script setup lang="ts">
22
import { RouterView } from 'vue-router'
3+
4+
import { useLocate } from '@/i18n'
5+
6+
const { locate } = useLocate()
37
</script>
48

59
<template>
6-
<n-message-provider>
7-
<RouterView />
8-
</n-message-provider>
10+
<n-config-provider :locale="locate">
11+
<n-message-provider>
12+
<RouterView />
13+
</n-message-provider>
14+
</n-config-provider>
915
</template>
1016

1117
<style scoped></style>

src/hooks/pager.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {reactive} from 'vue'
2+
3+
export const usePager = (obj?: { page?: number; pageSize?: number }) => {
4+
let cb = () => {}
5+
6+
const pager = reactive({
7+
page: 1,
8+
pageSize: 10,
9+
pageCount: 0,
10+
showSizePicker: true,
11+
pageSizes: [10, 20, 50, 100],
12+
onChange: (page: number) => {
13+
pager.page = page
14+
cb()
15+
},
16+
onUpdatePageSize: (pageSize: number) => {
17+
pager.pageSize = pageSize
18+
pager.page = 1
19+
cb()
20+
},
21+
...obj,
22+
})
23+
const onPageChanged = (func: () => void) => {
24+
cb = func
25+
}
26+
const calcIndex = (index: number) => {
27+
return (pager.page - 1) * pager.pageSize + index+ 1
28+
}
29+
return {
30+
pager,
31+
onPageChanged,
32+
calcIndex
33+
}
34+
}

src/i18n/en-US/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
['Github', 'github.com/fuyoo/bs-redis-desktop-client'],
1010
],
1111
settings: ['Settings', 'Language', 'Version'],
12-
actions: ['Ok', 'Cancel', 'Delete', 'Modify', 'Add'],
12+
actions: ['Ok', 'Cancel', 'Delete', 'Edit', 'Add', 'Insert'],
1313
home: {
1414
form: {
1515
lable: ['Name', 'Host', 'Port', 'Database', 'Username', 'Password', 'Cluster'],
@@ -30,4 +30,6 @@ export default {
3030
hostInfo: ['Memory', 'Server', 'Stats', 'Details', 'Key Anylaysis'],
3131
normal: ['Database', 'Please select a key.'],
3232
timeFormat: ['d', 'h', 'm', 's', 'mill','never'],
33+
table: ['Data','Operate'],
34+
tips: ['Current data type unsupported yet.']
3335
}

src/i18n/index.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { createI18n } from 'vue-i18n'
1+
import { createI18n,useI18n } from 'vue-i18n'
22

33
import messages from './lang'
44
import { Lang, type QuasarLanguage } from 'quasar'
5-
import type { App } from 'vue'
5+
import { type App, computed } from 'vue'
6+
import { enUS, ruRU, zhCN } from 'naive-ui'
7+
68
export type MessageLanguages = keyof typeof messages
79
// Type-define 'en-US' as the master schema for the resource
810
export type MessageSchema = (typeof messages)['en-US']
@@ -21,13 +23,13 @@ declare module 'vue-i18n' {
2123
}
2224
/* eslint-enable @typescript-eslint/no-empty-object-type */
2325

24-
export const useI18n = (app: App) => {
26+
export const injectI18n = (app: App) => {
2527
// import lang pack
2628
const languages = import.meta.glob('../../node_modules/quasar/lang/(zh-CN|en-US).js', {
2729
eager: true,
2830
import: 'default',
2931
})
30-
// obtain currently luanguage
32+
// obtain currently language
3133
const local = localStorage.getItem('lang') ?? (Lang.getLocale() || 'zh-CN')
3234
// set currently language
3335
Object.keys(languages).forEach((k) => {
@@ -45,3 +47,18 @@ export const useI18n = (app: App) => {
4547
// Set i18n instance on app
4648
app.use(i18n)
4749
}
50+
51+
export const useLocate = () => {
52+
const $i18n = useI18n()
53+
const locate = computed(() => {
54+
switch ($i18n.locale.value) {
55+
case 'zh-CN':
56+
return zhCN
57+
case 'ruRU':
58+
return ruRU
59+
default:
60+
return enUS
61+
}
62+
})
63+
return { locate }
64+
}

src/i18n/zh-CN/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
['Github', 'github.com/fuyoo/bs-redis-desktop-client'],
77
],
88
settings: ['设置', '语言', '版本'],
9-
actions: ['确定', '取消', '删除', '修改', '添加'],
9+
actions: ['确定', '取消', '删除', '修改', '添加','插入'],
1010
home: {
1111
form: {
1212
lable: ['名称', '地址', '端口', '数据库', '用户名', '密码', '是否集群'],
@@ -26,6 +26,8 @@ export default {
2626
tabName: ['状态', '数据'],
2727
},
2828
hostInfo: ['内存', '服务端', '状态', '详情', 'Key情况'],
29-
normal: ['数据库','请选择一个键'],
30-
timeFormat:['天','时','分','秒','毫秒','不过期']
29+
normal: ['数据库', '请选择一个键'],
30+
timeFormat: ['天', '时', '分', '秒', '毫秒', '永不过期'],
31+
table: ['数据', '操作'],
32+
tips: ['该数据类型尚不支持']
3133
}

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import '@quasar/extras/material-icons/material-icons.css'
88
import 'quasar/src/css/index.sass'
99
import App from './App.vue'
1010
import router from './router'
11-
import { useI18n } from './i18n'
11+
import { injectI18n } from './i18n'
1212
import 'virtual:uno.css'
1313
const app = createApp(App)
1414
app.use(Quasar, {
@@ -17,7 +17,7 @@ app.use(Quasar, {
1717
Notify,
1818
}, // import Quasar plugins and add here
1919
})
20-
app.use(useI18n)
20+
app.use(injectI18n)
2121
app.use(createPinia())
2222
app.use(router)
2323

src/pages/host/components/CoInfoHeader/index.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useReqStore } from '@/stores/req.ts'
33
import { onBeforeUnmount, reactive } from 'vue'
44
import { useI18n } from 'vue-i18n'
55
import { useRoute } from 'vue-router'
6+
import {dataToHuman} from '@/tools'
7+
68
const route = useRoute()
79
const { t } = useI18n()
810
const prop = defineProps<{ type?: string }>()
@@ -64,18 +66,22 @@ const formatMilliseconds = (v: string): string => {
6466
onBeforeUnmount(() => {
6567
clearInterval(timer)
6668
})
69+
6770
</script>
6871

6972
<template>
70-
<div class="b-b b-b-dashed b-b-#eee p-4 gap-2 flex">
73+
<div class="b-b b-b-dashed b-b-#eee p-4 flex justify-between items-center">
74+
<div class=" gap-2 flex">
7175
<b>{{ trans(route.params.key as string) }}</b>
7276
<q-badge><i class="i-iconamoon:type-bold mr-1"></i> {{ type?.toUpperCase() }}</q-badge>
73-
<q-badge><i class="i-material-symbols:memory-alt mr-1"></i> {{ baseInfo.memory }}bytes</q-badge>
77+
<q-badge><i class="i-material-symbols:memory-alt mr-1"></i> {{ dataToHuman(baseInfo.memory) }}</q-badge>
7478
<q-badge>
7579
<i class="i-material-symbols:nest-clock-farsight-analog-outline"></i>TTL
7680
{{ formatMilliseconds(baseInfo.pttl) }}
7781
</q-badge>
7882
</div>
83+
<slot></slot>
84+
</div>
7985
</template>
8086

8187
<style scoped lang="scss"></style>

src/pages/host/components/CoKeys/index.vue

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { useReqStore } from '@/stores/req.ts'
3-
import { reactive, ref, h, } from 'vue'
3+
import { reactive, ref, h } from 'vue'
44
import { useRoute, useRouter } from 'vue-router'
55
import type { DropdownOption } from 'naive-ui'
66
import { Folder, FolderOpenOutline, Trash } from '@vicons/ionicons5'
@@ -105,7 +105,7 @@ const loadMoreFn = () => {
105105
}
106106
}
107107
108-
let focusNodeData:Tree | null
108+
let focusNodeData: Tree | null
109109
const showDropdownRef = ref(false)
110110
const menuOptions = ref<DropdownOption[]>([
111111
{
@@ -116,6 +116,7 @@ const menuOptions = ref<DropdownOption[]>([
116116
])
117117
const x = ref(0)
118118
const y = ref(0)
119+
const supportDataType = ['string', 'list', 'set', 'zset', 'hash']
119120
const nodeProps = ({ option }: { option: Tree }) => {
120121
return {
121122
async onClick() {
@@ -124,6 +125,16 @@ const nodeProps = ({ option }: { option: Tree }) => {
124125
path: '/cmd',
125126
data: ['type', option.value],
126127
})
128+
if (!supportDataType.includes(t.data)) {
129+
await router.replace({
130+
path: `/tab/${route.params.id}/main/database/unsupported/${btoa(option.value!)}`,
131+
replace: true,
132+
query: {
133+
...route.query,
134+
},
135+
})
136+
return
137+
}
127138
await router.replace({
128139
path: `/tab/${route.params.id}/main/database/${t.data}/${btoa(option.value!)}`,
129140
replace: true,
@@ -146,8 +157,7 @@ const nodeProps = ({ option }: { option: Tree }) => {
146157
const handleSelect = async (act: string) => {
147158
showDropdownRef.value = false
148159
const data = focusNodeData
149-
if (act === "delete") {
150-
160+
if (act === 'delete') {
151161
if (data?.type === 'key') {
152162
const { code } = await reqStore.reqWithHost<string>({
153163
path: '/cmd',
@@ -227,7 +237,7 @@ const handleSelect = async (act: string) => {
227237
:x="x"
228238
:y="y"
229239
@select="handleSelect"
230-
@clickoutside="()=>showDropdownRef = false"
240+
@clickoutside="() => (showDropdownRef = false)"
231241
/>
232242
</template>
233243

0 commit comments

Comments
 (0)