/
githubmirror
/
ChatDev
Обзор
Документация
Войти
/
githubmirror
/
ChatDev
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
frontend/src/components/SettingsModal.vue
253 строки
5 KB
YunLong
feat: Add comprehensive i18n support and fix WorkflowEdge crash bug
01 апр 2026, 13:54
01 апр 2026, 13:54
37aaf31
Код
Авторство
О чём код?
<template> <Transition name="modal-fade"> <div v-if="isVisible" class="modal-overlay" @click.self="close"> <div class="modal-content settings-modal"> <div class="modal-header"> <h3>{{ $t('settings.title') }}</h3> <button class="close-button" @click="close">×</button> </div> <div class="modal-body"> <div class="settings-item"> <label class="checkbox-label"> <input type="checkbox" v-model="localConfig.AUTO_SHOW_ADVANCED"> {{ $t('settings.auto_show_advanced') }} </label> <p class="setting-desc">{{ $t('settings.auto_show_advanced_desc') }}</p> </div> <div class="settings-item"> <label class="checkbox-label"> <input type="checkbox" v-model="localConfig.AUTO_EXPAND_MESSAGES"> {{ $t('settings.auto_expand_messages') }} </label> <p class="setting-desc">{{ $t('settings.auto_expand_messages_desc') }}</p> </div> <div class="settings-item"> <label class="checkbox-label"> <input type="checkbox" v-model="localConfig.ENABLE_HELP_TOOLTIPS"> {{ $t('settings.enable_help_tooltips') }} </label> <p class="setting-desc">{{ $t('settings.enable_help_tooltips_desc') }}</p> </div> <div class="settings-item"> <label class="setting-label">{{ $t('settings.language') }}</label> <select v-model="localConfig.LANGUAGE" class="language-select"> <option value="en">English</option> <option value="zh">简体中文</option> </select> <p class="setting-desc">{{ $t('settings.language_desc') }}</p> </div> </div> <div class="modal-footer"> <button class="cancel-button" @click="close">{{ $t('common.cancel') }}</button> <button class="confirm-button" @click="save">{{ $t('common.save') }}</button> </div> </div> </div> </Transition> </template> <script setup> import { reactive, watch } from 'vue' import { configStore } from '../utils/configStore.js' import { useI18n } from 'vue-i18n' const { locale } = useI18n() const props = defineProps({ isVisible: { type: Boolean, required: true } }) const localConfig = reactive({ AUTO_SHOW_ADVANCED: false, AUTO_EXPAND_MESSAGES: false, ENABLE_HELP_TOOLTIPS: true, LANGUAGE: 'en' }) watch(() => props.isVisible, (newVal) => { if (newVal) { // Sync local state with global store when modal opens Object.assign(localConfig, configStore) } }) const emit = defineEmits(['update:isVisible', 'close']) const close = () => { emit('update:isVisible', false) emit('close') } const save = () => { // Commit local changes to global store Object.assign(configStore, localConfig) locale.value = localConfig.LANGUAGE close() } </script> <style scoped> .modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; z-index: 2000; backdrop-filter: blur(2px); } .modal-content.settings-modal { width: 500px !important; max-width: 90vw; background: #1e1e1e; border-radius: 8px; border: 1px solid #333; color: #fff; display: flex; flex-direction: column; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5); } .modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #333; } .modal-header h3 { margin: 0; font-size: 18px; font-weight: 500; } .close-button { background: none; border: none; color: #888; font-size: 24px; cursor: pointer; padding: 0; line-height: 1; } .close-button:hover { color: #fff; } .modal-body { padding: 20px; flex: 1; overflow-y: auto; } .settings-item { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); } .settings-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; } .setting-label { display: block; color: #e0e0e0; font-size: 15px; margin-bottom: 8px; } .language-select { width: 100%; padding: 8px; background: #2a2a2a; border: 1px solid #444; color: #fff; border-radius: 4px; margin-bottom: 6px; } .checkbox-label { display: flex; align-items: center; gap: 10px; color: #e0e0e0; font-size: 15px; cursor: pointer; user-select: none; margin-bottom: 6px; } .checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: #4facfe; cursor: pointer; } .setting-desc { margin-left: 26px; color: #8b949e; font-size: 13px; line-height: 1.4; margin-top: 0; } .modal-footer { padding: 16px 20px; border-top: 1px solid #333; display: flex; justify-content: flex-end; gap: 12px; } .confirm-button { background: #4facfe; color: #fff; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; } .confirm-button:hover { background: #3a9cfa; } .cancel-button { background: transparent; color: #ccc; border: 1px solid #444; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 14px; } .cancel-button:hover { background: rgba(255, 255, 255, 0.05); color: #fff; border-color: #666; } /* Transitions */ .modal-fade-enter-active, .modal-fade-leave-active { transition: opacity 0.2s ease; } .modal-fade-enter-from, .modal-fade-leave-to { opacity: 0; } </style>