|
@@ -1,15 +1,25 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { computed, ref, Ref } from 'vue'
|
|
|
|
|
|
|
+import { computed, ref, Ref, watch } from 'vue'
|
|
|
import { useI18n } from 'vue-i18n'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
import { devicesConfig } from '../../config'
|
|
import { devicesConfig } from '../../config'
|
|
|
-import type { DeviceSpec } from '../../lib/speaker/types'
|
|
|
|
|
|
|
+import type { DeviceSpec, DevicePanelState } from '../../lib/speaker/types'
|
|
|
import type { NumberParamKey } from '../../lib/speaker/types'
|
|
import type { NumberParamKey } from '../../lib/speaker/types'
|
|
|
|
|
|
|
|
const { t } = useI18n()
|
|
const { t } = useI18n()
|
|
|
-interface SplMaxConfig {
|
|
|
|
|
- standalone: Array<{ label: string; value: number }>
|
|
|
|
|
- extension: Array<{ label: string; value: number }>
|
|
|
|
|
-}
|
|
|
|
|
|
|
+
|
|
|
|
|
+const props = defineProps({
|
|
|
|
|
+ state: {
|
|
|
|
|
+ type: Object,
|
|
|
|
|
+ default: () => ({
|
|
|
|
|
+ model: 'custom',
|
|
|
|
|
+ isExtension: false,
|
|
|
|
|
+ powerMode: '',
|
|
|
|
|
+ splMax: 0,
|
|
|
|
|
+ hCov: 0,
|
|
|
|
|
+ vCov: 0
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
type NumberField = {
|
|
type NumberField = {
|
|
|
kind: 'number'
|
|
kind: 'number'
|
|
|
key: NumberParamKey
|
|
key: NumberParamKey
|
|
@@ -23,6 +33,7 @@ type NumberField = {
|
|
|
type FieldConfig = NumberField
|
|
type FieldConfig = NumberField
|
|
|
const emit = defineEmits<{
|
|
const emit = defineEmits<{
|
|
|
(e: 'apply-spec', spec: DeviceSpec): void
|
|
(e: 'apply-spec', spec: DeviceSpec): void
|
|
|
|
|
+ (e: 'update:state', state: DevicePanelState): void
|
|
|
}>()
|
|
}>()
|
|
|
|
|
|
|
|
const modelOptions = devicesConfig.map((d) => ({
|
|
const modelOptions = devicesConfig.map((d) => ({
|
|
@@ -35,16 +46,19 @@ const modelOptions = devicesConfig.map((d) => ({
|
|
|
|
|
|
|
|
const selectedModel = ref<string | null>('custom')
|
|
const selectedModel = ref<string | null>('custom')
|
|
|
|
|
|
|
|
-const isExtension = ref(false)
|
|
|
|
|
|
|
+const isExtension = ref(props.state.isExtension || false)
|
|
|
|
|
|
|
|
const powerMode = ref<string>('')
|
|
const powerMode = ref<string>('')
|
|
|
|
|
|
|
|
-const currentSplMaxConfig = ref<SplMaxConfig>({ standalone: [], extension: [] })
|
|
|
|
|
|
|
+const currentSplMaxConfig = computed(() => {
|
|
|
|
|
+ return devicesConfig.find((d) => d.model === selectedModel.value).splMax
|
|
|
|
|
+})
|
|
|
const splMax = ref<number | null>(null)
|
|
const splMax = ref<number | null>(null)
|
|
|
const hCov = ref<number | null>(null)
|
|
const hCov = ref<number | null>(null)
|
|
|
const vCov = ref<number | null>(null)
|
|
const vCov = ref<number | null>(null)
|
|
|
|
|
|
|
|
const powerModeOptions = computed(() => {
|
|
const powerModeOptions = computed(() => {
|
|
|
|
|
+ if (currentSplMaxConfig.value.extension.length == 0) return currentSplMaxConfig.value.standalone
|
|
|
return isExtension.value
|
|
return isExtension.value
|
|
|
? currentSplMaxConfig.value.extension
|
|
? currentSplMaxConfig.value.extension
|
|
|
: currentSplMaxConfig.value.standalone
|
|
: currentSplMaxConfig.value.standalone
|
|
@@ -55,35 +69,60 @@ const apply = (): void => {
|
|
|
const isCustom = !device || device.model === 'custom'
|
|
const isCustom = !device || device.model === 'custom'
|
|
|
hCov.value = isCustom ? hCov.value : device.horizontalAngle
|
|
hCov.value = isCustom ? hCov.value : device.horizontalAngle
|
|
|
vCov.value = isCustom ? vCov.value : device.verticalAngle
|
|
vCov.value = isCustom ? vCov.value : device.verticalAngle
|
|
|
|
|
+ const deviceState = {
|
|
|
|
|
+ model: selectedModel.value,
|
|
|
|
|
+ isExtension: isExtension.value,
|
|
|
|
|
+ powerMode: powerMode.value,
|
|
|
|
|
+ splMax: splMax.value,
|
|
|
|
|
+ hCov: hCov.value,
|
|
|
|
|
+ vCov: vCov.value
|
|
|
|
|
+ }
|
|
|
const data = {
|
|
const data = {
|
|
|
hCov: hCov.value,
|
|
hCov: hCov.value,
|
|
|
vCov: vCov.value,
|
|
vCov: vCov.value,
|
|
|
splMax: splMax.value
|
|
splMax: splMax.value
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ emit('update:state', deviceState)
|
|
|
emit('apply-spec', data)
|
|
emit('apply-spec', data)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const onSelectModel = (model: string, option): void => {
|
|
|
|
|
- console.log('onSelectModel', model, option)
|
|
|
|
|
- currentSplMaxConfig.value = option.splMax
|
|
|
|
|
|
|
+const onSelectModel = (model: string): void => {
|
|
|
selectedModel.value = model
|
|
selectedModel.value = model
|
|
|
isExtension.value = false
|
|
isExtension.value = false
|
|
|
- powerMode.value = ''
|
|
|
|
|
|
|
+ powerMode.value = powerModeOptions.value[0].label
|
|
|
|
|
+ splMax.value = powerModeOptions.value[0].value
|
|
|
apply()
|
|
apply()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const onToggleExtension = (value: boolean): void => {
|
|
const onToggleExtension = (value: boolean): void => {
|
|
|
isExtension.value = value
|
|
isExtension.value = value
|
|
|
- powerMode.value = ''
|
|
|
|
|
|
|
+ powerMode.value = powerModeOptions.value[0].label
|
|
|
splMax.value = powerModeOptions.value[0].value
|
|
splMax.value = powerModeOptions.value[0].value
|
|
|
apply()
|
|
apply()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const onSelectPowerMode = (mode: string): void => {
|
|
const onSelectPowerMode = (mode: string): void => {
|
|
|
- powerMode.value = mode
|
|
|
|
|
|
|
+ powerModeOptions.value.forEach((item) => {
|
|
|
|
|
+ if (item.label == mode) splMax.value = item.value
|
|
|
|
|
+ })
|
|
|
apply()
|
|
apply()
|
|
|
}
|
|
}
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.state,
|
|
|
|
|
+ (newVal) => {
|
|
|
|
|
+ selectedModel.value = newVal.model
|
|
|
|
|
+ isExtension.value = newVal.isExtension
|
|
|
|
|
+ powerMode.value = newVal.powerMode
|
|
|
|
|
+ splMax.value = newVal.splMax
|
|
|
|
|
+ hCov.value = newVal.hCov
|
|
|
|
|
+ vCov.value = newVal.vCov
|
|
|
|
|
+ console.log(isExtension.value, props.state)
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ immediate: true
|
|
|
|
|
+ }
|
|
|
|
|
+)
|
|
|
const fields: FieldConfig[] = [
|
|
const fields: FieldConfig[] = [
|
|
|
{
|
|
{
|
|
|
kind: 'number',
|
|
kind: 'number',
|
|
@@ -132,12 +171,17 @@ const fields: FieldConfig[] = [
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<n-flex>
|
|
<n-flex>
|
|
|
- <div class="field model-field" v-if="selectedModel && selectedModel !== 'custom'">
|
|
|
|
|
|
|
+ <div
|
|
|
|
|
+ class="field model-field"
|
|
|
|
|
+ v-if="
|
|
|
|
|
+ selectedModel && selectedModel !== 'custom' && currentSplMaxConfig.extension.length > 0
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
<div class="field-label">
|
|
<div class="field-label">
|
|
|
<span class="sym">🔊</span>
|
|
<span class="sym">🔊</span>
|
|
|
{{ $t('params.hasSubwoofer') }}
|
|
{{ $t('params.hasSubwoofer') }}
|
|
|
</div>
|
|
</div>
|
|
|
- <NCheckbox :model-value="isExtension" @update:checked="onToggleExtension">
|
|
|
|
|
|
|
+ <NCheckbox v-model:checked="isExtension" @update:checked="onToggleExtension">
|
|
|
{{ $t('params.hasSubwooferOn') }}
|
|
{{ $t('params.hasSubwooferOn') }}
|
|
|
</NCheckbox>
|
|
</NCheckbox>
|
|
|
</div>
|
|
</div>
|
|
@@ -149,8 +193,9 @@ const fields: FieldConfig[] = [
|
|
|
<div class="spl-mode-hint">{{ $t('params.splMaxAuto') }}</div>
|
|
<div class="spl-mode-hint">{{ $t('params.splMaxAuto') }}</div>
|
|
|
</div>
|
|
</div>
|
|
|
<n-radio-group
|
|
<n-radio-group
|
|
|
- v-model:value="splMax"
|
|
|
|
|
|
|
+ v-model:value="powerMode"
|
|
|
:options="powerModeOptions"
|
|
:options="powerModeOptions"
|
|
|
|
|
+ value-field="label"
|
|
|
@update:value="onSelectPowerMode"
|
|
@update:value="onSelectPowerMode"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|