File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import { Host } from " @/adapters" ;
3
3
import { config2json , json2config } from " @/services/config/schema" ;
4
- import { listProfiles , saveProfile } from " @/services/profile" ;
4
+ import { listProfiles , saveManyProfiles } from " @/services/profile" ;
5
5
import { useFileDialog } from " @vueuse/core" ;
6
6
import { Notification } from " @arco-design/web-vue" ;
7
7
import {
@@ -23,7 +23,7 @@ onChange(async (file) => {
23
23
}
24
24
25
25
const profiles = json2config (await file [0 ].text ());
26
- profiles . forEach ( saveProfile );
26
+ await saveManyProfiles ( profiles );
27
27
Notification .success ({
28
28
content: Host .getMessage (
29
29
" preferences_feedback_n_profiles_being_imported" ,
Original file line number Diff line number Diff line change @@ -108,12 +108,26 @@ async function overwriteProfiles(profiles: ProfilesStorage) {
108
108
onProfileUpdateListeners . map ( ( cb ) => cb ( profiles ) ) ;
109
109
}
110
110
111
+ /**
112
+ * Save a single profile to the storage.
113
+ * Please be noticed that this is not promise-safe. If you want to save multiple profiles, use `saveManyProfiles` instead.
114
+ *
115
+ * @param profile
116
+ */
111
117
export async function saveProfile ( profile : ProxyProfile ) {
112
118
const data = await listProfiles ( ) ;
113
119
data [ profile . profileID ] = profile ;
114
120
await overwriteProfiles ( data ) ;
115
121
}
116
122
123
+ export async function saveManyProfiles ( profiles : ProxyProfile [ ] ) {
124
+ let data = await listProfiles ( ) ;
125
+ profiles . forEach ( ( p ) => {
126
+ data [ p . profileID ] = p ;
127
+ } ) ;
128
+ await overwriteProfiles ( data ) ;
129
+ }
130
+
117
131
export async function getProfile (
118
132
profileID : string ,
119
133
userProfileOnly ?: boolean
You can’t perform that action at this time.
0 commit comments