From 0c6499a56a5fe33023d871e9a90610e09d5e83a3 Mon Sep 17 00:00:00 2001 From: zyronon Date: Mon, 7 Aug 2023 02:03:05 +0800 Subject: [PATCH] SAve --- src/App.vue | 59 ++---------------------------- src/components/HelloWorld.vue | 38 ------------------- src/components/WordList.vue | 69 +++++++++++++++++++++++++++++++++++ src/hooks/usePlayWordAudio.ts | 21 +++++++++++ src/types.ts | 2 + 5 files changed, 96 insertions(+), 93 deletions(-) delete mode 100644 src/components/HelloWorld.vue create mode 100644 src/components/WordList.vue create mode 100644 src/hooks/usePlayWordAudio.ts diff --git a/src/App.vue b/src/App.vue index 7579ebec..d0dd49c0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,6 +14,7 @@ import {$ref} from "vue/macros" import {useSound} from "@/hooks/useSound.ts" import {useBaseStore} from "@/stores/base.ts" import {SaveKey} from "./types"; +import WordList from "./components/WordList.vue"; let input = $ref('') let wrong = $ref('') @@ -190,25 +191,9 @@ const step = $ref(1)
关闭
-
-
-
-
-
{{ item.name }}
-
-
{{ item.trans.join(';') }}
-
{{ item.usphone }}
-
-
+ -
-
播放
-
删除
-
-
-
-
-
+
六级
@@ -425,6 +410,7 @@ const step = $ref(1) .chapter-list { .chapter-item { + cursor: pointer; margin-bottom: 10rem; padding: 10rem; border-radius: 10rem; @@ -433,43 +419,6 @@ const step = $ref(1) } } - .new-words { - - .list { - display: flex; - flex-direction: column; - - .item { - margin: 10rem; - border-radius: 10rem; - padding: 10rem; - border: 1px solid blue; - display: flex; - justify-content: space-between; - - .left { - .letter { - margin-bottom: 10rem; - font-size: 24rem; - line-height: 1; - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace; - display: flex; - } - - .info { - display: flex; - gap: 20rem - } - } - - .right { - display: flex; - flex-direction: column; - justify-content: space-between; - } - } - } - } } diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index 7b25f3f2..00000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - - - diff --git a/src/components/WordList.vue b/src/components/WordList.vue new file mode 100644 index 00000000..8040a1f3 --- /dev/null +++ b/src/components/WordList.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/src/hooks/usePlayWordAudio.ts b/src/hooks/usePlayWordAudio.ts new file mode 100644 index 00000000..30e10911 --- /dev/null +++ b/src/hooks/usePlayWordAudio.ts @@ -0,0 +1,21 @@ +import {PronunciationApi} from "../types"; + +export function usePlayWordAudio() { + const audio = $ref(new Audio()) + + function generateWordSoundSrc(word: string, pronunciation: string) { + switch (pronunciation) { + case 'uk': + return `${PronunciationApi}${word}&type=1` + case 'us': + return `${PronunciationApi}${word}&type=2` + } + } + + function playAudio(word: string) { + audio.src = generateWordSoundSrc(word, 'us') + audio.play() + } + + return [playAudio] +} diff --git a/src/types.ts b/src/types.ts index 9522f55e..95957e13 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,3 +9,5 @@ export type Config = { export type Word = { "name": string, "usphone": string, "ukphone": string, "trans": string[] } export const SaveKey = 'bb-word-config' + +export const PronunciationApi = 'https://dict.youdao.com/dictvoice?audio='