Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add custom theme provider (#8604)
boojack31fb221f7444
diff --git a/frontend/src/App.vue b/frontend/src/App.vueindex 14f8467363..6dda862da2 100644--- a/frontend/src/App.vue+++ b/frontend/src/App.vue@@ -1,10 +1,5 @@<template>- <NConfigProvider- :key="key"- :locale="generalLang"- :date-locale="dateLang"- :theme-overrides="themeOverrides"- >+ <CustomThemeProvider><Watermark /><NDialogProvider>@@ -22,11 +17,11 @@</KBarWrapper></BBModalStack></NDialogProvider>- </NConfigProvider>+ </CustomThemeProvider></template><script lang="ts" setup>-import { NConfigProvider, NDialogProvider } from "naive-ui";+import { NDialogProvider } from "naive-ui";import { ServerError } from "nice-grpc-common";import { ClientError, Status } from "nice-grpc-web";import { reactive, watchEffect, onErrorCaptured, watch } from "vue";@@ -34,8 +29,7 @@ import { useRoute, useRouter } from "vue-router";import HelpDrawer from "@/components/HelpDrawer";import Watermark from "@/components/misc/Watermark.vue";import { RouteMapList } from "@/types";-import { themeOverrides, dateLang, generalLang } from "../naive-ui.config";-import { provideAppRootContext } from "./AppRootContext";+import CustomThemeProvider from "./CustomThemeProvider.vue";import BBModalStack from "./bbkit/BBModalStack.vue";import { BBNotificationItem } from "./bbkit/types";import KBarWrapper from "./components/KBar/KBarWrapper.vue";@@ -64,7 +58,6 @@ interface LocalState {RouteMapList: RouteMapList | null;}-const { key } = provideAppRootContext();const authStore = useAuthStore();const notificationStore = useNotificationStore();const route = useRoute();diff --git a/frontend/src/CustomThemeProvider.vue b/frontend/src/CustomThemeProvider.vuenew file mode 100644index 0000000000..aecb1e29a3--- /dev/null+++ b/frontend/src/CustomThemeProvider.vue@@ -0,0 +1,37 @@+<template>+ <NConfigProvider+ v-if="initialized"+ :key="key"+ :locale="generalLang"+ :date-locale="dateLang"+ :theme-overrides="themeOverrides"+ >+ <slot></slot>+ </NConfigProvider>+</template>++<script lang="ts" setup>+import { useLocalStorage } from "@vueuse/core";+import { NConfigProvider } from "naive-ui";+import { onMounted, ref } from "vue";+import { themeOverrides, dateLang, generalLang } from "../naive-ui.config";+import { provideAppRootContext } from "./AppRootContext";+import { applyCustomTheme } from "./utils/customTheme";++const { key } = provideAppRootContext();+const initialized = ref(false);++onMounted(() => {+ const searchParams = new URLSearchParams(window.location.search);+ let customTheme = searchParams.get("customTheme") || "";+ const cachedCustomTheme = useLocalStorage<string>("bb.custom-theme", "");+ if (!customTheme && cachedCustomTheme.value) {+ customTheme = cachedCustomTheme.value;+ }+ if (customTheme) {+ cachedCustomTheme.value = customTheme;+ applyCustomTheme(customTheme);+ }+ initialized.value = true;+});+</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 521c0c22e6..569b8477ac 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -267,7 +267,8 @@"go-to-configure": "Configure","updated-at-by": "Updated {time} by {user}","created-at-by": "Created {time} by {user}",- "filter-by-name": "Filter by name"+ "filter-by-name": "Filter by name",+ "tenant": "Tenant"},"error-page": {"go-back-home": "Go back home"diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex f29b1d0f2f..21c1eea03b 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -267,7 +267,8 @@"go-to-configure": "Configurar","updated-at-by": "Actualizado {time} por {user}","created-at-by": "Creado {time} por {user}",- "filter-by-name": "Filtrar por nombre"+ "filter-by-name": "Filtrar por nombre",+ "tenant": "Arrendataria"},"error-page": {"go-back-home": "Volver al inicio"diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 0cbc29a68f..306d4f48a4 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -265,7 +265,8 @@"go-to-configure": "去配置","updated-at-by": "由 {user} 更新于 {time}","created-at-by": "由 {user} 创建于 {time}",- "filter-by-name": "按名称过滤"+ "filter-by-name": "按名称过滤",+ "tenant": "租户"},"error-page": {"go-back-home": "回到主页"diff --git a/frontend/src/utils/customTheme.ts b/frontend/src/utils/customTheme.tsnew file mode 100644index 0000000000..9dee5574c0--- /dev/null+++ b/frontend/src/utils/customTheme.ts@@ -0,0 +1,19 @@+import { useLocalStorage } from "@vueuse/core";+import { useI18n } from "vue-i18n";++export const applyCustomTheme = (theme: string) => {+ const rootElement = document.documentElement;+ if (theme === "lixiang") {+ // TODO: update the color variables.+ rootElement.style.setProperty("--color-accent", "#52ab7c");+ }+};++export const getCustomProjectTitle = () => {+ const { t } = useI18n();+ const theme = useLocalStorage<string>("bb.custom-theme", "");+ if (theme.value === "lixiang") {+ return t("common.tenant");+ }+ return t("common.project");+};diff --git a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vueindex 49a67985fa..348c5cec34 100644--- a/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue+++ b/frontend/src/views/sql-editor/AsidePanel/AsidePanel.vue@@ -8,7 +8,7 @@class="primary-sidebar h-full"pane-style="height: calc(100% - 35px); padding: 0;">- <NTabPane name="projects" :tab="$t('common.project')">+ <NTabPane name="projects" :tab="projectTitle"><DatabaseTreekey="sql-editor-database-tree"v-model:search-pattern="searchPattern"@@ -36,6 +36,7 @@ import { computed, ref, watchEffect } from "vue";import { useConnectionTreeStore, useCurrentUserV1 } from "@/store";import { ConnectionTreeMode } from "@/types";import { hasWorkspacePermissionV1 } from "@/utils";+import { getCustomProjectTitle } from "@/utils/customTheme";import DatabaseTree from "./DatabaseTree.vue";const currentUserV1 = useCurrentUserV1();@@ -48,6 +49,10 @@ const databaseTab = ref<"projects" | "instances">(: "projects");+const projectTitle = computed(() => {+ return getCustomProjectTitle();+});+const hasInstanceView = computed((): boolean => {return hasWorkspacePermissionV1("bb.permission.workspace.manage-database",