style: update style of browser tabs

style: update style of connection dialog
This commit is contained in:
tiny-craft 2023-10-27 16:41:27 +08:00
parent 33051f4e46
commit b6eebda177
7 changed files with 59 additions and 52 deletions

View File

@ -79,6 +79,10 @@ const border = computed(() => {
return `1px solid ${color}` return `1px solid ${color}`
}) })
const logoWrapperWidth = computed(() => {
return `${data.navMenuWidth + prefStore.behavior.asideWidth - 4}px`
})
const borderRadius = ref(10) const borderRadius = ref(10)
const logoPaddingLeft = ref(10) const logoPaddingLeft = ref(10)
const maximised = ref(false) const maximised = ref(false)
@ -148,7 +152,8 @@ onMounted(async () => {
<div <div
id="app-toolbar-title" id="app-toolbar-title"
:style="{ :style="{
width: `${data.navMenuWidth + prefStore.behavior.asideWidth - 4}px`, width: logoWrapperWidth,
minWidth: logoWrapperWidth,
paddingLeft: `${logoPaddingLeft}px`, paddingLeft: `${logoPaddingLeft}px`,
}"> }">
<n-space :size="3" :wrap="false" :wrap-item="false" align="center"> <n-space :size="3" :wrap="false" :wrap-item="false" align="center">
@ -192,7 +197,7 @@ onMounted(async () => {
<nav-menu v-model:value="tabStore.nav" :width="data.navMenuWidth" /> <nav-menu v-model:value="tabStore.nav" :width="data.navMenuWidth" />
<!-- browser page --> <!-- browser page -->
<div v-show="tabStore.nav === 'browser'" :class="{ dragging }" class="flex-box-h flex-item-expand"> <div v-show="tabStore.nav === 'browser'" :class="{ dragging }" class="flex-box-h flex-item-expand">
<div id="app-side" :style="{ width: asideWidthVal }" class="flex-box-h flex-item"> <div :style="{ width: asideWidthVal }" class="app-side flex-box-h flex-item">
<browser-pane <browser-pane
v-for="t in tabStore.tabs" v-for="t in tabStore.tabs"
v-show="get(tabStore.currentTab, 'name') === t.name" v-show="get(tabStore.currentTab, 'name') === t.name"
@ -218,7 +223,7 @@ onMounted(async () => {
<!-- server list page --> <!-- server list page -->
<div v-show="tabStore.nav === 'server'" :class="{ dragging }" class="flex-box-h flex-item-expand"> <div v-show="tabStore.nav === 'server'" :class="{ dragging }" class="flex-box-h flex-item-expand">
<div id="app-side" :style="{ width: asideWidthVal }" class="flex-box-h flex-item"> <div :style="{ width: asideWidthVal }" class="app-side flex-box-h flex-item">
<connection-pane class="flex-item-expand" /> <connection-pane class="flex-item-expand" />
<div <div
:class="{ :class="{
@ -273,7 +278,7 @@ onMounted(async () => {
height: calc(100% - 60px); height: calc(100% - 60px);
} }
#app-side { .app-side {
//overflow: hidden; //overflow: hidden;
height: 100%; height: 100%;
background-color: v-bind('themeVars.tabColor'); background-color: v-bind('themeVars.tabColor');

View File

@ -63,10 +63,6 @@ const selectedSubTab = computed(() => {
return subTab return subTab
}) })
const onSwitchSubTab = (name) => {
tabStore.switchSubTab(name)
}
// BUG: naive-ui tabs will set the bottom line to '0px' after switch to another page and back again // BUG: naive-ui tabs will set the bottom line to '0px' after switch to another page and back again
// watch parent tabs' changing and call 'syncBarPosition' manually // watch parent tabs' changing and call 'syncBarPosition' manually
const tabsRef = ref(null) const tabsRef = ref(null)
@ -102,7 +98,7 @@ watch(
placement="top" placement="top"
tab-style="padding-left: 10px; padding-right: 10px;" tab-style="padding-left: 10px; padding-right: 10px;"
type="line" type="line"
@update:value="onSwitchSubTab"> @update:value="tabStore.switchSubTab">
<!-- server status pane --> <!-- server status pane -->
<n-tab-pane :name="BrowserTabType.Status.toString()" display-directive="show:lazy"> <n-tab-pane :name="BrowserTabType.Status.toString()" display-directive="show:lazy">
<template #tab> <template #tab>

View File

@ -7,6 +7,10 @@ import { get, map } from 'lodash'
import { useThemeVars } from 'naive-ui' import { useThemeVars } from 'naive-ui'
import useConnectionStore from 'stores/connections.js' import useConnectionStore from 'stores/connections.js'
/**
* Value content tab on head
*/
const themeVars = useThemeVars() const themeVars = useThemeVars()
const i18n = useI18n() const i18n = useI18n()
const tabStore = useTabStore() const tabStore = useTabStore()
@ -21,18 +25,15 @@ const onCloseTab = (tabIndex) => {
}) })
} }
const activeTabStyle = computed(() => { const tabMarkColor = computed(() => {
const { name } = tabStore.currentTab const { name } = tabStore?.currentTab || {}
const { markColor = '' } = connectionStore.serverProfile[name] || {} const { markColor = '' } = connectionStore.serverProfile[name] || {}
return { return markColor
borderTopWidth: markColor ? '3px' : '1px',
borderTopColor: markColor || themeVars.value.borderColor,
}
}) })
const tabClass = (idx) => { const tabClass = (idx) => {
if (tabStore.activatedIndex === idx) { if (tabStore.activatedIndex === idx) {
return ['value-tab', 'value-tab-active'] return ['value-tab', 'value-tab-active', tabMarkColor.value ? 'value-tab-active_mark' : '']
} else if (tabStore.activatedIndex - 1 === idx) { } else if (tabStore.activatedIndex - 1 === idx) {
return ['value-tab', 'value-tab-inactive'] return ['value-tab', 'value-tab-inactive']
} else { } else {
@ -52,12 +53,6 @@ const tab = computed(() =>
<n-tabs <n-tabs
v-model:value="tabStore.activatedIndex" v-model:value="tabStore.activatedIndex"
:closable="true" :closable="true"
:tab-style="{
borderStyle: 'solid',
borderWidth: '1px',
borderLeftColor: themeVars.borderColor,
borderRightColor: themeVars.borderColor,
}"
:tabs-padding="0" :tabs-padding="0"
:theme-overrides="{ :theme-overrides="{
tabFontWeightActive: 800, tabFontWeightActive: 800,
@ -73,14 +68,7 @@ const tab = computed(() =>
type="card" type="card"
@close="onCloseTab" @close="onCloseTab"
@update:value="(tabIndex) => tabStore.switchTab(tabIndex)"> @update:value="(tabIndex) => tabStore.switchTab(tabIndex)">
<n-tab <n-tab v-for="(t, i) in tab" :key="i" :class="tabClass(i)" :closable="true" :name="i" @dblclick.stop="() => {}">
v-for="(t, i) in tab"
:key="i"
:class="tabClass(i)"
:closable="true"
:name="i"
:style="tabStore.activatedIndex === i ? activeTabStyle : undefined"
@dblclick.stop="() => {}">
<n-space :size="5" :wrap-item="false" align="center" inline justify="center"> <n-space :size="5" :wrap-item="false" align="center" inline justify="center">
<n-icon size="18"> <n-icon size="18">
<server stroke-width="4" /> <server stroke-width="4" />
@ -95,11 +83,16 @@ const tab = computed(() =>
.value-tab { .value-tab {
--wails-draggable: none; --wails-draggable: none;
position: relative; position: relative;
border: 1px solid v-bind('themeVars.borderColor') !important;
} }
.value-tab-active { .value-tab-active {
background-color: v-bind('themeVars.bodyColor') !important; background-color: v-bind('themeVars.bodyColor') !important;
border-bottom-color: v-bind('themeVars.bodyColor') !important; border-bottom-color: v-bind('themeVars.bodyColor') !important;
&_mark {
border-top: 3px solid v-bind('tabMarkColor') !important;
}
} }
.value-tab-inactive { .value-tab-inactive {

View File

@ -10,8 +10,6 @@ const props = defineProps({
server: String, server: String,
}) })
const emit = defineEmits(['update:autoRefresh', 'refresh'])
const connectionStore = useConnectionStore() const connectionStore = useConnectionStore()
const serverInfo = ref({}) const serverInfo = ref({})
const autoRefresh = ref(false) const autoRefresh = ref(false)
@ -169,7 +167,7 @@ const infoFilter = ref('')
<n-gi :span="6"> <n-gi :span="6">
<n-statistic <n-statistic
:label="$t('status.connected_clients')" :label="$t('status.connected_clients')"
:value="get(serverInfo.value, 'Clients.connected_clients', 0)" /> :value="get(serverInfo, 'Clients.connected_clients', 0)" />
</n-gi> </n-gi>
<n-gi :span="6"> <n-gi :span="6">
<n-statistic :value="totalKeys"> <n-statistic :value="totalKeys">

View File

@ -8,11 +8,13 @@ import Close from '@/components/icons/Close.vue'
import useConnectionStore from 'stores/connections.js' import useConnectionStore from 'stores/connections.js'
import FileOpenInput from '@/components/common/FileOpenInput.vue' import FileOpenInput from '@/components/common/FileOpenInput.vue'
import { KeyViewType } from '@/consts/key_view_type.js' import { KeyViewType } from '@/consts/key_view_type.js'
import { useThemeVars } from 'naive-ui'
/** /**
* Dialog for new or edit connection * Dialog for new or edit connection
*/ */
const themeVars = useThemeVars()
const dialogStore = useDialog() const dialogStore = useDialog()
const connectionStore = useConnectionStore() const connectionStore = useConnectionStore()
const i18n = useI18n() const i18n = useI18n()
@ -396,10 +398,13 @@ const onClose = () => {
<div <div
v-for="color in predefineColors" v-for="color in predefineColors"
:key="color" :key="color"
:class="{ :style="{
'color-preset-item_selected': generalForm.markColor === color, backgroundColor: color,
borderColor:
generalForm.markColor === color
? themeVars.textColorBase
: themeVars.borderColor,
}" }"
:style="{ backgroundColor: color }"
class="color-preset-item" class="color-preset-item"
@click="generalForm.markColor = color"> @click="generalForm.markColor = color">
<n-icon v-if="isEmpty(color)" :component="Close" size="24" /> <n-icon v-if="isEmpty(color)" :component="Close" size="24" />
@ -591,13 +596,9 @@ const onClose = () => {
width: 24px; width: 24px;
height: 24px; height: 24px;
margin-right: 2px; margin-right: 2px;
border: white 3px solid; border-width: 3px;
border-style: solid;
cursor: pointer; cursor: pointer;
border-radius: 50%; border-radius: 50%;
&_selected,
&:hover {
border-color: #cdd0d6;
}
} }
</style> </style>

View File

@ -12,21 +12,12 @@ import useConnectionStore from 'stores/connections.js'
import { types } from '@/consts/support_redis_type.js' import { types } from '@/consts/support_redis_type.js'
import Search from '@/components/icons/Search.vue' import Search from '@/components/icons/Search.vue'
import Unlink from '@/components/icons/Unlink.vue' import Unlink from '@/components/icons/Unlink.vue'
import Status from '@/components/icons/Status.vue'
const themeVars = useThemeVars() const themeVars = useThemeVars()
const dialogStore = useDialogStore() const dialogStore = useDialogStore()
const tabStore = useTabStore() const tabStore = useTabStore()
const currentName = computed(() => get(tabStore.currentTab, 'name', '')) const currentName = computed(() => get(tabStore.currentTab, 'name', ''))
const browserTreeRef = ref(null) const browserTreeRef = ref(null)
/**
*
* @type {ComputedRef<{server: string, db: number, key: string}>}
*/
const currentSelect = computed(() => {
const { server, db, key } = tabStore.currentTab || {}
return { server, db, key }
})
const onInfo = () => { const onInfo = () => {
browserTreeRef.value?.handleSelectContextMenu('server_info') browserTreeRef.value?.handleSelectContextMenu('server_info')
@ -96,7 +87,7 @@ const filterTypeOptions = computed(() => {
<!-- stroke-width="4"--> <!-- stroke-width="4"-->
<!-- unselect-stroke-width="3"--> <!-- unselect-stroke-width="3"-->
<!-- @update:value="onSwitchView" />--> <!-- @update:value="onSwitchView" />-->
<icon-button :icon="Status" size="20" stroke-width="4" t-tooltip="interface.status" @click="onInfo" /> <!-- <icon-button :icon="Status" size="20" stroke-width="4" t-tooltip="interface.status" @click="onInfo" />-->
<icon-button :icon="Refresh" size="20" stroke-width="4" t-tooltip="interface.reload" @click="onRefresh" /> <icon-button :icon="Refresh" size="20" stroke-width="4" t-tooltip="interface.reload" @click="onRefresh" />
<div class="flex-item-expand" /> <div class="flex-item-expand" />
<icon-button <icon-button

View File

@ -5,6 +5,7 @@ import { padStart, size, startsWith } from 'lodash'
* @property {number} r * @property {number} r
* @property {number} g * @property {number} g
* @property {number} b * @property {number} b
* @property {number} [a]
*/ */
/** /**
@ -43,6 +44,28 @@ export function hexGammaCorrection(rgb, gamma) {
} }
} }
/**
* mix two colors
* @param rgba1
* @param rgba2
* @param weight
* @return {{a: number, r: number, b: number, g: number}}
*/
export function mixColors(rgba1, rgba2, weight = 0.5) {
if (rgba1.a === undefined) {
rgba1.a = 255
}
if (rgba2.a === undefined) {
rgba2.a = 255
}
return {
r: Math.floor(rgba1.r * (1 - weight) + rgba2.r * weight),
g: Math.floor(rgba1.g * (1 - weight) + rgba2.g * weight),
b: Math.floor(rgba1.b * (1 - weight) + rgba2.b * weight),
a: Math.floor(rgba1.a * (1 - weight) + rgba2.a * weight),
}
}
/** /**
* RGB object to hex color string * RGB object to hex color string
* @param {RGB} rgb * @param {RGB} rgb