Skip to content

Commit

Permalink
fix: rename exported data to 'weibo-data.json'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Mar 1, 2024
1 parent dfa1710 commit 8034e40
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 23 deletions.
5 changes: 2 additions & 3 deletions apps/monkey/src/utils/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export function exportData(posts: Post[]) {
// https://github.com/Stuk/jszip/issues/864
const zip = new JSZip()

const data = `export const _ = ${JSON.stringify(posts)}`
zip.file('data.mjs', data)
const data = JSON.stringify(posts)
zip.file('weibo-data.json', data)

const imgsData = Array
.from(imgsParser(posts))
Expand All @@ -42,7 +42,6 @@ export function exportData(posts: Post[]) {
zip
.generateAsync({ type: 'blob' })
.then((zipFile) => {
// @ts-expect-error is defined
window.$message.success('导出成功,正在下载数据...')
saveAs(zipFile, 'weibo-archiver.zip')
})
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/stores/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const usePostStore = defineStore('post', () => {
data: Post[],
replace = false,
) {
if (!data[0]?.user)
throw new Error('数据格式错误')

if (replace) {
posts.value = data
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/settings/base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ function exportData() {
<n-upload
:custom-request="onImportData"
:max="1"
accept=".mjs,.json"
directory-dnd
accept=".mjs"
>
<n-button>
点击导入
Expand Down
19 changes: 0 additions & 19 deletions scripts/merge.mjs

This file was deleted.

0 comments on commit 8034e40

Please sign in to comment.