wangzhibo
2026-10-08 220e4fab27b7f419b3e89e2f2d28ae789aac09d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<route lang="jsonc" type="page">
{
  "layout": "default",
  "style": {
    "navigationBarTitleText": "语音设置",
    "navigationStyle": "custom"
  }
}
</route>
 
<script lang="ts" setup>
import { t } from '@/i18n'
import { useSpeedPitch } from '@/store'
 
defineOptions({
  name: 'SpeedPitch',
})
 
const speedPitchStore = useSpeedPitch()
const SPEED_PITCH_FIELDS = ['ttsVolume', 'ttsRate', 'ttsPitch'] as const
 
const localSettings = ref({
  ttsVolume: 0,
  ttsRate: 0,
  ttsPitch: 0,
})
 
function handleConfirm() {
  const changedFields = SPEED_PITCH_FIELDS.filter((field) => {
    return localSettings.value[field] !== speedPitchStore.speedPitch[field]
  })
  speedPitchStore.updateSpeedPitch(localSettings.value, { changedFields })
  goBack()
}
 
// 返回上一页并更新配置
function goBack() {
  uni.navigateBack()
}
 
onMounted(() => {
  localSettings.value = {
    ttsVolume: speedPitchStore.speedPitch.ttsVolume,
    ttsRate: speedPitchStore.speedPitch.ttsRate,
    ttsPitch: speedPitchStore.speedPitch.ttsPitch,
  }
})
</script>
 
<template>
  <view class="h-screen flex flex-col bg-[#f5f7fb]">
    <!-- 头部导航 -->
    <wd-navbar
      :title="t('agent.languageConfig')"
      safe-area-inset-top
      left-arrow
      :bordered="false"
      @click-left="goBack"
    >
      <template #left>
        <wd-icon name="arrow-left" size="18" />
      </template>
    </wd-navbar>
    <view class="flex flex-1 flex-col overflow-hidden">
      <view class="flex flex-1 flex-col gap-[50rpx] overflow-y-auto px-[40rpx] py-[50rpx]">
        <!-- 音量调节 -->
        <view class="flex flex-col gap-[20rpx]">
          <text class="text-[30rpx] text-[#232338] font-semibold">
            {{ t('agent.ttsVolume') }}
          </text>
          <view class="flex items-center gap-[20rpx]">
            <wd-slider
              v-model="localSettings.ttsVolume"
              :min="-100"
              :max="100"
              :step="1"
              :show-value="false"
              custom-class="voice-slider"
              class="flex-1"
            />
            <text class="min-w-[80rpx] text-right text-[28rpx] text-[#336cff] font-medium">
              {{ localSettings.ttsVolume }}
            </text>
          </view>
          <text class="mt-[10rpx] text-[24rpx] text-[#9d9ea3]">
            {{ t('agent.volumeHint') }}
          </text>
        </view>
 
        <!-- 语速调节 -->
        <view class="flex flex-col gap-[20rpx]">
          <text class="text-[30rpx] text-[#232338] font-semibold">
            {{ t('agent.ttsRate') }}
          </text>
          <view class="flex items-center gap-[20rpx]">
            <wd-slider
              v-model="localSettings.ttsRate"
              :min="-100"
              :max="100"
              :step="1"
              :show-value="false"
              custom-class="voice-slider"
              class="flex-1"
            />
            <text class="min-w-[80rpx] text-right text-[28rpx] text-[#336cff] font-medium">
              {{ localSettings.ttsRate }}
            </text>
          </view>
          <text class="mt-[10rpx] text-[24rpx] text-[#9d9ea3]">
            {{ t('agent.speedHint') }}
          </text>
        </view>
 
        <!-- 音调调节 -->
        <view class="flex flex-col gap-[20rpx]">
          <text class="text-[30rpx] text-[#232338] font-semibold">
            {{ t('agent.ttsPitch') }}
          </text>
          <view class="flex items-center gap-[20rpx]">
            <wd-slider
              v-model="localSettings.ttsPitch"
              :min="-100"
              :max="100"
              :step="1"
              :show-value="false"
              custom-class="voice-slider"
              class="flex-1"
            />
            <text class="min-w-[80rpx] text-right text-[28rpx] text-[#336cff] font-medium">
              {{ localSettings.ttsPitch }}
            </text>
          </view>
          <text class="mt-[10rpx] text-[24rpx] text-[#9d9ea3]">
            {{ t('agent.pitchHint') }}
          </text>
        </view>
      </view>
 
      <view class="flex gap-[20rpx] border-t border-[#eee] px-[30rpx] py-[30rpx]">
        <wd-button type="primary" class="h-[80rpx] flex-1 rounded-[12rpx] text-[28rpx] !bg-[#336cff]" @click="handleConfirm">
          {{ t('agent.save') }}
        </wd-button>
      </view>
    </view>
  </view>
</template>
 
<style scoped lang="scss">
/* 自定义滑块样式 */
:deep(.wd-slider) {
  --wd-slider-bar-background: #e6ebff;
  --wd-slider-bar-active-background: #336cff;
  --wd-slider-thumb-border-color: #336cff;
  --wd-slider-thumb-background: #336cff;
  --wd-slider-thumb-size: 32rpx;
}
</style>