| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <template>
- <div class="alarm-container">
- <div class="alarm-header">
- <span class="alarm-title">{{t('alarm_settings.title')}}</span>
- </div>
- <div class="alarm-buttons">
- <el-button
- type="primary"
- size="large"
- @click="handleAlarm"
- class="btn-alarm"
- :loading="loading"
- >
- {{ t('alarm_settings.open_manual_alarm') }}
- </el-button>
- <el-button
- type="info"
- size="large"
- @click="handleCloseAlarm"
- class="btn-close"
- :loading="loading"
- >
- {{ t('alarm_settings.close_manual_alarm') }}
- </el-button>
- </div>
- <div class="alarm-tip">
- <span class="tip-icon">ℹ️</span>
- <span> {{ t('alarm_settings.tip') }}</span>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref } from 'vue'
- import { ElMessage } from 'element-plus'
- import { cameraAlarm } from '@/api/setting'
- import { useI18n } from 'vue-i18n'
- const { t } = useI18n()
- const loading = ref(false)
- async function handleCloseAlarm() {
- if (loading.value) return
- loading.value = true
- try {
- const res = await cameraAlarm({
- AlarmSettings: 0
- })
- if (res.data === 'ok\n') {
- ElMessage.success('Manual Alarm Deactivated Successfully')
- } else {
- ElMessage.warning('Manual Alarm Deactivation Error')
- }
- } catch (error) {
- ElMessage.error('Manual Alarm Deactivation Error')
- } finally {
- loading.value = false
- }
- }
- async function handleAlarm() {
- if (loading.value) return
- loading.value = true
- try {
- const res = await cameraAlarm({
- AlarmSettings: 1
- })
- if (res.data === 'ok\n') {
- ElMessage.success('Manual alarm activated successfully. It will remain active for 1 minute.')
- } else {
- ElMessage.warning('Manual Alarm Activation Error')
- }
- } catch (error) {
- ElMessage.error('Failed to Activate Manual Alarm.')
- } finally {
- loading.value = false
- }
- }
- </script>
- <style scoped lang="scss">
- .alarm-container {
- background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
- border-radius: 12px;
- padding: 24px;
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
- border-left: 4px solid #ff6b6b;
- transition: all 0.3s ease;
- &:hover {
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
- transform: translateY(-2px);
- }
- }
- .alarm-header {
- margin-bottom: 20px;
- padding-bottom: 12px;
- border-bottom: 2px solid rgba(255, 107, 107, 0.2);
- }
- .alarm-title {
- font-size: 16px;
- font-weight: 600;
- color: #333;
- display: flex;
- align-items: center;
- gap: 8px;
- &::before {
- content: '';
- width: 4px;
- height: 4px;
- background: #ff6b6b;
- border-radius: 50%;
- animation: pulse 2s ease-in-out infinite;
- }
- }
- .alarm-buttons {
- display: flex;
- gap: 16px;
- margin-bottom: 16px;
- flex-wrap: wrap;
- @media (max-width: 600px) {
- flex-direction: column;
- gap: 12px;
- }
- }
- .btn-alarm,
- .btn-close {
- flex: 1;
- min-width: 160px;
- height: 44px;
- font-weight: 500;
- letter-spacing: 0.5px;
- border-radius: 8px;
- transition: all 0.3s ease;
- border: none;
- font-size: 14px;
- @media (max-width: 600px) {
- width: 100%;
- }
- &:hover:not(:disabled) {
- transform: translateY(-2px);
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
- }
- &:active:not(:disabled) {
- transform: translateY(0);
- }
- }
- .btn-icon {
- margin-right: 6px;
- font-size: 16px;
- }
- .alarm-tip {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 12px;
- background: rgba(255, 193, 7, 0.1);
- border-radius: 6px;
- border-left: 3px solid #ffc107;
- font-size: 13px;
- color: #666;
- line-height: 1.5;
- }
- .tip-icon {
- font-size: 16px;
- flex-shrink: 0;
- }
- @keyframes pulse {
- 0%, 100% {
- opacity: 1;
- }
- 50% {
- opacity: 0.5;
- }
- }
- </style>
|