@ithinkdt/page 4.0.20 → 4.0.21
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/package.json +1 -1
- package/src/list.js +16 -14
package/package.json
CHANGED
package/src/list.js
CHANGED
|
@@ -71,17 +71,17 @@ export function useListPageCustomization({
|
|
|
71
71
|
|
|
72
72
|
const getDefaultName = (i, namePrefix = t('common.page.custom.profile')) => {
|
|
73
73
|
const name = `${namePrefix}${i}`
|
|
74
|
-
if (
|
|
74
|
+
if (profiles.value.some(profile => profile.name === name)) return getDefaultName(i + 1, namePrefix)
|
|
75
75
|
return name
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const onSet = async (newValue, storage) => {
|
|
79
|
-
const profile =
|
|
79
|
+
const profile = profiles.value.find(profile => profile.key === storage.profile)
|
|
80
80
|
if (profile?.locked) {
|
|
81
81
|
const profileName = getDefaultName(1, profile.key === 'default' ? undefined : profile?.name)
|
|
82
82
|
const profileKey = nanoid()
|
|
83
|
-
const index =
|
|
84
|
-
config.value.profiles.splice(index
|
|
83
|
+
const index = profiles.value.findIndex(profile => profile.key === storage.profile)
|
|
84
|
+
config.value.profiles.splice(index, 0, { key: profileKey, name: profileName })
|
|
85
85
|
await switchProfile(profileKey, false)
|
|
86
86
|
}
|
|
87
87
|
changing.value = true
|
|
@@ -126,9 +126,7 @@ export function useListPageCustomization({
|
|
|
126
126
|
{
|
|
127
127
|
latest: 'default',
|
|
128
128
|
preference: undefined,
|
|
129
|
-
profiles: [
|
|
130
|
-
{ key: 'default', locked: true },
|
|
131
|
-
],
|
|
129
|
+
profiles: [],
|
|
132
130
|
},
|
|
133
131
|
storage,
|
|
134
132
|
{
|
|
@@ -137,7 +135,6 @@ export function useListPageCustomization({
|
|
|
137
135
|
onReady() {
|
|
138
136
|
resolve()
|
|
139
137
|
nextTick(() => {
|
|
140
|
-
config.value.profiles[0].name = t('common.page.custom.profileDefault')
|
|
141
138
|
const key = route.params[routeParamName]
|
|
142
139
|
switchProfile(key)
|
|
143
140
|
})
|
|
@@ -145,6 +142,11 @@ export function useListPageCustomization({
|
|
|
145
142
|
},
|
|
146
143
|
)
|
|
147
144
|
|
|
145
|
+
const profiles = computed(() => [
|
|
146
|
+
{ key: 'default', name: t('common.page.custom.profileDefault'), locked: true },
|
|
147
|
+
...config.value.profiles,
|
|
148
|
+
])
|
|
149
|
+
|
|
148
150
|
const profile = computed({
|
|
149
151
|
get: () => config.value.latest ?? 'default',
|
|
150
152
|
set: (key) => {
|
|
@@ -189,7 +191,7 @@ export function useListPageCustomization({
|
|
|
189
191
|
key = name.key
|
|
190
192
|
}
|
|
191
193
|
key ??= config.value.latest
|
|
192
|
-
const profile =
|
|
194
|
+
const profile = profiles.value.find(profile => profile.key === key)
|
|
193
195
|
if (!profile) {
|
|
194
196
|
console.debug(`[customizer] profile not found: ${key}`)
|
|
195
197
|
return
|
|
@@ -198,13 +200,13 @@ export function useListPageCustomization({
|
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
async function copyProfile(key, name) {
|
|
201
|
-
const index =
|
|
203
|
+
const index = profiles.value.findIndex(profile => profile.key === key)
|
|
202
204
|
if (index === -1) {
|
|
203
205
|
console.debug(`[customizer] profile not found: ${key}`)
|
|
204
206
|
return
|
|
205
207
|
}
|
|
206
|
-
const newProfile = { key: nanoid(), name: name ?? getDefaultName(1,
|
|
207
|
-
config.value.profiles.splice(index
|
|
208
|
+
const newProfile = { key: nanoid(), name: name ?? getDefaultName(1, profiles.value[index].name) }
|
|
209
|
+
config.value.profiles.splice(index, 0, newProfile)
|
|
208
210
|
await Promise.all([
|
|
209
211
|
storage.setItem(
|
|
210
212
|
`customization#${filterStorage.key}~${newProfile.key}#${filterStorage.type}`,
|
|
@@ -224,7 +226,7 @@ export function useListPageCustomization({
|
|
|
224
226
|
key = key.key
|
|
225
227
|
locked = key.locked
|
|
226
228
|
}
|
|
227
|
-
const profile =
|
|
229
|
+
const profile = profiles.value.find(profile => profile.key === key)
|
|
228
230
|
if (!profile) {
|
|
229
231
|
console.debug(`[customizer] profile not found: ${key}`)
|
|
230
232
|
return
|
|
@@ -233,7 +235,7 @@ export function useListPageCustomization({
|
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
const returns = {
|
|
236
|
-
profiles
|
|
238
|
+
profiles,
|
|
237
239
|
profile,
|
|
238
240
|
preference,
|
|
239
241
|
changing,
|