Feature(custom): optimize UI of config sync panel and dialog

This commit is contained in:
Kuingsmile
2025-12-31 11:47:42 +08:00
parent 07c4bd75a9
commit edff735328
5 changed files with 655 additions and 146 deletions
+216 -137
View File
@@ -183,57 +183,92 @@
<!-- Sync & Configure Tab -->
<div v-if="activeName === 'sync'" class="tab-content">
<div class="settings-section">
<h2>{{ t('pages.settings.sync.syncConfiguration') }}</h2>
<p>{{ ' ' }}</p>
<!-- Sync Status Overview -->
<div class="sync-overview-card">
<div class="sync-overview-header">
<div class="sync-overview-icon">
<RotateCcw :size="28" />
</div>
<div class="sync-overview-info">
<h2>{{ t('pages.settings.sync.syncConfiguration') }}</h2>
<p class="sync-status-text">
<span class="sync-type-badge">{{ sync.type?.toUpperCase() || 'N/A' }}</span>
<span v-if="sync.type !== 'webdav' && sync.username"
>{{ sync.username }}/{{ sync.repo || '...' }}</span
>
<span v-else-if="sync.type === 'webdav' && sync.webdavEndpoint">{{ sync.webdavEndpoint }}</span>
<span v-else class="sync-not-configured">{{ t('pages.settings.sync.notConfigured') }}</span>
</p>
</div>
</div>
<button class="btn btn-primary sync-config-btn" @click="syncVisible = true">
<Settings :size="16" />
{{ t('pages.settings.sync.configureSync') }}
</button>
</div>
<div class="form-grid">
<div class="form-group">
<label>{{ t('pages.settings.sync.syncEndpointConfig') }}</label>
<button class="btn btn-primary" @click="syncVisible = true">
<RotateCcw :size="16" />
{{ t('pages.settings.clickToSet') }}
</button>
<!-- Sync Actions Section -->
<div class="settings-section sync-actions-section">
<div class="section-header-with-icon">
<CloudUpload :size="20" class="section-icon" />
<div>
<h2>{{ t('pages.settings.sync.syncActions') }}</h2>
</div>
</div>
<div class="sync-action-cards">
<div class="sync-action-card" @click="upDownConfigVisible = true">
<div class="sync-action-icon upload">
<CloudUpload :size="24" />
</div>
<div class="sync-action-content">
<h4>{{ t('pages.settings.sync.upDownloadSettings') }}</h4>
<p>{{ t('pages.settings.sync.upDownloadDesc') }}</p>
</div>
<div class="sync-action-arrow">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 18l6-6-6-6" />
</svg>
</div>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.upDownloadSettings') }}</label>
<button class="btn btn-primary" @click="upDownConfigVisible = true">
<Download :size="16" />
{{ t('pages.settings.clickToSet') }}
</button>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.migrateFromPicGo') }}</label>
<button class="btn btn-secondary" @click="handleMigrateFromPicGo">
<Import :size="16" />
{{ t('pages.settings.clickToSet') }}
</button>
<div class="sync-action-card" @click="handleMigrateFromPicGo">
<div class="sync-action-icon migrate">
<Import :size="24" />
</div>
<div class="sync-action-content">
<h4>{{ t('pages.settings.sync.migrateFromPicGo') }}</h4>
<p>{{ t('pages.settings.sync.migrateDesc') }}</p>
</div>
<div class="sync-action-arrow">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M9 18l6-6-6-6" />
</svg>
</div>
</div>
</div>
</div>
<div class="settings-section">
<h2>{{ t('pages.settings.sync.fileManagement') }}</h2>
<p>{{ ' ' }}</p>
<div class="form-grid">
<div class="form-group">
<label>{{ t('pages.settings.sync.openConfigFile') }}</label>
<button class="btn btn-secondary" @click="openFile('data.json')">
<FileText :size="16" />
{{ t('pages.settings.clickToOpen') }}
</button>
<!-- File Management Section -->
<div class="settings-section file-management-section">
<div class="section-header-with-icon">
<FolderOpen :size="20" class="section-icon" />
<div>
<h2>{{ t('pages.settings.sync.fileManagement') }}</h2>
<p>{{ t('pages.settings.sync.fileManagementDesc') }}</p>
</div>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.openConfigFileDir') }}</label>
<button class="btn btn-secondary" @click="openDirectory()">
<FolderOpen :size="16" />
{{ t('pages.settings.clickToOpen') }}
</button>
</div>
<div class="file-action-grid">
<button class="file-action-btn" @click="openFile('data.json')">
<FileText :size="20" />
<span>{{ t('pages.settings.sync.openConfigFile') }}</span>
</button>
<button class="file-action-btn" @click="openDirectory()">
<FolderOpen :size="20" />
<span>{{ t('pages.settings.sync.openConfigFileDir') }}</span>
</button>
</div>
</div>
</div>
@@ -1109,106 +1144,148 @@
<!-- Sync Configuration Dialog -->
<div v-if="syncVisible" class="dialog-overlay">
<div class="dialog large" @click.stop>
<div class="dialog sync-config-dialog" @click.stop>
<div class="dialog-header">
<h3 class="dialog-title">
{{ t('pages.settings.sync.syncEndpointConfig') }}
</h3>
<div class="dialog-header-content">
<div class="sync-dialog-icon">
<RotateCcw :size="24" />
</div>
<div>
<h3 class="dialog-title">{{ t('pages.settings.sync.syncEndpointConfig') }}</h3>
</div>
</div>
<button class="dialog-close" @click="cancelSyncSetting">×</button>
</div>
<div class="dialog-content">
<div class="notice-text">
{{ t('pages.settings.sync.syncConfigNote') }}
<div class="dialog-content sync-dialog-content">
<div class="sync-type-selector">
<label class="sync-type-label">{{ t('pages.settings.sync.selectType') }}</label>
<div class="sync-type-grid">
<button
v-for="typeitem of syncType"
:key="typeitem"
:class="['sync-type-btn', { active: sync.type === typeitem }]"
@click="sync.type = typeitem"
>
<GitBranch v-if="typeitem.includes('git')" :size="20" />
<Store v-else-if="typeitem === 'webdav'" :size="20" />
<span>{{ typeitem.slice(0, 1).toUpperCase() + typeitem.slice(1) }}</span>
</button>
</div>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.selectType') }}</label>
<select v-model="sync.type" class="form-select">
<option v-for="typeitem of syncType" :key="typeitem" :value="typeitem">
{{ typeitem.slice(0, 1).toUpperCase() + typeitem.slice(1) }}
</option>
</select>
</div>
<div v-if="sync.type === 'gitea'" class="form-group">
<label>{{ t('pages.settings.sync.giteaHost') }}</label>
<input
v-model.trim="sync.endpoint"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.giteaHost')"
/>
</div>
<div v-if="sync.type === 'webdav'" class="form-group">
<label>{{ t('pages.settings.sync.webdavEndpoint') }}</label>
<input
v-model.trim="sync.webdavEndpoint"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdavEndpoint')"
/>
</div>
<template v-if="sync.type !== 'webdav'">
<div v-for="inputItem in ['username', 'repo', 'branch', 'token']" :key="inputItem" class="form-group">
<label>{{ t(`pages.settings.sync.${sync.type.toLowerCase()}.${inputItem.toLowerCase()}`) }}</label>
<input
v-model.trim="sync[inputItem as any]"
type="text"
class="form-input"
:placeholder="t(`pages.settings.sync.${sync.type.toLowerCase()}.${inputItem.toLowerCase()}`)"
/>
</div>
</template>
<template v-if="sync.type === 'webdav'">
<div class="form-group">
<label>{{ t('pages.settings.sync.webdav.username') }}</label>
<input
v-model.trim="sync.webdavUsername"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdav.username')"
/>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.webdav.password') }}</label>
<input
v-model.trim="sync.webdavPassword"
class="form-input"
:placeholder="t('pages.settings.sync.webdav.password')"
/>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.webdav.savePath') }}</label>
<input
v-model.trim="sync.webdavSavePath"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdav.savePath')"
/>
</div>
<div class="form-group">
<label>{{ t('pages.settings.sync.webdav.authType') }}</label>
<select v-model="sync.webdavAuthType" class="form-select">
<option value="basic">Basic</option>
<option value="digest">Digest</option>
</select>
</div>
<div class="form-group">
<label class="switch-label">
<input v-model="sync.webdavSslEnabled" type="checkbox" class="switch-input" />
<span class="switch-slider" />
<div class="switch-content">
<div class="switch-title">{{ t('pages.settings.sync.webdav.enableSSL') }}</div>
</div>
<!-- Configuration Fields -->
<div class="sync-config-fields">
<div v-if="sync.type === 'gitea'" class="sync-field-group">
<label>
<Server :size="16" />
{{ t('pages.settings.sync.giteaHost') }}
</label>
<input
v-model.trim="sync.endpoint"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.giteaHost')"
/>
</div>
<!-- WebDAV Endpoint -->
<div v-if="sync.type === 'webdav'" class="sync-field-group">
<label>
<Globe :size="16" />
{{ t('pages.settings.sync.webdavEndpoint') }}
</label>
<input
v-model.trim="sync.webdavEndpoint"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdavEndpoint')"
/>
</div>
<!-- Git-based fields -->
<template v-if="sync.type !== 'webdav'">
<div class="sync-fields-grid">
<div
v-for="inputItem in ['username', 'repo', 'branch', 'token']"
:key="inputItem"
class="sync-field-group"
>
<label>
{{ t(`pages.settings.sync.${sync.type.toLowerCase()}.${inputItem.toLowerCase()}`) }}
</label>
<input
v-model.trim="sync[inputItem as any]"
type="text"
class="form-input"
:placeholder="t(`pages.settings.sync.${sync.type.toLowerCase()}.${inputItem.toLowerCase()}`)"
/>
</div>
</div>
</template>
<!-- WebDAV fields -->
<template v-if="sync.type === 'webdav'">
<div class="sync-fields-grid">
<div class="sync-field-group">
<label>{{ t('pages.settings.sync.webdav.username') }}</label>
<input
v-model.trim="sync.webdavUsername"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdav.username')"
/>
</div>
<div class="sync-field-group">
<label>{{ t('pages.settings.sync.webdav.password') }}</label>
<input
v-model.trim="sync.webdavPassword"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdav.password')"
/>
</div>
<div class="sync-field-group">
<label>{{ t('pages.settings.sync.webdav.savePath') }}</label>
<input
v-model.trim="sync.webdavSavePath"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.webdav.savePath')"
/>
</div>
<div class="sync-field-group">
<label>{{ t('pages.settings.sync.webdav.authType') }}</label>
<select v-model="sync.webdavAuthType" class="form-select">
<option value="basic">Basic</option>
<option value="digest">Digest</option>
</select>
</div>
</div>
<div class="sync-ssl-toggle">
<label class="switch-label">
<input v-model="sync.webdavSslEnabled" type="checkbox" class="switch-input" />
<span class="switch-slider" />
<div class="switch-content">
<div class="switch-title">{{ t('pages.settings.sync.webdav.enableSSL') }}</div>
<div class="switch-description">{{ t('pages.settings.sync.webdav.enableSSLDesc') }}</div>
</div>
</label>
</div>
</template>
<!-- GitHub Proxy -->
<div v-if="sync.type === 'github'" class="sync-field-group">
<label>
<Globe :size="16" />
{{ t('pages.settings.sync.syncConfigProxy') }}
</label>
<input
v-model.trim="sync.proxy"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.syncConfigProxy')"
/>
</div>
</template>
<div v-if="sync.type === 'github'" class="form-group">
<label>{{ t('pages.settings.sync.syncConfigProxy') }}</label>
<input
v-model.trim="sync.proxy"
type="text"
class="form-input"
:placeholder="t('pages.settings.sync.syncConfigProxy')"
/>
</div>
</div>
<div class="dialog-footer">
@@ -1248,7 +1325,7 @@
class="config-button"
@click="syncTaskFn(item.task, item.number)"
>
<Import :size="16" class="button-icon" />
<CloudUpload :size="16" class="button-icon" />
<span>{{ item.label }}</span>
</button>
</div>
@@ -1326,6 +1403,7 @@ import {
Edit,
FileText,
FolderOpen,
GitBranch,
Globe,
Image as ImageIcon,
Import,
@@ -1336,6 +1414,7 @@ import {
RotateCcw,
Server,
Settings,
Store,
} from 'lucide-vue-next'
import type { IConfig } from 'piclist'
import pkg from 'root/package.json'
+412
View File
@@ -1082,3 +1082,415 @@ small {
max-width: 95%;
}
}
/* ==================== Sync Panel Styles ==================== */
/* Sync Overview Card */
.sync-overview-card {
display: flex;
justify-content: space-between;
align-items: center;
border: 1px solid var(--color-border);
border-radius: 16px;
padding: 1.5rem;
background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-background-primary) 100%);
box-shadow: 0 4px 16px rgb(0 0 0 / 8%);
gap: 1.5rem;
}
.sync-overview-header {
display: flex;
align-items: center;
gap: 1rem;
}
.sync-overview-icon {
display: flex;
justify-content: center;
align-items: center;
border-radius: 14px;
width: 46px;
height: 46px;
color: white;
background: linear-gradient(135deg, #409eff 0%, #66b1ff 100%);
box-shadow: 0 4px 12px rgb(64 158 255 / 30%);
}
.sync-overview-info h2 {
margin: 0 0 0.25rem;
font-size: 1.125rem;
font-weight: 600;
color: var(--color-text-primary);
}
.sync-status-text {
display: flex;
align-items: center;
font-size: 0.875rem;
color: var(--color-text-secondary);
gap: 0.5rem;
}
.sync-type-badge {
display: inline-flex;
align-items: center;
border-radius: 6px;
padding: 0.2rem 0.5rem;
font-size: 0.75rem;
font-weight: 600;
color: #409eff;
background: rgb(64 158 255 / 15%);
letter-spacing: 0.02em;
}
.sync-not-configured {
font-style: italic;
color: var(--color-text-tertiary);
}
.sync-config-btn {
white-space: nowrap;
flex-shrink: 0;
}
/* Section Header with Icon */
.section-header-with-icon {
display: flex;
align-items: flex-start;
margin-bottom: 0.5rem;
gap: 0.75rem;
}
.section-icon {
margin-top: 0.125rem;
color: var(--color-accent);
flex-shrink: 0;
}
.section-header-with-icon h2 {
margin: 0 0 0.25rem;
font-size: 1.125rem;
font-weight: 600;
color: var(--color-text-primary);
}
.section-header-with-icon p {
margin: 0;
font-size: 0.875rem;
color: var(--color-text-secondary);
}
/* Sync Action Cards */
.sync-action-cards {
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.sync-action-card {
display: flex;
align-items: center;
border: 1px solid var(--color-border);
border-radius: 12px;
padding: 0.5rem 1.25rem;
background: var(--color-background-tertiary);
transition: all 0.25s ease;
cursor: pointer;
gap: 1rem;
}
.sync-action-card:hover {
border-color: var(--color-accent);
background: var(--color-background-secondary);
transform: translateX(4px);
box-shadow: 0 4px 16px rgb(64 158 255 / 15%);
}
.sync-action-icon {
display: flex;
justify-content: center;
align-items: center;
border-radius: 10px;
width: 38px;
height: 38px;
color: white;
flex-shrink: 0;
}
.sync-action-icon.upload {
background: linear-gradient(135deg, #409eff 0%, #66b1ff 100%);
}
.sync-action-icon.migrate {
background: linear-gradient(135deg, #67c23a 0%, #95d475 100%);
}
.sync-action-content {
flex: 1;
}
.sync-action-content h4 {
margin: 0 0 0.25rem;
font-size: 0.95rem;
font-weight: 600;
color: var(--color-text-primary);
}
.sync-action-content p {
margin: 0;
font-size: 0.8rem;
color: var(--color-text-secondary);
line-height: 1.4;
}
.sync-action-arrow {
color: var(--color-text-tertiary);
transition: all 0.25s ease;
flex-shrink: 0;
}
.sync-action-card:hover .sync-action-arrow {
color: var(--color-accent);
transform: translateX(4px);
}
/* File Management Section */
.file-action-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1rem;
}
.file-action-btn {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 1px dashed var(--color-border);
border-radius: 12px;
padding: 1.5rem 1rem;
background: var(--color-background-tertiary);
transition: all 0.25s ease;
cursor: pointer;
gap: 0.75rem;
}
.file-action-btn:hover {
border-style: solid;
border-color: var(--color-accent);
color: var(--color-accent);
background: rgb(64 158 255 / 8%);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgb(64 158 255 / 15%);
}
.file-action-btn svg {
color: var(--color-text-secondary);
transition: color 0.25s ease;
}
.file-action-btn:hover svg {
color: var(--color-accent);
}
.file-action-btn span {
font-size: 0.875rem;
font-weight: 500;
text-align: center;
color: var(--color-text-primary);
}
/* ==================== Sync Configuration Dialog ==================== */
.sync-config-dialog {
width: 90%;
max-width: 560px;
}
.sync-dialog-icon {
display: flex;
justify-content: center;
align-items: center;
border-radius: 10px;
width: 34px;
height: 34px;
color: white;
background: linear-gradient(135deg, #409eff 0%, #66b1ff 100%);
box-shadow: 0 4px 12px rgb(64 158 255 / 25%);
flex-shrink: 0;
}
.dialog-subtitle {
margin: 0.25rem 0 0;
font-size: 0.8rem;
color: var(--color-text-secondary);
}
.sync-dialog-content {
padding: 0.5rem;
}
/* Sync Type Selector */
.sync-type-selector {
margin-bottom: 1.5rem;
}
.sync-type-label {
display: block;
margin-bottom: 0.75rem;
font-size: 0.875rem;
font-weight: 500;
color: var(--color-text-primary);
}
.sync-type-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 0.75rem;
}
.sync-type-btn {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
border: 2px solid var(--color-border);
border-radius: 12px;
padding: 1rem 0.5rem;
background: var(--color-background-tertiary);
transition: all 0.2s ease;
cursor: pointer;
gap: 0.5rem;
}
.sync-type-btn:hover {
border-color: var(--color-accent);
background: rgb(64 158 255 / 8%);
}
.sync-type-btn.active {
border-color: #409eff;
color: #409eff;
background: rgb(64 158 255 / 12%);
box-shadow: 0 0 0 3px rgb(64 158 255 / 15%);
}
.sync-type-btn svg {
color: var(--color-text-secondary);
transition: color 0.2s ease;
}
.sync-type-btn.active svg,
.sync-type-btn:hover svg {
color: #409eff;
}
.sync-type-btn span {
font-size: 0.75rem;
font-weight: 600;
color: inherit;
}
/* Sync Config Fields */
.sync-config-fields {
display: flex;
flex-direction: column;
gap: 1rem;
}
.sync-fields-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1rem;
}
.sync-field-group {
display: flex;
flex-direction: column;
}
.sync-field-group label {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
font-size: 0.825rem;
font-weight: 500;
color: var(--color-text-primary);
gap: 0.4rem;
}
.sync-field-group label svg {
color: var(--color-accent);
}
.sync-ssl-toggle {
margin-top: 0.5rem;
}
/* Dark Mode Adjustments for Sync Panel */
:root.dark .sync-overview-card,
:root.auto.dark .sync-overview-card {
background: linear-gradient(135deg, var(--color-background-secondary) 0%, var(--color-background-tertiary) 100%);
box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
}
:root.dark .sync-action-card,
:root.auto.dark .sync-action-card {
border-color: var(--color-border);
background: var(--color-background-secondary);
}
:root.dark .sync-action-card:hover,
:root.auto.dark .sync-action-card:hover {
background: var(--color-background-tertiary);
}
:root.dark .file-action-btn,
:root.auto.dark .file-action-btn {
background: var(--color-background-secondary);
}
:root.dark .file-action-btn:hover,
:root.auto.dark .file-action-btn:hover {
background: rgb(64 158 255 / 12%);
}
:root.dark .sync-type-btn,
:root.auto.dark .sync-type-btn {
border-color: var(--color-border);
background: var(--color-background-secondary);
}
:root.dark .sync-type-btn:hover,
:root.auto.dark .sync-type-btn:hover {
background: rgb(64 158 255 / 15%);
}
:root.dark .sync-type-btn.active,
:root.auto.dark .sync-type-btn.active {
background: rgb(64 158 255 / 20%);
}
/* Responsive Adjustments */
@media (width <= 768px) {
.sync-overview-card {
flex-direction: column;
text-align: center;
}
.sync-overview-header {
flex-direction: column;
}
.file-action-grid {
grid-template-columns: 1fr;
}
.sync-type-grid {
grid-template-columns: repeat(2, 1fr);
}
.sync-fields-grid {
grid-template-columns: 1fr;
}
}