sync.vue 6.02 KB
<template>
  <view class="page">
    <view class="header-hero" :style="{ paddingTop: statusBarHeight + 'px' }">
      <view class="top-bar">
        <view class="top-left" @click="goBack">
          <AppIcon name="chevronLeft" size="sm" color="white" />
        </view>
        <view class="top-center">
          <text class="page-title">{{ t('sync.title') }}</text>
          <LocationPicker />
        </view>
        <view class="top-right" @click="isMenuOpen = true">
          <AppIcon name="menu" size="sm" color="white" />
        </view>
      </view>
    </view>

    <view class="content">
      <view class="status-card">
        <view class="status-top">
          <view class="status-icon"><AppIcon name="check" size="lg" color="green" /></view>
          <view>
            <text class="status-title">{{ t('sync.allSynced') }}</text>
            <text class="status-time">{{ t('sync.lastSync') }}: {{ syncData.lastSync }}</text>
          </view>
        </view>
        <view class="sync-btn" @click="handleSync">
          <AppIcon name="refresh" size="sm" color="white" />
          <text class="sync-btn-text">{{ t('sync.syncNow') }}</text>
        </view>
      </view>

      <text class="section-title">{{ t('sync.details') }}</text>

      <view class="detail-card">
        <view class="detail-row">
          <view class="detail-left">
            <view class="detail-icon blue"><AppIcon name="cloud" size="md" color="blue" /></view>
            <view>
              <text class="detail-name">{{ t('sync.labels') }}</text>
              <text class="detail-count">{{ syncData.labels.synced }} {{ t('sync.of') }} {{ syncData.labels.total }} {{ t('sync.synced') }}</text>
            </view>
          </view>
          <AppIcon name="check" size="md" color="green" />
        </view>
      </view>

      <view class="detail-card">
        <view class="detail-row">
          <view class="detail-left">
            <view class="detail-icon purple"><AppIcon name="cloud" size="md" color="purple" /></view>
            <view>
              <text class="detail-name">{{ t('sync.photos') }}</text>
              <text class="detail-count">{{ syncData.photos.synced }} {{ t('sync.of') }} {{ syncData.photos.total }} {{ t('sync.synced') }}</text>
            </view>
          </view>
          <AppIcon name="check" size="md" color="green" />
        </view>
      </view>

      <view class="info-card">
        <text>{{ t('sync.autoSyncInfo') }}</text>
      </view>
    </view>

    <SideMenu v-model="isMenuOpen" />
  </view>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
import AppIcon from '../../components/AppIcon.vue'
import SideMenu from '../../components/SideMenu.vue'
import LocationPicker from '../../components/LocationPicker.vue'
import { getStatusBarHeight } from '../../utils/statusBar'

const { t } = useI18n()
const statusBarHeight = getStatusBarHeight()
const isMenuOpen = ref(false)
const syncData = ref({
  lastSync: '2 minutes ago',
  labels: { total: 247, synced: 247, pending: 0 },
  photos: { total: 38, synced: 38, pending: 0 },
})

const goBack = () => {
  const pages = getCurrentPages()
  if (pages.length > 1) {
    uni.navigateBack()
  } else {
    uni.redirectTo({ url: '/pages/index/index' })
  }
}

const handleSync = () => {
  uni.showToast({ title: t('sync.syncing'), icon: 'none' })
  setTimeout(() => {
    uni.showToast({ title: t('sync.syncSuccess'), icon: 'success' })
  }, 1500)
}
</script>

<style scoped>
.page {
  min-height: 100vh;
  background: #f9fafb;
}

.header-hero {
  background: linear-gradient(135deg, var(--theme-primary), var(--theme-primary-dark));
  padding: 16rpx 32rpx 24rpx;
}

.top-bar {
  height: 96rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-left,
.top-right {
  width: 64rpx;
  height: 64rpx;
  border-radius: 999rpx;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-title {
  font-size: 34rpx;
  font-weight: 600;
  color: #fff;
}

.content {
  padding: 48rpx;
}

.status-card {
  background: #fff;
  padding: 48rpx;
  border-radius: 20rpx;
  margin-bottom: 48rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}

.status-top {
  display: flex;
  align-items: flex-start;
  gap: 32rpx;
  margin-bottom: 32rpx;
}

.status-icon {
  width: 96rpx;
  height: 96rpx;
  background: #f0fdf4;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-title {
  font-size: 36rpx;
  font-weight: 600;
  color: #111827;
  display: block;
  margin-bottom: 8rpx;
}

.status-time {
  font-size: 28rpx;
  color: #6b7280;
}

.sync-btn {
  width: 100%;
  height: 96rpx;
  background: var(--theme-primary);
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12rpx;
}

.sync-btn-text {
  font-size: 30rpx;
  font-weight: 600;
  color: #fff;
  line-height: 1;
}

.section-title {
  font-size: 32rpx;
  font-weight: 600;
  color: #111827;
  display: block;
  margin-bottom: 24rpx;
}

.detail-card {
  background: #fff;
  padding: 32rpx;
  border-radius: 20rpx;
  margin-bottom: 24rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-left {
  display: flex;
  align-items: center;
  gap: 24rpx;
}

.detail-icon {
  padding: 16rpx;
  border-radius: 16rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-icon.blue {
  background: #eff6ff;
}

.detail-icon.green {
  background: #f0fdf4;
}

.detail-icon.purple {
  background: #faf5ff;
}

.detail-name {
  font-size: 30rpx;
  font-weight: 500;
  color: #111827;
  display: block;
}

.detail-count {
  font-size: 26rpx;
  color: #6b7280;
}

.info-card {
  padding: 32rpx;
  background: #eff6ff;
  border: 1rpx solid #bfdbfe;
  border-radius: 16rpx;
  margin-top: 16rpx;
}

.info-card text {
  font-size: 26rpx;
  color: #1e3a8a;
  line-height: 1.5;
}
</style>