@ithinkdt/page 4.0.20 → 4.0.22

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.
Files changed (3) hide show
  1. package/package.json +5 -5
  2. package/src/form.js +1 -1
  3. package/src/list.js +18 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ithinkdt/page",
3
- "version": "4.0.20",
3
+ "version": "4.0.22",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "iThinkDT Page",
@@ -41,7 +41,7 @@
41
41
  "dependencies": {
42
42
  "@vueuse/core": "^14.3.0",
43
43
  "nanoid": "^5.1.11",
44
- "@ithinkdt/common": "^4.0.9"
44
+ "@ithinkdt/common": "^4.0.10"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "vue": ">=3.5",
@@ -49,9 +49,9 @@
49
49
  },
50
50
  "devDependencies": {
51
51
  "typescript": "~6.0.3",
52
- "vite": "^8.0.14",
53
- "vue": "^3.5.34",
54
- "vue-router": "^5.0.7"
52
+ "vite": "^8.0.16",
53
+ "vue": "^3.5.35",
54
+ "vue-router": "^5.1.0"
55
55
  },
56
56
  "scripts": {
57
57
  "release": "pnpm publish --no-git-checks"
package/src/form.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StorageSerializers, toReactive, tryOnScopeDispose, useEventListener, useStorage } from '@vueuse/core'
2
2
  import { nanoid } from 'nanoid'
3
- import { computed, effectScope, h, hasInjectionContext, inject, reactive, readonly, ref, shallowReactive, shallowRef, toRaw, unref, watch } from 'vue'
3
+ import { computed, effectScope, h, hasInjectionContext, inject, reactive, readonly, ref, shallowReactive, shallowRef, toRaw, unref } from 'vue'
4
4
  import { useRoute } from 'vue-router'
5
5
 
6
6
  import { copy, isNone } from '@ithinkdt/common/object'
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 (config.value.profiles.some(profile => profile.name === name)) return getDefaultName(i + 1, namePrefix)
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 = config.value.profiles.find(profile => profile.key === storage.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 = config.value.profiles.findIndex(profile => profile.key === storage.profile)
84
- config.value.profiles.splice(index + 1, 0, { key: profileKey, name: profileName })
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
@@ -91,8 +91,8 @@ export function useListPageCustomization({
91
91
  const filterStorage = new CustomStorage('filter-form', storage, key, 'default', { onSet })
92
92
  const tableStorage = new CustomStorage('table-column', storage, key, 'default', { onSet })
93
93
  tryOnScopeDispose(() => {
94
- filterStorage.$event.clear()
95
- tableStorage.$event.clear()
94
+ filterStorage.$change.clear()
95
+ tableStorage.$change.clear()
96
96
  })
97
97
 
98
98
  let laskKey = 'default'
@@ -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 = config.value.profiles.find(profile => profile.key === key)
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 = config.value.profiles.findIndex(profile => profile.key === key)
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, config.value.profiles[index].name) }
207
- config.value.profiles.splice(index + 1, 0, newProfile)
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 = config.value.profiles.find(profile => profile.key === key)
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: computed(() => config.value.profiles),
238
+ profiles,
237
239
  profile,
238
240
  preference,
239
241
  changing,