Skip to content

Commit

Permalink
fix(monkey): options to set fetch all posts
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Feb 26, 2024
1 parent df38ce8 commit 1901b2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
13 changes: 12 additions & 1 deletion apps/monkey/src/Config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ const dateRange = computed({
configStore.state.dateRange = val ?? []
},
})
configStore.setConfig({ now: Date.now() })
</script>

<template>
<div class="flex flex-col gap-3">
<p class="text-black">
<p class="text-black!">
请选择要存档的范围,默认为所有微博
</p>

Expand All @@ -26,6 +28,15 @@ const dateRange = computed({
/>

<div class="center flex-wrap justify-start gap-2">
<button
class="bg-#18a058 py-1 btn hover:bg-green-7"
@click="() => {
const { now } = configStore.state
dateRange = [now, now]
}"
>
重置为所有微博
</button>
<n-checkbox
v-model:checked="configStore.state.picLarge"
label="导出原图"
Expand Down
7 changes: 4 additions & 3 deletions apps/monkey/src/stores/configStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ export const useConfigStore = defineStore('config', () => {
const state = reactive<FetchOptions>(localData
? JSON.parse(localData)
: {
now,
uid: '',
name: '',
cookie: document.cookie,
cookie: '',
isFetchAll: true,
picLarge: true,
repostPic: true,
Expand All @@ -25,8 +26,8 @@ export const useConfigStore = defineStore('config', () => {
Object.assign(state, config)
}

watch(() => state.dateRange, (newVal) => {
state.isFetchAll = newVal.every(v => v === now)
watchImmediate(() => state.dateRange, (newVal) => {
state.isFetchAll = newVal.every(v => v === state.now)
})

watchEffect(() => {
Expand Down
2 changes: 2 additions & 0 deletions types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export interface FetchOptions {
*/
cookie: string

now: number

/**
* 是否获取全部微博
*/
Expand Down

0 comments on commit 1901b2e

Please sign in to comment.