Skip to content

Commit

Permalink
🚧 Show original article url.
Browse files Browse the repository at this point in the history
  • Loading branch information
tolerious committed Oct 19, 2024
1 parent e23ce1f commit 4f8e77a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/views/FlashCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { ElNotification } from 'element-plus';
import { computed, onMounted, ref, type Ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const buttonTexts = ['上一个', '下一个'];
const buttonTexts = ['上一个', '文章链接', '下一个'];
const route = useRoute();
const router = useRouter();
Expand All @@ -65,6 +65,7 @@ const isTranslationVisible = ref(false);
const wordList: Ref<Word[]> = ref([]);
const currentIndex = ref(0);
const currentTranslation = ref();
const originalPageUrl = ref('');
const currentWord = computed(() => wordList.value[currentIndex.value] ?? { en: '' });
Expand All @@ -74,6 +75,7 @@ onMounted(async () => {
if (currentWord.value.en) {
await getTranslation(currentWord.value.en);
}
await getGroupDetail();
});
async function getWordList() {
Expand All @@ -91,6 +93,11 @@ function handleGoBack() {
router.go(-1);
}
async function getGroupDetail() {
const info = await request({ url: '/wordgroup/detail', method: 'post', data: { groupID: groupId.value } });
originalPageUrl.value = info.data.originalPageUrl;
}
function navigateWord(text: string) {
if (text === '上一个') {
if (currentIndex.value != 0) {
Expand All @@ -108,6 +115,11 @@ function navigateWord(text: string) {
ElNotification({ type: 'info', title: '单词已学完', message: '选择其他词组继续学习吧' });
}
}
if (text === '文章链接') {
if (originalPageUrl.value) {
window.open(`http://${originalPageUrl.value}`, '_blank');
}
}
isTranslationVisible.value = false;
}
</script>
Expand Down

0 comments on commit 4f8e77a

Please sign in to comment.