Skip to content

Commit e330018

Browse files
authored
feat: backup restore UI (#134)
feat: backup restore UI #134 implement the backup UI Refs: #23 --------- Signed-off-by: seven <[email protected]>
1 parent cbde0a3 commit e330018

File tree

9 files changed

+414
-7
lines changed

9 files changed

+414
-7
lines changed

components.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ declare module 'vue' {
3737
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
3838
NModal: typeof import('naive-ui')['NModal']
3939
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
40+
NP: typeof import('naive-ui')['NP']
4041
NPopover: typeof import('naive-ui')['NPopover']
4142
NProgress: typeof import('naive-ui')['NProgress']
4243
NRadio: typeof import('naive-ui')['NRadio']
@@ -48,7 +49,10 @@ declare module 'vue' {
4849
NTabPane: typeof import('naive-ui')['NTabPane']
4950
NTabs: typeof import('naive-ui')['NTabs']
5051
NTag: typeof import('naive-ui')['NTag']
52+
NText: typeof import('naive-ui')['NText']
5153
NTooltip: typeof import('naive-ui')['NTooltip']
54+
NUpload: typeof import('naive-ui')['NUpload']
55+
NUploadDragger: typeof import('naive-ui')['NUploadDragger']
5256
PathBreadcrumb: typeof import('./src/components/PathBreadcrumb.vue')['default']
5357
RouterLink: typeof import('vue-router')['RouterLink']
5458
RouterMain: typeof import('./src/components/RouterMain.vue')['default']

src/lang/enUS.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const enUS = {
88
user: 'User',
99
setting: 'Setting',
1010
chatBot: 'AI Assistant',
11+
backupRestore: 'Backup/Restore',
1112
},
1213
setting: {
1314
basic: 'Basic',
@@ -170,6 +171,23 @@ export const enUS = {
170171
empty: 'No history yet',
171172
emptyDesc: 'History of queries will appear here as you execute Scans and Queries',
172173
},
174+
backup: {
175+
backup: 'Backup',
176+
restore: 'Restore',
177+
restoreSourceDesc: 'Click or drag a file to this area to upload your JSON/CSV file',
178+
backupForm: {
179+
connection: 'Connection',
180+
index: 'Index',
181+
backupFolder: 'Location',
182+
backupFileName: 'File Name',
183+
connectionRequired: 'Please select a Connection',
184+
indexRequired: 'Please select an Index',
185+
backupFolderRequired: 'Please select Backup Folder',
186+
backupFileNameRequired: 'Please enter Backup File Name',
187+
validationFailed: 'Backup Config validation failed!',
188+
validationPassed: 'Backup Config validation passed!',
189+
},
190+
},
173191
version: {
174192
newVersion: 'New version available',
175193
message: 'A new version is available, download it now',

src/lang/zhCN.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const zhCN = {
88
user: '用户',
99
setting: '设置',
1010
chatBot: 'AI助手',
11+
backupRestore: '备份/恢复',
1112
},
1213
setting: {
1314
basic: '通用设置',
@@ -171,6 +172,23 @@ export const zhCN = {
171172
empty: '无历史记录',
172173
emptyDesc: '执行扫描和查询时,查询历史记录将显示在此处',
173174
},
175+
backup: {
176+
backup: '备份',
177+
restore: '恢复',
178+
restoreSourceDesc: '点击或拖动文件到此区域上传您的 JSON/CSV 文件',
179+
backupForm: {
180+
connection: '选择连接',
181+
index: '选择索引',
182+
backupFolder: '文件夹',
183+
backupFileName: '文件名',
184+
connectionRequired: '请选择连接',
185+
indexRequired: '请选择索引',
186+
backupFolderRequired: '请选择备份文件夹',
187+
backupFileNameRequired: '请输入备份文件名',
188+
validationFailed: '备份操作配置校验失败!',
189+
validationPassed: '备份操作配置校验通过!',
190+
},
191+
},
174192
version: {
175193
newVersion: '发现新版本',
176194
message: '发现新版本,是否立即下载',

src/layout/components/the-aside.vue

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,11 @@ import {
5353
UserAvatar,
5454
ExpandAll,
5555
Equalizer,
56+
ImportExport,
5657
} from '@vicons/carbon';
5758
import { useAppStore } from '../../store';
5859
import TheAsideIcon from './the-aside-icon.vue';
60+
5961
const router = useRouter();
6062
const route = useRoute();
6163
const appStore = useAppStore();
@@ -90,13 +92,13 @@ const mainNavList = ref([
9092
icon: markRaw(ExpandAll),
9193
isLink: false,
9294
},
93-
// {
94-
// id: 'import-export',
95-
// path: '/import-export',
96-
// name: 'import-export',
97-
// icon: markRaw(SaveSeries),
98-
// isLink: false,
99-
// },
95+
{
96+
id: 'backup-restore',
97+
path: '/backup-restore',
98+
name: 'backupRestore',
99+
icon: markRaw(ImportExport),
100+
isLink: false,
101+
},
100102
{
101103
id: 'github',
102104
path: '',
@@ -130,6 +132,7 @@ interface RouteItem {
130132
name: string;
131133
isLink: boolean;
132134
}
135+
133136
const isActive = (item: RouteItem) => {
134137
return item.path === route.path;
135138
};
@@ -157,10 +160,12 @@ const navClick = (item: RouteItem) => {
157160
display: flex;
158161
flex-direction: column;
159162
border-right: 1px solid var(--border-color);
163+
160164
.main-nav {
161165
flex: 1;
162166
height: 0;
163167
}
168+
164169
.icon-item {
165170
height: var(--aside-width);
166171
height: 40px;
@@ -171,12 +176,15 @@ const navClick = (item: RouteItem) => {
171176
align-items: center;
172177
color: var(--text-color);
173178
cursor: pointer;
179+
174180
.n-icon {
175181
opacity: 0.4;
176182
transition: 0.3s;
177183
}
184+
178185
&.active {
179186
position: relative;
187+
180188
&::before {
181189
content: '';
182190
position: absolute;
@@ -186,10 +194,12 @@ const navClick = (item: RouteItem) => {
186194
width: 5px;
187195
background-color: var(--border-color);
188196
}
197+
189198
.n-icon {
190199
opacity: 1;
191200
}
192201
}
202+
193203
&:hover {
194204
.n-icon {
195205
opacity: 0.9;

src/router/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ const router = createRouter({
6464
},
6565
component: () => import('../views/file/index.vue'),
6666
},
67+
{
68+
name: 'BackupRestore',
69+
path: '/backup-restore',
70+
meta: {
71+
keepAlive: false,
72+
},
73+
component: () => import('../views/backup-restore/index.vue'),
74+
},
6775
],
6876
},
6977
],

src/store/backupRestoreStore.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { open } from '@tauri-apps/api/dialog';
2+
3+
import { defineStore } from 'pinia';
4+
import { CustomError } from '../common';
5+
import { get } from 'lodash';
6+
7+
export const useBackupRestoreStore = defineStore('backupRestoreStore', {
8+
state(): { folderPath: string; fileName: string } {
9+
return {
10+
folderPath: '',
11+
fileName: '',
12+
};
13+
},
14+
persist: true,
15+
getters: {},
16+
actions: {
17+
async selectFolder() {
18+
try {
19+
this.folderPath = (await open({ recursive: true, directory: true })) as string;
20+
} catch (error) {
21+
throw new CustomError(
22+
get(error, 'status', 500),
23+
get(error, 'details', get(error, 'message', '')),
24+
);
25+
}
26+
},
27+
},
28+
});

src/store/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export * from './connectionStore';
1212
export * from './sourceFileStore';
1313
export * from './chatStore';
1414
export * from './clusterManageStore';
15+
export * from './backupRestoreStore';

0 commit comments

Comments
 (0)