2026-06-05 22:01:10 +03:30
|
|
|
<template>
|
|
|
|
|
<div
|
|
|
|
|
class="setting-card"
|
|
|
|
|
:class="{
|
|
|
|
|
'setting-card--readonly': readonly,
|
2026-06-13 17:38:35 +03:30
|
|
|
'setting-card--saving': saving
|
2026-06-05 22:01:10 +03:30
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<div class="setting-card__head">
|
|
|
|
|
<div class="setting-card__title-row">
|
|
|
|
|
<span v-if="readonly" class="setting-card__lock" title="فقطخواندنی">🔒</span>
|
|
|
|
|
<span class="setting-card__title">{{ title }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="setting-card__key">کلید: {{ settingKey }}</div>
|
|
|
|
|
<div v-if="help" class="setting-card__help">{{ help }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
class="setting-card__body"
|
|
|
|
|
:class="{ 'setting-card__body--switch': fieldType === 'switch' }"
|
|
|
|
|
>
|
|
|
|
|
<SettingValueField
|
|
|
|
|
:model-value="modelValue"
|
|
|
|
|
:setting-key="settingKey"
|
|
|
|
|
:setting-type="settingType"
|
|
|
|
|
:description="description"
|
|
|
|
|
:disabled="readonly"
|
2026-06-17 17:34:21 +03:30
|
|
|
:rows="fieldType === 'longtext' ? 10 : 6"
|
2026-06-05 22:01:10 +03:30
|
|
|
@update:value="emit('update:value', $event)"
|
2026-06-17 17:34:21 +03:30
|
|
|
@blur="emit('blur')"
|
2026-06-05 22:01:10 +03:30
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-if="saving" class="setting-card__status">
|
|
|
|
|
<a-spin size="small" />
|
|
|
|
|
<span>در حال ذخیره...</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div v-else-if="savedFlash" class="setting-card__status setting-card__status--ok">ذخیره شد</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import SettingValueField from './SettingValueField.vue'
|
2026-06-28 21:48:17 +03:30
|
|
|
import {
|
|
|
|
|
helpText,
|
2026-07-02 00:30:42 +03:30
|
|
|
resolveSettingTitle,
|
2026-06-28 21:48:17 +03:30
|
|
|
resolveSettingFieldType,
|
|
|
|
|
type SettingFieldType
|
|
|
|
|
} from './settingTypes'
|
2026-06-05 22:01:10 +03:30
|
|
|
import type { Const } from '@/model/configuration'
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
row: Const
|
|
|
|
|
modelValue: string
|
|
|
|
|
readonly?: boolean
|
|
|
|
|
saving?: boolean
|
|
|
|
|
savedFlash?: boolean
|
|
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
'update:value': [value: string]
|
2026-06-17 17:34:21 +03:30
|
|
|
blur: []
|
2026-06-05 22:01:10 +03:30
|
|
|
}>()
|
|
|
|
|
|
|
|
|
|
const settingKey = computed(() => props.row.key ?? '')
|
|
|
|
|
const settingType = computed(() => props.row.type)
|
|
|
|
|
const description = computed(() => props.row.description)
|
2026-07-02 00:30:42 +03:30
|
|
|
const title = computed(() => resolveSettingTitle(props.row))
|
2026-06-05 22:01:10 +03:30
|
|
|
|
|
|
|
|
const fieldType = computed<SettingFieldType>(() =>
|
|
|
|
|
resolveSettingFieldType({ key: props.row.key, type: props.row.type })
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const help = computed(() => helpText(props.row))
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.setting-card {
|
2026-06-14 21:04:26 +03:30
|
|
|
border: 1px solid var(--admin-border);
|
2026-06-05 22:01:10 +03:30
|
|
|
border-radius: 10px;
|
|
|
|
|
padding: 14px 16px;
|
2026-06-14 21:04:26 +03:30
|
|
|
background: var(--admin-bg-elevated);
|
2026-06-05 22:01:10 +03:30
|
|
|
min-height: 108px;
|
|
|
|
|
transition: border-color 0.2s, box-shadow 0.2s;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
&:hover:not(.setting-card--readonly) {
|
|
|
|
|
border-color: #91caff;
|
|
|
|
|
box-shadow: 0 2px 8px rgba(22, 119, 255, 0.08);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&--readonly {
|
2026-06-14 21:04:26 +03:30
|
|
|
background: var(--admin-bg-muted);
|
2026-06-05 22:01:10 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&--saving {
|
|
|
|
|
border-color: #91caff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__head {
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__title-row {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__lock {
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 1.4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__title {
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
font-size: 14px;
|
2026-06-14 21:04:26 +03:30
|
|
|
color: var(--admin-text);
|
2026-06-05 22:01:10 +03:30
|
|
|
line-height: 1.45;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__key {
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
font-size: 12px;
|
2026-06-14 21:04:26 +03:30
|
|
|
color: var(--admin-text-secondary);
|
2026-06-05 22:01:10 +03:30
|
|
|
direction: ltr;
|
|
|
|
|
text-align: right;
|
|
|
|
|
word-break: break-all;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__help {
|
|
|
|
|
margin-top: 4px;
|
|
|
|
|
font-size: 11px;
|
2026-06-14 21:04:26 +03:30
|
|
|
color: var(--admin-text-secondary);
|
2026-06-05 22:01:10 +03:30
|
|
|
line-height: 1.35;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__body {
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
flex: 1;
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
|
|
|
|
&--switch {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&__status {
|
|
|
|
|
margin-top: 8px;
|
|
|
|
|
font-size: 11px;
|
2026-06-14 21:04:26 +03:30
|
|
|
color: var(--admin-text-secondary);
|
2026-06-05 22:01:10 +03:30
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 6px;
|
|
|
|
|
min-height: 18px;
|
|
|
|
|
|
|
|
|
|
&--ok {
|
|
|
|
|
color: #52c41a;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|