update UI
This commit is contained in:
1 parent
0c6f1c0ffc
commit
0c5939ed7a
7 files changed
+218
-61
No files matched your search
@@ -136,7 +136,7 @@ const submitFeedback = async () => {
|
||||
<div class="dialog-body space-y-5">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field block">{{ t('feedback.labels.type') }}</label>
|
||||
<div class="segment-control segment-control--chips segment-control--md" role="radiogroup" :aria-label="t('feedback.labels.type')">
|
||||
<div class="segment-control segment-control--cols-3 segment-control--md" role="radiogroup" :aria-label="t('feedback.labels.type')">
|
||||
<button
|
||||
v-for="item in typeOptions"
|
||||
:key="item"
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Check, Languages } from 'lucide-vue-next';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
floating?: boolean;
|
||||
/** header:登录顶栏;sidebar:Chat 侧栏底栏图标行 */
|
||||
variant?: 'header' | 'sidebar';
|
||||
/** sidebar 折叠栏用 md 图标 */
|
||||
iconSize?: 'sm' | 'md';
|
||||
}>(),
|
||||
{
|
||||
floating: false,
|
||||
variant: 'header',
|
||||
iconSize: 'sm',
|
||||
},
|
||||
);
|
||||
|
||||
const { locale, t } = useI18n();
|
||||
const open = ref(false);
|
||||
const rootRef = ref<HTMLElement | null>(null);
|
||||
|
||||
/** 语言菜单文案固定,不随当前 locale 翻译(与产品约定一致) */
|
||||
const LOCALE_PICKER_OPTIONS = [
|
||||
{ value: 'zh-CN', label: '简体中文' },
|
||||
{ value: 'zh-TW', label: '繁體中文' },
|
||||
{ value: 'en', label: 'English' },
|
||||
{ value: 'th', label: 'ไทย' },
|
||||
] as const;
|
||||
|
||||
const buttonClass = computed(() => {
|
||||
if (props.variant === 'sidebar') {
|
||||
return [
|
||||
'flex items-center justify-center transition-colors hover:text-secondary',
|
||||
open.value ? 'text-brand-600' : 'text-muted',
|
||||
];
|
||||
}
|
||||
if (props.floating) return 'header-locale-btn header-locale-btn--floating';
|
||||
return 'header-locale-btn';
|
||||
});
|
||||
|
||||
const iconClass = computed(() => {
|
||||
if (props.variant === 'header') return 'h-4 w-4 md:h-5 md:w-5';
|
||||
return props.iconSize === 'md' ? 'h-5 w-5' : 'h-4 w-4';
|
||||
});
|
||||
|
||||
const menuClass = computed(() =>
|
||||
props.variant === 'sidebar'
|
||||
? 'header-locale-menu header-locale-menu--sidebar'
|
||||
: 'header-locale-menu',
|
||||
);
|
||||
|
||||
const selectLocale = (code: string) => {
|
||||
locale.value = code;
|
||||
open.value = false;
|
||||
};
|
||||
|
||||
const onDocumentClick = (event: MouseEvent) => {
|
||||
if (!rootRef.value?.contains(event.target as Node)) {
|
||||
open.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(open, (isOpen) => {
|
||||
if (isOpen) {
|
||||
document.addEventListener('click', onDocumentClick);
|
||||
return;
|
||||
}
|
||||
document.removeEventListener('click', onDocumentClick);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('click', onDocumentClick);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div ref="rootRef" class="relative shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
:class="buttonClass"
|
||||
:title="t('workspace.languageLabel')"
|
||||
:aria-label="t('workspace.languageLabel')"
|
||||
:aria-expanded="open"
|
||||
aria-haspopup="listbox"
|
||||
@click.stop="open = !open"
|
||||
>
|
||||
<Languages :class="iconClass" />
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="open"
|
||||
:class="menuClass"
|
||||
role="listbox"
|
||||
:aria-label="t('workspace.languageLabel')"
|
||||
@click.stop
|
||||
>
|
||||
<button
|
||||
v-for="item in LOCALE_PICKER_OPTIONS"
|
||||
:key="item.value"
|
||||
type="button"
|
||||
role="option"
|
||||
:aria-selected="locale === item.value"
|
||||
class="header-locale-menu__item"
|
||||
:class="{ 'header-locale-menu__item--active': locale === item.value }"
|
||||
@click="selectLocale(item.value)"
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
<Check v-if="locale === item.value" class="h-4 w-4 shrink-0 text-brand-600" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,18 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
|
||||
const { locale } = useI18n();
|
||||
import LocaleToggleButton from '../components/LocaleToggleButton.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center gap-2">
|
||||
<ThemeToggleButton />
|
||||
<select v-model="locale" class="select-field-ds">
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="zh-TW">繁體</option>
|
||||
<option value="en">English</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
<LocaleToggleButton />
|
||||
</div>
|
||||
</template>
|
||||
@@ -32,6 +32,53 @@
|
||||
|
||||
.select-field-ds { @apply select-field; }
|
||||
|
||||
/* 顶栏语言图标 — 无圆圈,与 theme-toggle-btn--inline 同占位对齐 */
|
||||
.header-locale-btn {
|
||||
@apply flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border-0 bg-transparent p-0 text-muted shadow-none transition-colors hover:text-primary;
|
||||
}
|
||||
|
||||
.header-locale-btn:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: 0 0 0 2px var(--focus-ring);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.header-locale-btn {
|
||||
@apply h-9 w-9;
|
||||
}
|
||||
}
|
||||
|
||||
.header-locale-btn--floating {
|
||||
@apply fixed bottom-5 right-5 z-[70] h-11 w-11 rounded-full;
|
||||
}
|
||||
|
||||
/* 顶栏语言图标 — 下拉菜单 */
|
||||
.header-locale-menu {
|
||||
@apply absolute right-0 top-full z-[60] mt-1.5 min-w-[9.5rem] overflow-hidden rounded-xl border border-default py-1 shadow-elevated;
|
||||
background-color: var(--bg-surface);
|
||||
}
|
||||
|
||||
.header-locale-menu--sidebar {
|
||||
@apply bottom-full top-auto right-0 left-auto mb-1.5 mt-0;
|
||||
}
|
||||
|
||||
.header-locale-menu__item {
|
||||
@apply flex w-full items-center justify-between gap-2 px-3 py-2 text-left text-sm font-medium text-secondary transition-colors;
|
||||
}
|
||||
|
||||
.header-locale-menu__item:hover {
|
||||
@apply bg-surface-soft text-primary;
|
||||
}
|
||||
|
||||
.header-locale-menu__item--active {
|
||||
@apply bg-brand-50 text-brand-700;
|
||||
}
|
||||
|
||||
html.dark .header-locale-menu__item--active {
|
||||
@apply bg-brand-950/40 text-brand-300;
|
||||
}
|
||||
|
||||
.card-ds { @apply card; }
|
||||
|
||||
.card-ds-interactive {
|
||||
@@ -539,61 +586,70 @@
|
||||
@apply w-5 h-5 cursor-pointer rounded border-default text-blue-600 focus:ring-blue-500;
|
||||
}
|
||||
|
||||
/* Segment control — toggle / single-choice (not action buttons) */
|
||||
/* Segment control — 与个人中心「主题」切换同款(细边框 + brand 选中态) */
|
||||
.segment-control {
|
||||
@apply inline-flex max-w-full flex-wrap gap-2;
|
||||
@apply grid w-full gap-2;
|
||||
}
|
||||
|
||||
/* 2–3 个短选项:独立细边框芯片 */
|
||||
.segment-control--chips {
|
||||
@apply gap-2;
|
||||
.segment-control--cols-2 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
/* 等分宽、独立细边框(如 Cron 四选一)— 无共用轨道 */
|
||||
.segment-control--chips-equal {
|
||||
@apply flex w-full flex-nowrap gap-2;
|
||||
.segment-control--cols-3 {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.segment-control--chips-equal .segment-item {
|
||||
@apply min-w-0 flex-1 justify-center text-center;
|
||||
.segment-control--cols-4 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
@media (min-width: 640px) {
|
||||
.segment-control--cols-4 {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
/* 工具栏内 2 个短标签(如 数据库直联 | 外部 API) */
|
||||
.segment-control--fit {
|
||||
@apply inline-grid w-auto;
|
||||
grid-template-columns: repeat(2, max-content);
|
||||
}
|
||||
|
||||
.segment-control--fit .segment-item {
|
||||
@apply w-auto;
|
||||
}
|
||||
|
||||
.segment-item {
|
||||
@apply shrink-0 cursor-pointer whitespace-nowrap rounded-xl border px-3 py-2 text-sm font-semibold transition-colors duration-200;
|
||||
color: var(--text-secondary);
|
||||
background-color: var(--bg-surface);
|
||||
border-color: var(--border-default);
|
||||
box-shadow: none;
|
||||
@apply w-full cursor-pointer whitespace-nowrap rounded-xl border border-default bg-surface px-3 py-3 text-center text-sm font-medium text-secondary transition-colors;
|
||||
}
|
||||
|
||||
.segment-item:hover:not(.segment-item--active) {
|
||||
color: var(--text-primary);
|
||||
background-color: var(--bg-surface-soft);
|
||||
.segment-item:hover:not(:disabled):not(.segment-item--active) {
|
||||
@apply bg-surface-soft text-primary;
|
||||
}
|
||||
|
||||
.segment-item--active {
|
||||
color: #0284c7;
|
||||
background-color: color-mix(in srgb, #0ea5e9 12%, var(--bg-surface));
|
||||
border-color: color-mix(in srgb, #0ea5e9 38%, var(--border-default));
|
||||
@apply border-brand-500 bg-brand-50 text-brand-700;
|
||||
}
|
||||
|
||||
html.dark .segment-item--active {
|
||||
color: #7dd3fc;
|
||||
background-color: color-mix(in srgb, #0ea5e9 20%, var(--bg-surface));
|
||||
border-color: color-mix(in srgb, #38bdf8 45%, var(--border-default));
|
||||
@apply border-brand-400 bg-brand-950/50 text-brand-300;
|
||||
}
|
||||
|
||||
.segment-item:disabled {
|
||||
@apply cursor-not-allowed opacity-60;
|
||||
}
|
||||
|
||||
.segment-control--sm .segment-item {
|
||||
@apply px-3 py-1.5 text-xs;
|
||||
@apply px-3 py-2 text-xs;
|
||||
}
|
||||
|
||||
.segment-control--md .segment-item {
|
||||
@apply px-4 py-2.5 text-sm;
|
||||
@apply px-3 py-3 text-sm;
|
||||
}
|
||||
|
||||
/* @deprecated — use .segment-control + .segment-item */
|
||||
.btn-segment-group {
|
||||
@apply segment-control segment-control--chips segment-control--sm;
|
||||
@apply segment-control segment-control--cols-2 segment-control--sm;
|
||||
}
|
||||
|
||||
.btn-segment-group .btn-segment {
|
||||
|
||||
@@ -5837,7 +5837,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<h4 class="text-base font-bold text-primary shrink-0">{{ $t('admin.schedule.form.dataSourceConfig') }}</h4>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<div
|
||||
class="segment-control segment-control--chips segment-control--sm shrink-0"
|
||||
class="segment-control segment-control--fit segment-control--sm shrink-0"
|
||||
role="radiogroup"
|
||||
:aria-label="$t('admin.schedule.form.dataSourceConfig')"
|
||||
>
|
||||
@@ -6105,7 +6105,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<p class="text-sm text-muted">{{ $t('admin.schedule.form.cronHint') }}</p>
|
||||
</div>
|
||||
<div
|
||||
class="segment-control segment-control--chips-equal segment-control--sm w-full"
|
||||
class="segment-control segment-control--cols-4 segment-control--sm"
|
||||
role="radiogroup"
|
||||
:aria-label="$t('admin.schedule.form.cronTitle')"
|
||||
>
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue'
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useChat } from '../composables/useChat';
|
||||
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, Briefcase, History, Sun, Moon } from 'lucide-vue-next';
|
||||
import LocaleToggleButton from '../components/LocaleToggleButton.vue';
|
||||
import { marked } from 'marked';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { config } from '../config';
|
||||
@@ -2117,6 +2118,7 @@ const showChatRating = ref(false);
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white shadow-sm shadow-brand-500/20">
|
||||
{{ (currentUser?.username || 'I').charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<LocaleToggleButton variant="sidebar" icon-size="md" />
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-secondary" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-5 w-5" /></button>
|
||||
<button @click="goToWorkspace()" class="transition-colors hover:text-secondary" :title="$t('workspace.title')"><Briefcase class="h-5 w-5" /></button>
|
||||
</div>
|
||||
@@ -2212,17 +2214,7 @@ const showChatRating = ref(false);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 px-4 py-2">
|
||||
<span class="shrink-0 text-xs font-medium text-muted">{{ $t('chat.language') }}</span>
|
||||
<select v-model="locale" class="min-w-0 flex-1 rounded-lg border border-default bg-surface-soft px-2 py-1 text-xs text-secondary outline-none transition focus:border-brand-400">
|
||||
<option value="zh-CN">简体中文</option>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-TW">繁體中文</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button @click="handleLogout" class="flex w-full items-center gap-2 border-t border-slate-50 px-4 py-2 text-left text-sm text-red-600 transition-colors hover:bg-red-50">
|
||||
<button @click="handleLogout" class="flex w-full items-center gap-2 border-t border-subtle px-4 py-2 text-left text-sm text-red-600 transition-colors hover:bg-red-50">
|
||||
<LogOut class="w-4 h-4" />
|
||||
{{ $t('chat.logout') }}
|
||||
</button>
|
||||
@@ -2236,6 +2228,7 @@ const showChatRating = ref(false);
|
||||
<Sun v-if="appliedTheme === 'dark'" class="h-4 w-4" />
|
||||
<Moon v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<LocaleToggleButton variant="sidebar" />
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-secondary" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-4 w-4" /></button>
|
||||
<button @click="goToWorkspace()" class="transition-colors hover:text-secondary" :title="$t('workspace.title')"><Briefcase class="h-4 w-4" /></button>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { config } from '../config';
|
||||
import { useTheme } from '../composables/useTheme';
|
||||
import type { ThemePreference } from '../composables/useTheme';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
import LocaleToggleButton from '../components/LocaleToggleButton.vue';
|
||||
import MarketingShell from '../layouts/MarketingShell.vue';
|
||||
import DeleteConfirmDialog from '../components/DeleteConfirmDialog.vue';
|
||||
import GeneralFeedbackDialog from '../components/GeneralFeedbackDialog.vue';
|
||||
@@ -1409,12 +1410,7 @@ onBeforeUnmount(() => {
|
||||
<MarketingShell v-if="!isLoggedIn">
|
||||
<template #tools>
|
||||
<ThemeToggleButton />
|
||||
<select v-model="locale" class="select-field-ds cursor-pointer rounded-full text-xs">
|
||||
<option value="en">English</option>
|
||||
<option value="zh-CN">{{ $t('workspace.lang.zhCN') }}</option>
|
||||
<option value="zh-TW">{{ $t('workspace.lang.zhTW') }}</option>
|
||||
<option value="th">ไทย</option>
|
||||
</select>
|
||||
<LocaleToggleButton />
|
||||
</template>
|
||||
|
||||
<div v-if="isLoading" class="animate-pulse space-y-8">
|
||||
@@ -1866,17 +1862,21 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-muted">{{ $t('profile.theme') }}</label>
|
||||
<div class="grid grid-cols-3 gap-2">
|
||||
<div
|
||||
class="segment-control segment-control--cols-3 segment-control--md"
|
||||
role="radiogroup"
|
||||
:aria-label="$t('profile.theme')"
|
||||
>
|
||||
<button
|
||||
v-for="item in themeOptions"
|
||||
:key="item.value"
|
||||
type="button"
|
||||
role="radio"
|
||||
:aria-checked="profileUser.theme_preference === item.value"
|
||||
:disabled="!isProfileEditing"
|
||||
class="segment-item"
|
||||
:class="profileUser.theme_preference === item.value ? 'segment-item--active' : ''"
|
||||
@click="profileUser.theme_preference = item.value"
|
||||
class="rounded-xl border px-3 py-3 text-sm font-medium transition-colors"
|
||||
:class="profileUser.theme_preference === item.value
|
||||
? 'border-brand-500 bg-brand-50 text-brand-700'
|
||||
: 'border-default bg-surface text-secondary'"
|
||||
>
|
||||
{{ item.label() }}
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user