qidian-shared 0.0.1-beta.2 → 0.0.1-beta.3

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.
@@ -14,6 +14,7 @@ export type ServicePagination = MaybeRef<false | {
14
14
  export interface ServicePageDataType<T> {
15
15
  list: T[];
16
16
  page?: number;
17
+ size?: number;
17
18
  total?: number;
18
19
  }
19
20
  type PageParams<T> = T extends false ? undefined : ServicePageParams;
@@ -22,8 +23,8 @@ type ServicePaginationBaseOptions<T> = PaginationOptions<ServicePageDataType<T>,
22
23
  export interface ServicePageBaseOptions<D = unknown, R = unknown, P = ServicePageParams, TP = P, Pag extends ServicePagination = ServicePagination> {
23
24
  service: (params: TP) => Promise<R>;
24
25
  manual?: boolean;
25
- transformParams?: (params: PageParams<Pag>) => TP;
26
- transformRes?: (res: R) => ServicePageRes<D>;
26
+ transformParams?: (params: PageParams<Pag>) => TP | Promise<TP>;
27
+ transformRes?: (res: R) => ServicePageRes<D> | Promise<ServicePageRes<D>>;
27
28
  pagination?: Pag;
28
29
  }
29
30
  export interface ServicePageLoadMoreOptions<D = unknown, R = unknown, P = ServicePageParams, TP = P, Pag extends ServicePagination = ServicePagination> extends ServicePageBaseOptions<D, R, P, TP, Pag> {
@@ -95,6 +95,25 @@ function createEnum(obj) {
95
95
  });
96
96
  return { map, options };
97
97
  }
98
+ function extractSlotsWithPrefix(slots, prefix) {
99
+ const res = [];
100
+ for (const key in slots) {
101
+ if (!key.startsWith(`${prefix}-`)) continue;
102
+ res.push({ originalName: key, filterName: key.slice(prefix.length + 1) });
103
+ }
104
+ return res;
105
+ }
106
+ function extractSlotsWithoutPrefix(slots, prefix) {
107
+ const res = [];
108
+ for (const key in slots) {
109
+ if (key.startsWith(`${prefix}-`)) continue;
110
+ res.push(key);
111
+ }
112
+ return res;
113
+ }
114
+ function easyCopy(data) {
115
+ return JSON.parse(JSON.stringify(data));
116
+ }
98
117
  function toMoney(money, precision = 2, multiple) {
99
118
  if (isEmpty(money)) return "";
100
119
  if (multiple) money = Number(money) * multiple;
@@ -8187,8 +8206,8 @@ function useServiceLoadMore({
8187
8206
  const res = { list: [], page: 1, total: 0 };
8188
8207
  const paginationV = vue.unref(pagination);
8189
8208
  let currentParams = paginationV ? {
8190
- pageSize: paginationV.pageSize ?? 30,
8191
- pageNum: params?.page ? params?.page + 1 : 1
8209
+ pageNum: params?.page ?? 1,
8210
+ pageSize: params?.size ?? paginationV?.pageSize ?? 30
8192
8211
  } : void 0;
8193
8212
  if (!currentParams || currentParams?.pageNum === 1) {
8194
8213
  firstLoad.value = true;
@@ -8215,7 +8234,10 @@ function useServiceLoadMore({
8215
8234
  } else {
8216
8235
  res.list = res.list.concat(temp.records);
8217
8236
  }
8218
- if (paginationV) res.page = currentParams?.pageNum ?? 1;
8237
+ if (currentParams) {
8238
+ res.page = currentParams?.pageNum;
8239
+ res.size = currentParams?.pageSize;
8240
+ }
8219
8241
  res.total = temp.total;
8220
8242
  return res;
8221
8243
  },
@@ -8310,9 +8332,9 @@ function useServicePagination({
8310
8332
  async (params2) => {
8311
8333
  const res = { list: [], page: 1, total: 0 };
8312
8334
  const paginationV = vue.unref(pagination);
8313
- let currentParams = paginationV ? {
8314
- pageSize: paginationV.pageSize ?? 10,
8315
- pageNum: params2?.page ? params2?.page + 1 : 1
8335
+ let currentParams = paginationV !== false ? {
8336
+ pageNum: params2?.page ?? 1,
8337
+ pageSize: params2?.size ?? paginationV?.pageSize ?? 10
8316
8338
  } : void 0;
8317
8339
  if (!currentParams || currentParams?.pageNum === 1) {
8318
8340
  firstLoad.value = true;
@@ -8339,7 +8361,10 @@ function useServicePagination({
8339
8361
  } else {
8340
8362
  res.list = res.list.concat(temp.records);
8341
8363
  }
8342
- if (paginationV) res.page = currentParams?.pageNum ?? 1;
8364
+ if (currentParams) {
8365
+ res.page = currentParams?.pageNum;
8366
+ res.size = currentParams?.pageSize;
8367
+ }
8343
8368
  res.total = temp.total;
8344
8369
  return res;
8345
8370
  },
@@ -8422,8 +8447,11 @@ exports.createEnum = createEnum;
8422
8447
  exports.decryptBase64 = decryptBase64;
8423
8448
  exports.deleteUrlParams = deleteUrlParams;
8424
8449
  exports.devProxy = devProxy;
8450
+ exports.easyCopy = easyCopy;
8425
8451
  exports.encryptBase64 = encryptBase64;
8426
8452
  exports.encryptWithAes = encryptWithAes;
8453
+ exports.extractSlotsWithPrefix = extractSlotsWithPrefix;
8454
+ exports.extractSlotsWithoutPrefix = extractSlotsWithoutPrefix;
8427
8455
  exports.generateAesKey = generateAesKey;
8428
8456
  exports.getUrlParam = getUrlParam;
8429
8457
  exports.getUrlParams = getUrlParams;