fix: 修复问题

This commit is contained in:
耗子
2026-06-01 18:25:52 +08:00
parent 9f3f0c8876
commit c2d01c4371
3 changed files with 66 additions and 4 deletions
+1
View File
@@ -80,6 +80,7 @@ func IsEOL() bool {
"ubuntu": {
"22.04": time.Date(2027, 4, 1, 0, 0, 0, 0, time.UTC),
"24.04": time.Date(2029, 5, 31, 0, 0, 0, 0, time.UTC),
"26.04": time.Date(2031, 4, 30, 0, 0, 0, 0, time.UTC),
},
}
+9 -3
View File
@@ -20,11 +20,16 @@ const createModel = ref({
remark: '',
})
const servers = ref<{ label: string; value: string }[]>([])
const servers = ref<{ label: string; value: string; type: string }[]>([])
// 仅这些数据库类型支持用户管理
const userSupportedTypes = ['mysql', 'postgresql', 'clickhouse']
// 当前选中服务器的类型,用于决定是否显示 Host 字段(仅 MySQL 需要)
const selectedServerType = computed(
() => servers.value.find((s) => s.value === createModel.value.server_id)?.type,
)
const hostTypeOptions = [
{ label: $gettext('Local (localhost)'), value: 'localhost' },
{ label: $gettext('All (%)'), value: '%' },
@@ -69,6 +74,7 @@ watch(
servers.value.push({
label: server.name,
value: server.id,
type: server.type,
})
}
})
@@ -125,7 +131,7 @@ watch(
</n-button>
</n-input-group>
</n-form-item>
<n-form-item v-if="props.type === 'mysql'" path="host-select" :label="$gettext('Host')">
<n-form-item v-if="selectedServerType === 'mysql'" path="host-select" :label="$gettext('Host')">
<n-select
v-model:value="hostType"
@keydown.enter.prevent
@@ -134,7 +140,7 @@ watch(
/>
</n-form-item>
<n-form-item
v-if="hostType === 'specific' && props.type === 'mysql'"
v-if="hostType === 'specific' && selectedServerType === 'mysql'"
path="host"
:label="$gettext('Specific Host')"
>
+56 -1
View File
@@ -40,6 +40,11 @@ const ttlModalShow = ref(false)
const ttlKey = ref('')
const ttlValue = ref(0)
// Rename 弹窗
const renameModalShow = ref(false)
const renameOldKey = ref('')
const renameNewKey = ref('')
// 类型对应颜色
const typeColorMap: Record<string, 'info' | 'success' | 'warning' | 'default' | 'error'> = {
string: 'info',
@@ -118,7 +123,7 @@ const columns: any = [
{
title: $gettext('Actions'),
key: 'actions',
width: 300,
width: 380,
hideInExcel: true,
render(row: any) {
return h(NFlex, { size: 'small', align: 'center' }, () => [
@@ -148,6 +153,20 @@ const columns: any = [
},
{ default: () => 'TTL' },
),
h(
NButton,
{
size: 'small',
type: 'primary',
ghost: true,
onClick: () => {
renameOldKey.value = row.key
renameNewKey.value = row.key
renameModalShow.value = true
},
},
{ default: () => $gettext('Rename') },
),
h(
NButton,
{
@@ -204,6 +223,22 @@ const handleSetTTL = () => {
})
}
const handleRename = () => {
if (!selectedServer.value) return
useRequest(
database.redisKeyRename(
selectedServer.value,
selectedDB.value,
renameOldKey.value,
renameNewKey.value,
),
).onSuccess(() => {
renameModalShow.value = false
refresh()
window.$message.success($gettext('Renamed successfully'))
})
}
const openCreate = () => {
keyModalMode.value = 'create'
keyModalKeyName.value = ''
@@ -323,4 +358,24 @@ onUnmounted(() => {
{{ $gettext('Submit') }}
</n-button>
</n-modal>
<!-- Rename 弹窗 -->
<n-modal
v-model:show="renameModalShow"
preset="card"
:title="$gettext('Rename Key')"
class="w-100"
:bordered="false"
>
<n-form>
<n-form-item :label="$gettext('Old Key')">
<n-input :value="renameOldKey" disabled />
</n-form-item>
<n-form-item :label="$gettext('New Key')">
<n-input v-model:value="renameNewKey" :placeholder="$gettext('Enter new key name')" />
</n-form-item>
</n-form>
<n-button type="info" block @click="handleRename">
{{ $gettext('Submit') }}
</n-button>
</n-modal>
</template>