Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

2.8 KB
Raw Blame
<script setup lang="ts">
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { Label } from "@/components/ui/label";
import { Button } from "@/components/ui/button";
import { RefreshCw } from "@lucide/vue";
import { generateTimeInRange } from "@/lib/dataGrid/generatorTimeRange";
import type { GeneratorParams } from "@/lib/dataGrid/dataGenerate";

const props = defineProps<{ params: GeneratorParams }>();

const { t } = useI18n();

const previewVal = computed(() => {
  void previewKey.value;
  return props.params.allDay ? generateTimeInRange() : generateTimeInRange(props.params.startTime, props.params.endTime);
});

const previewKey = ref(0);
function refresh() {
  previewKey.value++;
}
</script>

<template>
  <div class="space-y-3">
    <div class="rounded-md border bg-muted/10 p-3 space-y-2">
      <div class="flex items-center gap-2 text-xs">
        <input id="tm-all-day" type="checkbox" class="h-3.5 w-3.5 accent-primary" :checked="!!params.allDay" @change="params.allDay = !params.allDay" />
        <Label for="tm-all-day" class="text-muted-foreground">{{ t("dataGenerate.allDay") }}</Label>
      </div>
      <div v-if="!params.allDay" class="flex items-center gap-2 text-xs ml-5">
        <Label class="text-muted-foreground shrink-0">{{ t("dataGenerate.startTime") }}</Label>
        <input
          :value="params.startTime ?? ''"
          @change="
            (e: Event) => {
              (params as Record<string, unknown>).startTime = (e.target as HTMLInputElement).value;
            }
          "
          type="time"
          class="h-7 w-24 min-w-0 rounded-[6px] border bg-transparent px-2.5 py-1 text-xs outline-none transition-colors dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3"
        />
        <Label class="text-muted-foreground shrink-0">{{ t("dataGenerate.endTime") }}</Label>
        <input
          :value="params.endTime ?? ''"
          @change="
            (e: Event) => {
              (params as Record<string, unknown>).endTime = (e.target as HTMLInputElement).value;
            }
          "
          type="time"
          class="h-7 w-24 min-w-0 rounded-[6px] border bg-transparent px-2.5 py-1 text-xs outline-none transition-colors dark:bg-input/30 border-input focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3"
        />
      </div>
    </div>

    <div class="rounded-md border bg-muted/10 p-3">
      <div class="flex items-center gap-2 text-xs">
        <span class="text-muted-foreground shrink-0">{{ t("dataGenerate.preview") }}</span>
        <span :key="previewKey" class="font-mono text-sm">{{ previewVal }}</span>
        <Button variant="ghost" size="icon" class="h-5 w-5 ml-auto" @click="refresh">
          <RefreshCw class="h-3 w-3" />
        </Button>
      </div>
    </div>
  </div>
</template>