Skip to content

Commit

Permalink
🚧 Fix cros issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
tolerious committed Sep 8, 2024
1 parent a1c0a7d commit ff81a90
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/webPage/translationFloatingPanel/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
</template>

<script setup lang="ts">
import axios from 'axios';
import { computed, onMounted, ref, watch, type Ref } from 'vue';
import { ADD_PHRASE, DELETE_WORD, GET_WORD_ID, SAVE_WORD, SEARCH_WORD } from './constants';
import { ADD_PHRASE, DELETE_WORD, GET_WORD_ID, SAVE_WORD, SEARCH_WORD, YOUDAO } from './constants';
import { customPost } from './utils/customRequest';
interface CustomEvent extends Event {
Expand Down Expand Up @@ -125,8 +126,16 @@ function goToCambridgeWebsite() {
window.open(`https://dictionary.cambridge.org/dictionary/english/${currentWord.value}`);
}
function handleClick() {
audioUrl.value = `https://dict.youdao.com/dictvoice?type=1&audio=${currentWord.value}`;
async function handleClick() {
const response = await axios({
url: `${import.meta.env.VITE_BACKEND_URL}${YOUDAO}`, // 后端 API
method: 'POST',
data: { word: currentWord.value },
responseType: 'blob' // 获取音频为 Blob
});
const audioBlob = response.data;
const u = URL.createObjectURL(audioBlob);
audioUrl.value = u;
audioPlayer.value?.play();
}
Expand Down
2 changes: 2 additions & 0 deletions src/webPage/translationFloatingPanel/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ export const SEARCH_WORD = '/word/search';
export const ADD_PHRASE = '/phrase';

export const USER_SETTING = '/usersetting';

export const YOUDAO = '/youdao/';

0 comments on commit ff81a90

Please sign in to comment.