revert
This commit is contained in:
@@ -1,176 +0,0 @@
|
||||
<template>
|
||||
<div class="support-messenger">
|
||||
<div class="settings-section-title">پشتیبانی پیامرسان</div>
|
||||
<div class="support-messenger__card">
|
||||
<div v-if="messengerRow" class="support-messenger__block">
|
||||
<div class="support-messenger__label">پیامرسان</div>
|
||||
<a-radio-group
|
||||
:value="messengerValue || 'bale'"
|
||||
button-style="solid"
|
||||
class="support-messenger__radios"
|
||||
@update:value="onMessengerChange"
|
||||
>
|
||||
<a-radio-button
|
||||
v-for="opt in SUPPORT_MESSENGER_OPTIONS"
|
||||
:key="opt.key"
|
||||
:value="opt.key"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</a-radio-button>
|
||||
</a-radio-group>
|
||||
<div v-if="isSaving(messengerRow.id)" class="support-messenger__status">در حال ذخیره...</div>
|
||||
<div
|
||||
v-else-if="isSavedFlash(messengerRow.id)"
|
||||
class="support-messenger__status support-messenger__status--ok"
|
||||
>
|
||||
ذخیره شد
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="idRow" class="support-messenger__block">
|
||||
<div class="support-messenger__label">شناسه / یوزرنیم</div>
|
||||
<a-input
|
||||
:value="draftValue(idRow)"
|
||||
allow-clear
|
||||
:placeholder="idPlaceholder"
|
||||
@update:value="onFieldChange(idRow, $event)"
|
||||
/>
|
||||
<div class="support-messenger__hint">{{ idHelp }}</div>
|
||||
<div v-if="isSaving(idRow.id)" class="support-messenger__status">در حال ذخیره...</div>
|
||||
<div v-else-if="isSavedFlash(idRow.id)" class="support-messenger__status support-messenger__status--ok">
|
||||
ذخیره شد
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="textRow" class="support-messenger__block">
|
||||
<div class="support-messenger__label">متن دکمه</div>
|
||||
<a-input
|
||||
:value="draftValue(textRow)"
|
||||
allow-clear
|
||||
placeholder="مثلاً پشتیبانی"
|
||||
@update:value="onFieldChange(textRow, $event)"
|
||||
/>
|
||||
<div v-if="isSaving(textRow.id)" class="support-messenger__status">در حال ذخیره...</div>
|
||||
<div v-else-if="isSavedFlash(textRow.id)" class="support-messenger__status support-messenger__status--ok">
|
||||
ذخیره شد
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Const } from '@/model/configuration'
|
||||
import {
|
||||
SUPPORT_MESSENGER_OPTIONS,
|
||||
supportMessengerIdPlaceholder
|
||||
} from './settingTypes'
|
||||
|
||||
const props = defineProps<{
|
||||
messengerRow?: Const
|
||||
idRow?: Const
|
||||
textRow?: Const
|
||||
draftValue: (row: Const) => string
|
||||
isSaving: (id?: number) => boolean
|
||||
isSavedFlash: (id?: number) => boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:value': [row: Const, value: string]
|
||||
'update:isActive': [row: Const, value: boolean]
|
||||
}>()
|
||||
|
||||
const messengerValue = computed(() =>
|
||||
props.messengerRow ? props.draftValue(props.messengerRow) : 'bale'
|
||||
)
|
||||
|
||||
const idPlaceholder = computed(() => supportMessengerIdPlaceholder(messengerValue.value))
|
||||
|
||||
const idHelp = computed(() => {
|
||||
switch ((messengerValue.value || '').trim().toLowerCase()) {
|
||||
case 'telegram':
|
||||
return 'لینک: https://t.me/{username}'
|
||||
case 'whatsapp':
|
||||
return 'لینک: https://wa.me/{شماره}'
|
||||
case 'rubika':
|
||||
return 'لینک: https://rubika.ir/{username}'
|
||||
case 'eitaa':
|
||||
return 'لینک: https://eitaa.com/{username}'
|
||||
case 'soroush':
|
||||
return 'لینک: https://splus.ir/{username}'
|
||||
case 'bale':
|
||||
default:
|
||||
return 'لینک: https://ble.ir/{username}'
|
||||
}
|
||||
})
|
||||
|
||||
function onMessengerChange(value: string) {
|
||||
if (!props.messengerRow) return
|
||||
emit('update:value', props.messengerRow, value)
|
||||
emit('update:isActive', props.messengerRow, true)
|
||||
}
|
||||
|
||||
function onFieldChange(row: Const, value: string) {
|
||||
emit('update:value', row, value)
|
||||
if (value.trim()) {
|
||||
emit('update:isActive', row, true)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.support-messenger {
|
||||
margin-top: 28px;
|
||||
margin-bottom: 8px;
|
||||
|
||||
&__card {
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 10px;
|
||||
padding: 16px 18px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
&__block + &__block {
|
||||
margin-top: 18px;
|
||||
padding-top: 18px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
&__label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: rgba(0, 0, 0, 0.88);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
&__radios {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
|
||||
:deep(.ant-radio-button-wrapper) {
|
||||
border-radius: 6px !important;
|
||||
margin-inline-end: 0;
|
||||
}
|
||||
}
|
||||
|
||||
&__hint {
|
||||
margin-top: 6px;
|
||||
font-size: 11px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
direction: ltr;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&__status {
|
||||
margin-top: 6px;
|
||||
font-size: 11px;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
min-height: 16px;
|
||||
|
||||
&--ok {
|
||||
color: #52c41a;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -66,18 +66,6 @@
|
||||
</a-row>
|
||||
</template>
|
||||
|
||||
<SupportMessengerSettings
|
||||
v-if="supportMessengerBundle"
|
||||
:messenger-row="supportMessengerBundle.messenger"
|
||||
:id-row="supportMessengerBundle.id"
|
||||
:text-row="supportMessengerBundle.text"
|
||||
:draft-value="draftValue"
|
||||
:is-saving="isSaving"
|
||||
:is-saved-flash="isSavedFlash"
|
||||
@update:value="onValueChange"
|
||||
@update:is-active="onActiveChange"
|
||||
/>
|
||||
|
||||
<template v-if="otherRows.length">
|
||||
<div class="settings-section-title settings-section-title--spaced">سایر تنظیمات</div>
|
||||
<a-row :gutter="[16, 16]" class="settings-grid">
|
||||
@@ -102,7 +90,7 @@
|
||||
</template>
|
||||
|
||||
<a-empty
|
||||
v-if="!loading && !switchRows.length && !supportMessengerBundle && !otherRows.length"
|
||||
v-if="!loading && !switchRows.length && !otherRows.length"
|
||||
description="تنظیمی یافت نشد"
|
||||
class="mt-8"
|
||||
/>
|
||||
@@ -183,17 +171,13 @@ import { loading } from '@/utils'
|
||||
import { getConfiguration, setConfiguration } from '@/api/configuration'
|
||||
import SettingValueField from './SettingValueField.vue'
|
||||
import SettingCard from './SettingCard.vue'
|
||||
import SupportMessengerSettings from './SupportMessengerSettings.vue'
|
||||
import {
|
||||
SETTING_TYPE_OPTIONS,
|
||||
formatValueForSave,
|
||||
helpText,
|
||||
resolveSettingFieldType,
|
||||
SUPPORT_MESSENGER_KEYS
|
||||
resolveSettingFieldType
|
||||
} from './settingTypes'
|
||||
|
||||
const supportMessengerKeySet = new Set<string>(SUPPORT_MESSENGER_KEYS)
|
||||
|
||||
const settingTypeOptions = SETTING_TYPE_OPTIONS
|
||||
|
||||
const statusFilterOptions = [
|
||||
@@ -286,24 +270,9 @@ const switchRows = computed(() =>
|
||||
)
|
||||
|
||||
const otherRows = computed(() =>
|
||||
filteredRows.value.filter(
|
||||
(row) =>
|
||||
resolveSettingFieldType(row) !== 'switch' &&
|
||||
!supportMessengerKeySet.has(row.key ?? '')
|
||||
)
|
||||
filteredRows.value.filter((row) => resolveSettingFieldType(row) !== 'switch')
|
||||
)
|
||||
|
||||
const supportMessengerBundle = computed(() => {
|
||||
const rows = filteredRows.value.filter((row) => supportMessengerKeySet.has(row.key ?? ''))
|
||||
if (!rows.length) return null
|
||||
const byKey = Object.fromEntries(rows.map((row) => [row.key, row]))
|
||||
return {
|
||||
messenger: byKey.support_messenger as Const | undefined,
|
||||
id: byKey.support_messenger_id as Const | undefined,
|
||||
text: byKey.support_messenger_text as Const | undefined
|
||||
}
|
||||
})
|
||||
|
||||
function rowColSpan(row: Const): number {
|
||||
return resolveSettingFieldType(row) === 'longtext' ? 24 : 8
|
||||
}
|
||||
|
||||
@@ -102,37 +102,6 @@ const SELECT_OPTIONS_BY_KEY: Record<string, string> = {
|
||||
support_messenger: 'bale,telegram,whatsapp,rubika,eitaa,soroush'
|
||||
}
|
||||
|
||||
export const SUPPORT_MESSENGER_KEYS = [
|
||||
'support_messenger',
|
||||
'support_messenger_id',
|
||||
'support_messenger_text'
|
||||
] as const
|
||||
|
||||
export const SUPPORT_MESSENGER_OPTIONS = [
|
||||
{ key: 'bale', label: 'بله' },
|
||||
{ key: 'telegram', label: 'تلگرام' },
|
||||
{ key: 'whatsapp', label: 'واتساپ' },
|
||||
{ key: 'rubika', label: 'روبیکا' },
|
||||
{ key: 'eitaa', label: 'ایتا' },
|
||||
{ key: 'soroush', label: 'سروش' }
|
||||
] as const
|
||||
|
||||
export function supportMessengerIdPlaceholder(messenger: string): string {
|
||||
switch ((messenger || '').trim().toLowerCase()) {
|
||||
case 'telegram':
|
||||
return 'username بدون @'
|
||||
case 'whatsapp':
|
||||
return '98912xxxxxxx'
|
||||
case 'rubika':
|
||||
case 'eitaa':
|
||||
case 'soroush':
|
||||
return 'username'
|
||||
case 'bale':
|
||||
default:
|
||||
return 'username در ble.ir'
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveSettingFieldType(row: Pick<Const, 'key' | 'type'>): SettingFieldType {
|
||||
const raw = (row.type || '').trim().toLowerCase()
|
||||
if (['text', 'number', 'switch', 'select', 'longtext'].includes(raw)) {
|
||||
|
||||
Reference in New Issue
Block a user