Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 Show original article url. #83

Merged
merged 1 commit into from
Oct 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading