|
@@ -26,6 +26,14 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <div class="li" @click="getTTS">
|
|
|
+ <div class="liBox">
|
|
|
+ <div class="pic"><img src="@/assets/images/common/set1.png"></div>
|
|
|
+ <div class="name">
|
|
|
+ 用{{ ttsState ? '系统' : '百度' }}TTS
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="li" @click="getLogout">
|
|
|
<div class="liBox">
|
|
|
<div class="pic"><img src="@/assets/images/common/set2.png"></div>
|
|
@@ -47,14 +55,16 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="SetIndex" lang="ts">
|
|
|
+import Speech from 'speak-tts';
|
|
|
const { proxy } = getCurrentInstance() as any;
|
|
|
const router = useRouter();
|
|
|
const data = reactive<any>({
|
|
|
vConsoleState: true,
|
|
|
rankingSwitch1: true,
|
|
|
+ ttsState: false,
|
|
|
});
|
|
|
|
|
|
-const { vConsoleState, rankingSwitch1 } = toRefs(data);
|
|
|
+const { vConsoleState, rankingSwitch1, ttsState } = toRefs(data);
|
|
|
|
|
|
//设置
|
|
|
const getConfig = () => {
|
|
@@ -118,6 +128,37 @@ const getRanking = () => {
|
|
|
}, 1000)
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * TTS切换
|
|
|
+*/
|
|
|
+const getTTS = () => {
|
|
|
+ proxy?.$modal.loading();
|
|
|
+ let state = localStorage.getItem('ttsState');
|
|
|
+ if (state == "1") {
|
|
|
+ localStorage.setItem('ttsState', "0");
|
|
|
+ ttsState.value = false;
|
|
|
+ let speech = new Speech();
|
|
|
+ if (!speech.hasBrowserSupport()) {
|
|
|
+ proxy?.$modal.msgWarning(`不支持TTS,建议切换百度TTS`);
|
|
|
+ } else {
|
|
|
+ proxy?.$modal.msgSuccess('已设为系统TTS');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ localStorage.setItem('ttsState', "1");
|
|
|
+ ttsState.value = true;
|
|
|
+ proxy?.$modal.msgSuccess('已设为百度TTS');
|
|
|
+ proxy?.$http.common.baiduToken({}).then((res: any) => {
|
|
|
+ let tok = res.token;
|
|
|
+ localStorage.setItem('tok', tok);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ proxy?.$modal?.closeLoading()
|
|
|
+ window.location.reload()
|
|
|
+ }, 1000)
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 返回
|
|
@@ -146,6 +187,12 @@ onMounted(() => {
|
|
|
} else {
|
|
|
rankingSwitch1.value = false;
|
|
|
}
|
|
|
+ let state3 = localStorage.getItem('ttsState');
|
|
|
+ if (state3 == "1") {
|
|
|
+ ttsState.value = true;
|
|
|
+ } else {
|
|
|
+ ttsState.value = false;
|
|
|
+ }
|
|
|
})
|
|
|
</script>
|
|
|
|