create-lupine 1.0.29 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +431 -411
- package/package.json +17 -17
- package/templates/common/.env.development +7 -7
- package/templates/common/.env.mobile +9 -9
- package/templates/common/.env.production +7 -7
- package/templates/common/_env +66 -58
- package/templates/common/_gitignore +25 -25
- package/templates/common/apps/server/src/index.ts +79 -76
- package/templates/common/apps/server/src/server-env-keys.ts +0 -9
- package/templates/common/dev/cp-folder.js +45 -45
- package/templates/common/tsconfig.json +128 -128
- package/templates/lupine-template-cv-starter/api/package.json +5 -5
- package/templates/lupine-template-cv-starter/api/resources/config_default.json +6 -6
- package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-cv-starter/api/src/index.ts +15 -15
- package/templates/lupine-template-cv-starter/lupine.json +39 -39
- package/templates/lupine-template-cv-starter/web/markdown/en/01-experience/index.md +32 -32
- package/templates/lupine-template-cv-starter/web/markdown/en/02-projects/index.md +36 -36
- package/templates/lupine-template-cv-starter/web/markdown/en/03-skills/index.md +28 -28
- package/templates/lupine-template-cv-starter/web/markdown/en/04-education/index.md +16 -16
- package/templates/lupine-template-cv-starter/web/markdown/en/index.md +41 -41
- package/templates/lupine-template-cv-starter/web/markdown/index.md +7 -7
- package/templates/lupine-template-cv-starter/web/markdown/zh/01-experience/index.md +32 -32
- package/templates/lupine-template-cv-starter/web/markdown/zh/02-projects/index.md +36 -36
- package/templates/lupine-template-cv-starter/web/markdown/zh/03-skills/index.md +28 -28
- package/templates/lupine-template-cv-starter/web/markdown/zh/04-education/index.md +17 -17
- package/templates/lupine-template-cv-starter/web/markdown/zh/index.md +41 -41
- package/templates/lupine-template-cv-starter/web/package.json +5 -5
- package/templates/lupine-template-cv-starter/web/src/client-env-keys.ts +5 -5
- package/templates/lupine-template-cv-starter/web/src/index.html +16 -16
- package/templates/lupine-template-cv-starter/web/src/index.tsx +28 -28
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/404.html +38 -38
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +73 -73
- package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +30 -30
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/01-experience/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/02-projects/index.html +28 -28
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/03-skills/index.html +18 -18
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/04-education/index.html +10 -10
- package/templates/lupine-template-cv-starter/web/src/markdown-built/en/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/01-experience/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/02-projects/index.html +28 -28
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/03-skills/index.html +18 -18
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/04-education/index.html +11 -11
- package/templates/lupine-template-cv-starter/web/src/markdown-built/zh/index.html +20 -20
- package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +15 -15
- package/templates/lupine-template-doc-starter/api/package.json +5 -5
- package/templates/lupine-template-doc-starter/api/resources/config_default.json +6 -6
- package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-doc-starter/api/src/index.ts +15 -15
- package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +6 -6
- package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-doc-starter/lupine.json +39 -39
- package/templates/lupine-template-doc-starter/web/markdown/en/essentials/index.md +6 -6
- package/templates/lupine-template-doc-starter/web/markdown/en/essentials/list.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/en/guide/install.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/en/guide/started.md +22 -22
- package/templates/lupine-template-doc-starter/web/markdown/en/index.md +42 -42
- package/templates/lupine-template-doc-starter/web/markdown/index.md +7 -7
- package/templates/lupine-template-doc-starter/web/markdown/zh/essentials/index.md +6 -6
- package/templates/lupine-template-doc-starter/web/markdown/zh/essentials/list.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/zh/guide/install.md +18 -18
- package/templates/lupine-template-doc-starter/web/markdown/zh/guide/started.md +22 -22
- package/templates/lupine-template-doc-starter/web/markdown/zh/index.md +42 -42
- package/templates/lupine-template-doc-starter/web/package.json +5 -5
- package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +5 -5
- package/templates/lupine-template-doc-starter/web/src/index.html +16 -16
- package/templates/lupine-template-doc-starter/web/src/index.tsx +28 -28
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/404.html +38 -38
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +27 -27
- package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +30 -30
- package/templates/lupine-template-doc-starter/web/src/markdown-built/en/essentials/list.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/en/guide/install.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/en/guide/started.html +12 -12
- package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/essentials/list.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/guide/install.html +8 -8
- package/templates/lupine-template-doc-starter/web/src/markdown-built/zh/guide/started.html +12 -12
- package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +15 -15
- package/templates/lupine-template-hello-world/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-hello-world/api/src/index.ts +4 -4
- package/templates/lupine-template-hello-world/api/src/service/root-api.ts +18 -18
- package/templates/lupine-template-hello-world/lupine.json +22 -22
- package/templates/lupine-template-hello-world/web/package.json +6 -6
- package/templates/lupine-template-hello-world/web/src/index.html +16 -16
- package/templates/lupine-template-hello-world/web/src/index.tsx +73 -73
- package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +3 -3
- package/templates/lupine-template-responsive-starter/api/src/index.ts +4 -4
- package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +18 -18
- package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +76 -76
- package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +93 -93
- package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +86 -86
- package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +80 -80
- package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +220 -219
- package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +119 -119
- package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +116 -116
- package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +154 -154
- package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +193 -193
- package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +95 -95
- package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +182 -182
- package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +52 -52
- package/templates/lupine-template-responsive-starter/web/src/index.html +16 -16
- package/templates/lupine-template-responsive-starter/web/src/index.tsx +39 -39
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/404.html +35 -35
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +49 -49
- package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +32 -32
- package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +43 -43
- package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +46 -46
- package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +452 -452
- package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +325 -325
- package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +46 -46
- package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +87 -87
- package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +45 -45
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CssProps,
|
|
3
|
-
MobileHeaderCenter,
|
|
4
|
-
MobileHeaderEmptyIcon,
|
|
5
|
-
MobileHeaderTitleIcon,
|
|
6
|
-
MobileTopSysIcon,
|
|
7
|
-
PageProps,
|
|
8
|
-
RefProps,
|
|
9
|
-
} from 'lupine.components';
|
|
10
|
-
|
|
11
|
-
export const ToolsPage = async (props: PageProps) => {
|
|
12
|
-
const css: CssProps = {
|
|
13
|
-
display: 'flex',
|
|
14
|
-
flexDirection: 'column',
|
|
15
|
-
height: '100%',
|
|
16
|
-
position: 'relative',
|
|
17
|
-
'.tools-list-container': {
|
|
18
|
-
padding: '32px 24px',
|
|
19
|
-
display: 'flex',
|
|
20
|
-
flexDirection: 'column',
|
|
21
|
-
alignItems: 'center',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const ref: RefProps = {
|
|
26
|
-
onLoad: async () => {},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<div css={css} ref={ref}>
|
|
31
|
-
<MobileHeaderCenter>
|
|
32
|
-
<MobileHeaderTitleIcon
|
|
33
|
-
title='Tools'
|
|
34
|
-
left={<MobileHeaderEmptyIcon />}
|
|
35
|
-
right={
|
|
36
|
-
<div class='flex-center-gap-12'>
|
|
37
|
-
<MobileTopSysIcon />
|
|
38
|
-
</div>
|
|
39
|
-
}
|
|
40
|
-
/>
|
|
41
|
-
</MobileHeaderCenter>
|
|
42
|
-
|
|
43
|
-
<div class='tools-list-container no-scrollbar-container'>This is a demo tools page.</div>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
CssProps,
|
|
3
|
+
MobileHeaderCenter,
|
|
4
|
+
MobileHeaderEmptyIcon,
|
|
5
|
+
MobileHeaderTitleIcon,
|
|
6
|
+
MobileTopSysIcon,
|
|
7
|
+
PageProps,
|
|
8
|
+
RefProps,
|
|
9
|
+
} from 'lupine.components';
|
|
10
|
+
|
|
11
|
+
export const ToolsPage = async (props: PageProps) => {
|
|
12
|
+
const css: CssProps = {
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
height: '100%',
|
|
16
|
+
position: 'relative',
|
|
17
|
+
'.tools-list-container': {
|
|
18
|
+
padding: '32px 24px',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexDirection: 'column',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ref: RefProps = {
|
|
26
|
+
onLoad: async () => {},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div css={css} ref={ref}>
|
|
31
|
+
<MobileHeaderCenter>
|
|
32
|
+
<MobileHeaderTitleIcon
|
|
33
|
+
title='Tools'
|
|
34
|
+
left={<MobileHeaderEmptyIcon />}
|
|
35
|
+
right={
|
|
36
|
+
<div class='flex-center-gap-12'>
|
|
37
|
+
<MobileTopSysIcon />
|
|
38
|
+
</div>
|
|
39
|
+
}
|
|
40
|
+
/>
|
|
41
|
+
</MobileHeaderCenter>
|
|
42
|
+
|
|
43
|
+
<div class='tools-list-container no-scrollbar-container'>This is a demo tools page.</div>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
export interface LocalNoteProps {
|
|
2
|
-
id: number;
|
|
3
|
-
title: string;
|
|
4
|
-
content: string; // HTML string
|
|
5
|
-
updatedAt: number;
|
|
6
|
-
images?: string[]; // Optional base64 strings
|
|
7
|
-
color?: string; // Optional color tag
|
|
8
|
-
orderIndex?: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const STORAGE_KEY = 'lj_notes';
|
|
12
|
-
|
|
13
|
-
export const LocalNotesService = {
|
|
14
|
-
getAllNotes: (): LocalNoteProps[] => {
|
|
15
|
-
try {
|
|
16
|
-
const data = localStorage.getItem(STORAGE_KEY);
|
|
17
|
-
const notes: LocalNoteProps[] = data ? JSON.parse(data) : [];
|
|
18
|
-
return notes.sort((a, b) => {
|
|
19
|
-
const orderA = a.orderIndex !== undefined ? a.orderIndex : a.id;
|
|
20
|
-
const orderB = b.orderIndex !== undefined ? b.orderIndex : b.id;
|
|
21
|
-
// Default sort: descending (newest/highest first), unless orderIndex dictates otherwise.
|
|
22
|
-
// If we want manual ordering, let's just sort descending by orderIndex.
|
|
23
|
-
return orderB - orderA;
|
|
24
|
-
});
|
|
25
|
-
} catch (e) {
|
|
26
|
-
console.error('Failed to load notes', e);
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
getNoteById: (id: number): LocalNoteProps | undefined => {
|
|
32
|
-
return LocalNotesService.getAllNotes().find((n) => n.id === id);
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
saveNote: (note: LocalNoteProps): LocalNoteProps => {
|
|
36
|
-
const notes = LocalNotesService.getAllNotes();
|
|
37
|
-
note.updatedAt = Date.now();
|
|
38
|
-
|
|
39
|
-
if (note.id <= 0) {
|
|
40
|
-
note.id = Date.now();
|
|
41
|
-
// Calculate next highest order index
|
|
42
|
-
const maxOrder = notes.length > 0 ? Math.max(...notes.map((n) => n.orderIndex ?? n.id)) : Date.now();
|
|
43
|
-
note.orderIndex = maxOrder + 1;
|
|
44
|
-
notes.unshift(note);
|
|
45
|
-
} else {
|
|
46
|
-
const index = notes.findIndex((n) => n.id === note.id);
|
|
47
|
-
if (index > -1) {
|
|
48
|
-
notes[index] = note;
|
|
49
|
-
} else {
|
|
50
|
-
notes.unshift(note);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(notes));
|
|
55
|
-
return note;
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
updateNoteOrders: (orderedIds: number[]): boolean => {
|
|
59
|
-
// orderedIds is passed from top to bottom. Top has highest orderIndex.
|
|
60
|
-
const notes = LocalNotesService.getAllNotes();
|
|
61
|
-
let updated = false;
|
|
62
|
-
const len = orderedIds.length;
|
|
63
|
-
orderedIds.forEach((id, idx) => {
|
|
64
|
-
const note = notes.find((n) => n.id === id);
|
|
65
|
-
if (note) {
|
|
66
|
-
note.orderIndex = len - idx; // Highest index for first item
|
|
67
|
-
updated = true;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (updated) {
|
|
72
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(notes));
|
|
73
|
-
}
|
|
74
|
-
return updated;
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
deleteNote: (id: number): boolean => {
|
|
78
|
-
let notes = LocalNotesService.getAllNotes();
|
|
79
|
-
const len = notes.length;
|
|
80
|
-
notes = notes.filter((n) => n.id !== id);
|
|
81
|
-
if (notes.length !== len) {
|
|
82
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(notes));
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
},
|
|
87
|
-
};
|
|
1
|
+
export interface LocalNoteProps {
|
|
2
|
+
id: number;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string; // HTML string
|
|
5
|
+
updatedAt: number;
|
|
6
|
+
images?: string[]; // Optional base64 strings
|
|
7
|
+
color?: string; // Optional color tag
|
|
8
|
+
orderIndex?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const STORAGE_KEY = 'lj_notes';
|
|
12
|
+
|
|
13
|
+
export const LocalNotesService = {
|
|
14
|
+
getAllNotes: (): LocalNoteProps[] => {
|
|
15
|
+
try {
|
|
16
|
+
const data = localStorage.getItem(STORAGE_KEY);
|
|
17
|
+
const notes: LocalNoteProps[] = data ? JSON.parse(data) : [];
|
|
18
|
+
return notes.sort((a, b) => {
|
|
19
|
+
const orderA = a.orderIndex !== undefined ? a.orderIndex : a.id;
|
|
20
|
+
const orderB = b.orderIndex !== undefined ? b.orderIndex : b.id;
|
|
21
|
+
// Default sort: descending (newest/highest first), unless orderIndex dictates otherwise.
|
|
22
|
+
// If we want manual ordering, let's just sort descending by orderIndex.
|
|
23
|
+
return orderB - orderA;
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error('Failed to load notes', e);
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
getNoteById: (id: number): LocalNoteProps | undefined => {
|
|
32
|
+
return LocalNotesService.getAllNotes().find((n) => n.id === id);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
saveNote: (note: LocalNoteProps): LocalNoteProps => {
|
|
36
|
+
const notes = LocalNotesService.getAllNotes();
|
|
37
|
+
note.updatedAt = Date.now();
|
|
38
|
+
|
|
39
|
+
if (note.id <= 0) {
|
|
40
|
+
note.id = Date.now();
|
|
41
|
+
// Calculate next highest order index
|
|
42
|
+
const maxOrder = notes.length > 0 ? Math.max(...notes.map((n) => n.orderIndex ?? n.id)) : Date.now();
|
|
43
|
+
note.orderIndex = maxOrder + 1;
|
|
44
|
+
notes.unshift(note);
|
|
45
|
+
} else {
|
|
46
|
+
const index = notes.findIndex((n) => n.id === note.id);
|
|
47
|
+
if (index > -1) {
|
|
48
|
+
notes[index] = note;
|
|
49
|
+
} else {
|
|
50
|
+
notes.unshift(note);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(notes));
|
|
55
|
+
return note;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
updateNoteOrders: (orderedIds: number[]): boolean => {
|
|
59
|
+
// orderedIds is passed from top to bottom. Top has highest orderIndex.
|
|
60
|
+
const notes = LocalNotesService.getAllNotes();
|
|
61
|
+
let updated = false;
|
|
62
|
+
const len = orderedIds.length;
|
|
63
|
+
orderedIds.forEach((id, idx) => {
|
|
64
|
+
const note = notes.find((n) => n.id === id);
|
|
65
|
+
if (note) {
|
|
66
|
+
note.orderIndex = len - idx; // Highest index for first item
|
|
67
|
+
updated = true;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (updated) {
|
|
72
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(notes));
|
|
73
|
+
}
|
|
74
|
+
return updated;
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
deleteNote: (id: number): boolean => {
|
|
78
|
+
let notes = LocalNotesService.getAllNotes();
|
|
79
|
+
const len = notes.length;
|
|
80
|
+
notes = notes.filter((n) => n.id !== id);
|
|
81
|
+
if (notes.length !== len) {
|
|
82
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(notes));
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { LocalNotesService } from './local-notes-service';
|
|
2
|
-
|
|
3
|
-
export interface MineStats {
|
|
4
|
-
noteCount: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface BackupData {
|
|
8
|
-
notes: any[];
|
|
9
|
-
timestamp: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const MineService = {
|
|
13
|
-
getStats: (): MineStats => {
|
|
14
|
-
const notes = LocalNotesService.getAllNotes();
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
noteCount: notes.length,
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
exportBackup: (): string => {
|
|
22
|
-
const data: BackupData = {
|
|
23
|
-
notes: LocalNotesService.getAllNotes(),
|
|
24
|
-
timestamp: new Date().toISOString(),
|
|
25
|
-
};
|
|
26
|
-
return JSON.stringify(data, null, 2);
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
importBackup: (jsonStr: string): boolean => {
|
|
30
|
-
try {
|
|
31
|
-
const data: BackupData = JSON.parse(jsonStr);
|
|
32
|
-
if (Array.isArray(data.notes)) {
|
|
33
|
-
localStorage.setItem('lj_notes', JSON.stringify(data.notes));
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
} catch (e) {
|
|
37
|
-
console.error('Failed to import backup', e);
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
clearAllData: () => {
|
|
43
|
-
localStorage.removeItem('lj_notes');
|
|
44
|
-
},
|
|
45
|
-
};
|
|
1
|
+
import { LocalNotesService } from './local-notes-service';
|
|
2
|
+
|
|
3
|
+
export interface MineStats {
|
|
4
|
+
noteCount: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface BackupData {
|
|
8
|
+
notes: any[];
|
|
9
|
+
timestamp: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const MineService = {
|
|
13
|
+
getStats: (): MineStats => {
|
|
14
|
+
const notes = LocalNotesService.getAllNotes();
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
noteCount: notes.length,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
exportBackup: (): string => {
|
|
22
|
+
const data: BackupData = {
|
|
23
|
+
notes: LocalNotesService.getAllNotes(),
|
|
24
|
+
timestamp: new Date().toISOString(),
|
|
25
|
+
};
|
|
26
|
+
return JSON.stringify(data, null, 2);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
importBackup: (jsonStr: string): boolean => {
|
|
30
|
+
try {
|
|
31
|
+
const data: BackupData = JSON.parse(jsonStr);
|
|
32
|
+
if (Array.isArray(data.notes)) {
|
|
33
|
+
localStorage.setItem('lj_notes', JSON.stringify(data.notes));
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.error('Failed to import backup', e);
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
clearAllData: () => {
|
|
43
|
+
localStorage.removeItem('lj_notes');
|
|
44
|
+
},
|
|
45
|
+
};
|