-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from tolerious/feat/the-guardian-support
Feat/the guardian support
- Loading branch information
Showing
8 changed files
with
241 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
{ | ||
"files.autoSave": "afterDelay", | ||
"editor.bracketPairColorization.independentColorPoolPerBracketType": true | ||
"editor.bracketPairColorization.independentColorPoolPerBracketType": true, | ||
"cSpell.words": [ | ||
"dsense", | ||
"FUIYOH", | ||
"HIYAA", | ||
"thisweek", | ||
"usersetting", | ||
"wordgroup", | ||
"wordlist" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<template> | ||
<Header :title="'Reading Article'" @go-back="handleGoBack" /> | ||
<div class="px-3 py-2" v-if="articleList.length > 0"> | ||
<span | ||
@click="handleGenerateAllQuestionsAnswers" | ||
class="px-2 py-1 bg-cyan-400 select-none cursor-pointer active:shadow-sm active:shadow-cyan-600 rounded" | ||
>一键生成</span | ||
> | ||
<div v-for="article in articleList" :key="article._id"> | ||
<div class="my-3 font-bold text-lg">{{ article._id }}</div> | ||
<div | ||
@click="handleGoToArticleDetail(i._id)" | ||
class="px-1 py-2 bg-slate-50 mb-2 cursor-pointer" | ||
v-for="i in article.documents" | ||
:key="i" | ||
> | ||
<div @click.stop class="cursor-auto">{{ i.title }}</div> | ||
<div class="flex items-center" v-if="i.questions"> | ||
<div class="h-2 w-5 bg-green-300"></div> | ||
<div class="ml-1"><span>问题已生成</span></div> | ||
</div> | ||
<div class="flex items-center" v-else> | ||
<div class="h-2 w-5 bg-red-500"></div> | ||
<div class="ml-1"><span>问题未生成</span></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<el-empty description="暂无数据,请访问The Guardian网站,阅读新闻,系统会自动添加。" v-else /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import Header from '@/components/Header.vue'; | ||
import { request } from '@/utils/service'; | ||
import { onMounted, ref } from 'vue'; | ||
import { useRouter } from 'vue-router'; | ||
const router = useRouter(); | ||
const articleList = ref([]); | ||
async function handleGenerateAllQuestionsAnswers() { | ||
let availableList = []; | ||
articleList.value.forEach(article => { | ||
article.documents.forEach(doc => { | ||
if (!doc.questions) { | ||
availableList.push(doc._id); | ||
} | ||
}); | ||
}); | ||
console.log(availableList); | ||
for (let i = 0; i < availableList.length; i++) { | ||
const r = await request({ url: '/deepseek', method: 'post', data: { articleId: availableList[i] } }); | ||
console.log(r); | ||
} | ||
} | ||
function handleGoToArticleDetail(id) { | ||
router.push(`/reading/${id}`); | ||
} | ||
async function getGuardianArticles() { | ||
const r = await request({ url: '/article/guardian' }); | ||
console.log(r); | ||
articleList.value = r.data; | ||
} | ||
function handleGoBack() { | ||
router.go(-1); | ||
} | ||
onMounted(() => { | ||
getGuardianArticles(); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<template> | ||
<Header :title="'Reading Article Detail'" @go-back="handleGoBack" /> | ||
<div class="px-3 py-3 bg-slate-50"> | ||
<h1 class="text-center text-xl font-bold">{{ articleDetail.title }}</h1> | ||
<div class="mx-2 flex gap-2 my-5 text-slate-500"> | ||
<div class="bg-cyan-500 h-full w-1"> </div> | ||
<div>{{ articleDetail.summary }}</div> | ||
</div> | ||
<div> | ||
<p class="text-lg mx-2 my-4" v-for="pp in articleDetail.content" :key="pp">{{ pp }}</p> | ||
</div> | ||
<div class="flex gap-2 items-center"> | ||
<a class="px-2 py-1 bg-cyan-500 cursor-pointer round rounded text-white" @click="handleOriginalUrl" | ||
>原文链接</a | ||
> | ||
<div | ||
@click="generateQuestions" | ||
class="cursor-pointer active:shadow active:shadow-slate-400 px-2 py-1 bg-pink-500 rounded text-white" | ||
> | ||
生成问题 | ||
</div> | ||
<div | ||
@click="displayAnswers" | ||
class="cursor-pointer active:shadow active:shadow-slate-400 px-2 py-1 bg-pink-500 rounded text-white" | ||
> | ||
查看答案 | ||
</div> | ||
<div | ||
@click="refreshPage" | ||
class="cursor-pointer active:shadow active:shadow-slate-400 px-2 py-1 bg-pink-500 rounded text-white" | ||
> | ||
刷新页面 | ||
</div> | ||
</div> | ||
<div class="mt-16"> | ||
<div class="font-bold">Questions:</div> | ||
<p class="whitespace-pre-wrap">{{ articleDetail.questions }}</p> | ||
</div> | ||
<div class="mt-16" v-if="isAnswersVisible"> | ||
<div class="font-bold">Answers:</div> | ||
<p class="whitespace-pre-wrap">{{ articleDetail.answers }}</p> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import Header from '@/components/Header.vue'; | ||
import { request } from '@/utils/service'; | ||
import { ElNotification } from 'element-plus'; | ||
import { onMounted, ref } from 'vue'; | ||
import { useRoute, useRouter } from 'vue-router'; | ||
const router = useRouter(); | ||
const route = useRoute(); | ||
const articleDetail = ref({}); | ||
const isAnswersVisible = ref(false); | ||
function refreshPage(){ | ||
window.location.reload(); | ||
} | ||
function displayAnswers() { | ||
isAnswersVisible.value = !isAnswersVisible.value; | ||
} | ||
function handleOriginalUrl() { | ||
window.open(articleDetail.value.originalUrl); | ||
} | ||
function handleGoBack() { | ||
router.go(-1); | ||
} | ||
async function getArticleDetail(id) { | ||
const r = await request({ url: '/article/guardian/' + id }); | ||
console.log(r); | ||
return r; | ||
} | ||
async function generateQuestions() { | ||
const r = await request({ url: '/deepseek', method: 'post', data: { articleId: articleDetail.value._id } }); | ||
console.log(r); | ||
if (r.code === 200) { | ||
ElNotification({ type: 'success', title: '问题已生成' }); | ||
} else { | ||
ElNotification({ type: 'error', title: '问题生成失败,请重试' }); | ||
} | ||
} | ||
onMounted(async () => { | ||
const id = route.params.articleID; | ||
console.log(id); | ||
const t = await getArticleDetail(id); | ||
articleDetail.value = t.data; | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters