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。

1.3 KB
Raw Blame
<script setup>
import { onBeforeUnmount, ref, watch } from "vue";

const props = defineProps({
  contributionId: String,
  loadIcon: { type: Function, required: true },
  connected: { type: Boolean, default: undefined },
});
const source = ref("");
let generation = 0;
watch(
  () => [props.contributionId, props.loadIcon],
  async ([contributionId, loadIcon]) => {
    const current = ++generation;
    source.value = "";
    try {
      const asset = await loadIcon(contributionId);
      if (current === generation && /^image\/(svg\+xml|png|jpeg|gif|webp)$/.test(asset?.contentType) && typeof asset.dataBase64 === "string") {
        source.value = `data:${asset.contentType};base64,${asset.dataBase64}`;
      }
    } catch {
      if (current === generation) source.value = "";
    }
  },
  { immediate: true },
);
onBeforeUnmount(() => generation++);
</script>

<template>
  <span class="relative inline-flex size-3.5 shrink-0 items-center justify-center" aria-hidden="true">
    <img v-if="source" :src="source" alt="" class="size-full object-contain" @error="source = ''" />
    <slot v-else />
    <span v-if="source && connected !== undefined" :data-connected="connected" class="absolute -bottom-0.5 -right-0.5 size-1.5 rounded-full ring-1 ring-base-200" :class="connected ? 'bg-success' : 'bg-base-content/40'" />
  </span>
</template>