Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Dynamic image :src couldn't work properly with vite and use static src instead

天舟b58fe219569b
diff --git a/frontend/src/components/ProjectWebhookCard.vue b/frontend/src/components/ProjectWebhookCard.vue
index 328c48052f..040ca9e2fa 100644
--- a/frontend/src/components/ProjectWebhookCard.vue
+++ b/frontend/src/components/ProjectWebhookCard.vue
@@ -4,7 +4,30 @@
>
<div class="flex py-2 px-4 justify-between">
<div class="flex flex-row space-x-2 items-center">
- <img class="h-5 w-5" :src="`/src/assets/${logo}`" />
+ <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
+ https://github.com/vitejs/vite/issues/1265 -->
+ <template v-if="projectWebhook.type == 'bb.plugin.webhook.slack'">
+ <img class="h-5 w-5" src="../assets/slack-logo.png" />
+ </template>
+ <template
+ v-else-if="projectWebhook.type == 'bb.plugin.webhook.discord'"
+ >
+ <img class="h-5 w-5" src="../assets/discord-logo.svg" />
+ </template>
+ <template v-else-if="projectWebhook.type == 'bb.plugin.webhook.teams'">
+ <img class="h-5 w-5" src="../assets/teams-logo.svg" />
+ </template>
+ <template
+ v-else-if="projectWebhook.type == 'bb.plugin.webhook.dingtalk'"
+ >
+ <img class="h-5 w-5" src="../assets/dingtalk-logo.png" />
+ </template>
+ <template v-else-if="projectWebhook.type == 'bb.plugin.webhook.feishu'">
+ <img class="h-5 w-5" src="../assets/feishu-logo.png" />
+ </template>
+ <template v-else-if="projectWebhook.type == 'bb.plugin.webhook.wecom'">
+ <img class="h-5 w-5" src="../assets/wecom-logo.png" />
+ </template>
<h3 class="text-lg leading-6 font-medium text-main">
{{ projectWebhook.name }}
</h3>
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index 41499e1e0c..733ffea742 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -20,11 +20,45 @@
@click.capture="state.webhook.type = item.type"
>
<div class="flex flex-col items-center">
- <img
- class="h-10 w-10 rounded-full"
- :src="`/src/assets/${item.logo}`"
- alt=""
- />
+ <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
+ https://github.com/vitejs/vite/issues/1265 -->
+ <template v-if="item.type == 'bb.plugin.webhook.slack'">
+ <img
+ class="h-10 w-10 rounded-full"
+ src="../assets/slack-logo.png"
+ alt=""
+ />
+ </template>
+ <template v-else-if="item.type == 'bb.plugin.webhook.discord'">
+ <img
+ class="h-10 w-10 rounded-full"
+ src="../assets/discord-logo.svg"
+ />
+ </template>
+ <template v-else-if="item.type == 'bb.plugin.webhook.teams'">
+ <img
+ class="h-10 w-10 rounded-full"
+ src="../assets/teams-logo.svg"
+ />
+ </template>
+ <template v-else-if="item.type == 'bb.plugin.webhook.dingtalk'">
+ <img
+ class="h-10 w-10 rounded-full"
+ src="../assets/dingtalk-logo.png"
+ />
+ </template>
+ <template v-else-if="item.type == 'bb.plugin.webhook.feishu'">
+ <img
+ class="h-10 w-10 rounded-full"
+ src="../assets/feishu-logo.png"
+ />
+ </template>
+ <template v-else-if="item.type == 'bb.plugin.webhook.wecom'">
+ <img
+ class="h-10 w-10 rounded-full"
+ src="../assets/wecom-logo.png"
+ />
+ </template>
<p class="mt-1 text-center textlabel">
{{ item.name }}
</p>
diff --git a/frontend/src/types/projectWebhook.ts b/frontend/src/types/projectWebhook.ts
index 0cb57a5c11..98ef6a053b 100644
--- a/frontend/src/types/projectWebhook.ts
+++ b/frontend/src/types/projectWebhook.ts
@@ -5,7 +5,6 @@ import { Principal } from "./principal";
type ProjectWebhookTypeItem = {
type: string;
name: string;
- logo: string;
urlPrefix: string;
};
@@ -13,37 +12,31 @@ export const PROJECT_HOOK_TYPE_ITEM_LIST: ProjectWebhookTypeItem[] = [
{
type: "bb.plugin.webhook.slack",
name: "Slack",
- logo: "slack-logo.png",
urlPrefix: "https://hooks.slack.com/",
},
{
type: "bb.plugin.webhook.discord",
name: "Discord",
- logo: "discord-logo.svg",
urlPrefix: "https://discord.com/api/webhooks",
},
{
type: "bb.plugin.webhook.teams",
name: "Teams",
- logo: "teams-logo.svg",
urlPrefix: "",
},
{
type: "bb.plugin.webhook.dingtalk",
name: "DingTalk",
- logo: "dingtalk-logo.png",
urlPrefix: "https://oapi.dingtalk.com",
},
{
type: "bb.plugin.webhook.feishu",
name: "Feishu",
- logo: "feishu-logo.png",
urlPrefix: "https://open.feishu.cn",
},
{
type: "bb.plugin.webhook.wecom",
name: "WeCom",
- logo: "wecom-logo.png",
urlPrefix: "https://qyapi.weixin.qq.com",
},
];