<template>
  <view class="admin-page">
      <view class="admin-sections">
        <view class="admin-grid-2">
          <!-- 清除缓存 -->
          <view class="admin-card cache-card">
            <view class="cache-header">
              <text class="cache-title">清除缓存</text>
              <text class="cache-desc">清除系统的所有缓存</text>
            </view>
            <button class="btn primary full" @click="onClearCache">立即清除</button>
          </view>

        <!-- 清除日志 -->
        <view class="admin-card cache-card">
          <view class="cache-header">
            <text class="cache-title">清除日志</text>
            <text class="cache-desc">清除系统的所有日志文件</text>
          </view>
          <button class="btn primary full" @click="onClearLog">立即清除</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup lang="uts">

function onClearCache() {
  uni.showModal({
    title: '提示',
    content: '确定要清除所有缓存吗？',
    success: (res) => {
      if (res.confirm) {
        uni.showToast({ title: '缓存已清除', icon: 'none' })
      }
    }
  })
}

function onClearLog() {
  uni.showModal({
    title: '提示',
    content: '确定要清除所有日志吗？',
    success: (res) => {
      if (res.confirm) {
        uni.showToast({ title: '日志已清除', icon: 'none' })
      }
    }
  })
}
</script>

<style scoped lang="scss">
.admin-page {
  /* 使用 Layout 的背景和内边距 */
  min-height: auto;
}

.admin-grid-2 {
  display: flex;
  flex-direction: row;
  gap: 20px;
}

.admin-card {
  background-color: #fff;
  border-radius: 4px;
  padding: 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.cache-header {
  margin-bottom: 24px;
}

.cache-title {
  font-size: 18px;
  color: #333;
  font-weight: bold;
  display: block;
  margin-bottom: 12px;
}

.cache-desc {
  font-size: 14px;
  color: #999;
}

.btn {
  height: 32px;
  padding: 0 20px;
  border-radius: 2px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn.primary {
  background-color: #1890ff;
  color: #fff;
  border: none;
}

.btn.full {
  width: 120px;
}
</style>

