File tree Expand file tree Collapse file tree 12 files changed +37
-40
lines changed Expand file tree Collapse file tree 12 files changed +37
-40
lines changed Original file line number Diff line number Diff line change 15
15
"@dnd-kit/core" : " 6.3.1" ,
16
16
"@dnd-kit/sortable" : " 10.0.0" ,
17
17
"@electron-toolkit/preload" : " 3.0.2" ,
18
+ "@follow/database" : " workspace:*" ,
18
19
"@follow/electron-main" : " workspace:*" ,
19
20
"@follow/shared" : " workspace:*" ,
20
21
"@follow/store" : " workspace:*" ,
48
49
"cmdk" : " 1.1.1" ,
49
50
"dayjs" : " 1.11.13" ,
50
51
"dexie" : " 4.0.11" ,
51
- "dexie-export-import" : " 4.1.4" ,
52
52
"dnum" : " 2.15.0" ,
53
53
"embla-carousel-react" : " 8.6.0" ,
54
54
"embla-carousel-wheel-gestures" : " 8.0.2" ,
Original file line number Diff line number Diff line change @@ -79,16 +79,6 @@ class BrowserDB extends Dexie {
79
79
80
80
export const browserDB = new BrowserDB ( )
81
81
82
- export const exportDB = async ( ) => {
83
- await import ( "dexie-export-import" )
84
- const blob = await browserDB . export ( { prettyJson : true } )
85
- const url = URL . createObjectURL ( blob )
86
- const a = document . createElement ( "a" )
87
- a . href = url
88
- a . download = `${ LOCAL_DB_NAME } .json`
89
- a . click ( )
90
- }
91
-
92
82
// ================================================ //
93
83
// ================================================ //
94
84
// ================================================ //
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { Input } from "@follow/components/ui/input/Input.js"
13
13
import { Label } from "@follow/components/ui/label/index.jsx"
14
14
import { RadioGroup , RadioGroupItem } from "@follow/components/ui/radio-group/motion.js"
15
15
import { Slider } from "@follow/components/ui/slider/index.js"
16
+ import { exportDB } from "@follow/database/db"
16
17
import { ELECTRON_BUILD } from "@follow/shared/constants"
17
18
import { env } from "@follow/shared/env.desktop"
18
19
import { zodResolver } from "@hookform/resolvers/zod"
@@ -24,7 +25,6 @@ import { z } from "zod"
24
25
25
26
import { setGeneralSetting , useGeneralSettingValue } from "~/atoms/settings/general"
26
27
import { useDialog , useModalStack } from "~/components/ui/modal/stacked/hooks"
27
- import { exportDB } from "~/database"
28
28
import { ipcServices } from "~/lib/client"
29
29
import { queryClient } from "~/lib/query-client"
30
30
import { clearLocalPersistStoreData } from "~/store/utils/clear"
Original file line number Diff line number Diff line change 1
- import { initializeDb } from "@follow/database/db"
1
+ import { initializeDB } from "@follow/database/db"
2
2
import { hydrateDatabaseToStore } from "@follow/store/hydrate"
3
3
import { tracker } from "@follow/tracker"
4
4
import { nativeApplicationVersion } from "expo-application"
@@ -21,7 +21,7 @@ export const initializeApp = async () => {
21
21
const now = Date . now ( )
22
22
23
23
await initDeviceType ( )
24
- initializeDb ( )
24
+ initializeDB ( )
25
25
26
26
await apm ( "migrateDatabase" , migrateDatabase )
27
27
initializeDayjs ( )
Original file line number Diff line number Diff line change 1
- import { migrateDb } from "@follow/database/db"
1
+ import { migrateDB } from "@follow/database/db"
2
2
import { useSyncExternalStore } from "react"
3
3
4
4
let storeChangeFn : ( ) => void
@@ -16,7 +16,7 @@ const migrateStore = {
16
16
17
17
export const migrateDatabase = async ( ) => {
18
18
try {
19
- await migrateDb ( )
19
+ await migrateDB ( )
20
20
migrateStore . success = true
21
21
storeChangeFn ?.( )
22
22
} catch ( error ) {
Original file line number Diff line number Diff line change 214
214
"general.export_data.title" : " Export Data" ,
215
215
"general.export_database.button" : " Export" ,
216
216
"general.export_database.description" : " Export all your data, including articles (Full Backup)." ,
217
- "general.export_database.label" : " Export Database (JSON) " ,
217
+ "general.export_database.label" : " Export Database" ,
218
218
"general.group_by_date.description" : " Group entries by date." ,
219
219
"general.group_by_date.label" : " Group by date" ,
220
220
"general.hide_all_read_subscriptions.description" : " Hide subscriptions without unread entries in the subscription list." ,
Original file line number Diff line number Diff line change 206
206
"general.export_data.title" : " 导出数据" ,
207
207
"general.export_database.button" : " 导出" ,
208
208
"general.export_database.description" : " 导出你的所有数据,包括文章(完整备份)。" ,
209
- "general.export_database.label" : " 导出数据库 (JSON) " ,
209
+ "general.export_database.label" : " 导出数据库" ,
210
210
"general.group_by_date.description" : " 按日期对条目进行分组。" ,
211
211
"general.group_by_date.label" : " 按日期分组" ,
212
212
"general.hide_all_read_subscriptions.description" : " 在订阅列表中隐藏没有未读条目的订阅。" ,
Original file line number Diff line number Diff line change @@ -21,15 +21,15 @@ export const sqlite = new SQLocalDrizzle(dbName)
21
21
22
22
let db : SqliteRemoteDatabase < typeof schema >
23
23
24
- export function initializeDb ( ) {
24
+ export function initializeDB ( ) {
25
25
db = drizzle ( sqlite . driver , sqlite . batchDriver , {
26
26
schema,
27
27
logger : false ,
28
28
} )
29
29
}
30
30
export { db }
31
31
32
- export async function migrateDb ( ) {
32
+ export async function migrateDB ( ) {
33
33
try {
34
34
await migrate ( db , migrations )
35
35
} catch ( error ) {
@@ -39,3 +39,16 @@ export async function migrateDb() {
39
39
await migrate ( db , migrations )
40
40
}
41
41
}
42
+
43
+ export async function exportDB ( ) {
44
+ const databaseFile = await sqlite . getDatabaseFile ( )
45
+ const fileUrl = URL . createObjectURL ( databaseFile )
46
+
47
+ const a = document . createElement ( "a" )
48
+ a . href = fileUrl
49
+ a . download = "database.sqlite3"
50
+ a . click ( )
51
+ a . remove ( )
52
+
53
+ URL . revokeObjectURL ( fileUrl )
54
+ }
Original file line number Diff line number Diff line change @@ -13,15 +13,15 @@ let db: ExpoSQLiteDatabase<typeof schema> & {
13
13
$client : SQLite . SQLiteDatabase
14
14
}
15
15
16
- export function initializeDb ( ) {
16
+ export function initializeDB ( ) {
17
17
db = drizzle ( sqlite , {
18
18
schema,
19
19
logger : false ,
20
20
} )
21
21
}
22
22
export { db }
23
23
24
- export async function migrateDb ( ) : Promise < void > {
24
+ export async function migrateDB ( ) : Promise < void > {
25
25
try {
26
26
await migrate ( db , migrations )
27
27
} catch ( error ) {
@@ -33,7 +33,9 @@ export async function migrateDb(): Promise<void> {
33
33
}
34
34
await SQLite . deleteDatabaseAsync ( SQLITE_DB_NAME )
35
35
sqlite = SQLite . openDatabaseSync ( SQLITE_DB_NAME )
36
- initializeDb ( )
36
+ initializeDB ( )
37
37
await migrate ( db , migrations )
38
38
}
39
39
}
40
+
41
+ export async function exportDB ( ) { }
Original file line number Diff line number Diff line change @@ -2,5 +2,6 @@ import type { DB } from "./types"
2
2
3
3
export declare const sqlite : unknown
4
4
export declare const db : DB
5
- export declare function initializeDb ( ) : void
6
- export declare function migrateDb ( ) : Promise < void >
5
+ export declare function initializeDB ( ) : void
6
+ export declare function migrateDB ( ) : Promise < void >
7
+ export declare function exportDB ( ) : Promise < Blob >
You can’t perform that action at this time.
0 commit comments