@foundbyte/uni-libs 1.0.9 → 1.1.0

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.
@@ -89,6 +89,8 @@ declare enum EBusinessLine {
89
89
  TulvCheckIn = 271,
90
90
  /** 徒旅贵州-自由行 */
91
91
  TulvFreeWalker = 272,
92
+ /** 权益中心 */
93
+ BenefitsCenter = 28,
92
94
  /** ai助手页面(问道贵州,后端无定义) */
93
95
  AiHelper = 1023,
94
96
  }
@@ -89,6 +89,8 @@ let EBusinessLine = /* @__PURE__ */ function(EBusinessLine) {
89
89
  EBusinessLine[EBusinessLine["TulvCheckIn"] = 271] = "TulvCheckIn";
90
90
  /** 徒旅贵州-自由行 */
91
91
  EBusinessLine[EBusinessLine["TulvFreeWalker"] = 272] = "TulvFreeWalker";
92
+ /** 权益中心 */
93
+ EBusinessLine[EBusinessLine["BenefitsCenter"] = 28] = "BenefitsCenter";
92
94
  /** ai助手页面(问道贵州,后端无定义) */
93
95
  EBusinessLine[EBusinessLine["AiHelper"] = 1023] = "AiHelper";
94
96
  return EBusinessLine;
@@ -32,7 +32,8 @@ function getQueryParameters(url) {
32
32
  const key = decodeURIComponent(pair[0]);
33
33
  let value = decodeURIComponent(pair[1] || "");
34
34
  try {
35
- value = JSON.parse(value);
35
+ const parsed = JSON.parse(value);
36
+ if (typeof parsed === "number" && String(parsed) !== value) {} else value = parsed;
36
37
  } catch (_unused) {}
37
38
  params[key] = value;
38
39
  }
@@ -4,20 +4,21 @@ declare enum EObsSource {
4
4
  Huawei = 1,
5
5
  /** 腾讯 */
6
6
  Tencent = 2,
7
- /** ali */
7
+ /** 阿里 */
8
8
  Ali = 2,
9
9
  }
10
10
  /**
11
11
  * 参考 https://support.huaweicloud.com/intl/zh-cn/fg-obs/obs_01_0430.html
12
+ * 腾讯云目前只支持部分参数(w/h)
12
13
  */
13
14
  type CompressOptions = {
14
15
  w?: number;
15
16
  h?: number;
16
17
  /**
17
18
  * 缩率类型,默认 'lfit'
18
- * - `lfit`: 等比缩放,限制在容器内
19
- * - `mfit`: 等比缩放,覆盖容器
20
- * - `fill`: 等比缩放,裁剪填充容器
19
+ * - `lfit`: 等比缩放,限制在容器内,类似 css container
20
+ * - `mfit`: 等比缩放,覆盖容器,类似 css cover ,但保留裁剪掉的部分
21
+ * - `fill`: 等比缩放,裁剪填充容器,类似 css cover
21
22
  */
22
23
  m?: 'lfit' | 'mfit' | 'fill';
23
24
  p?: number;
@@ -5,7 +5,7 @@ let EObsSource = /* @__PURE__ */ function(EObsSource) {
5
5
  EObsSource[EObsSource["Huawei"] = 1] = "Huawei";
6
6
  /** 腾讯 */
7
7
  EObsSource[EObsSource["Tencent"] = 2] = "Tencent";
8
- /** ali */
8
+ /** 阿里 */
9
9
  EObsSource[EObsSource["Ali"] = 2] = "Ali";
10
10
  return EObsSource;
11
11
  }({});
@@ -70,12 +70,33 @@ function compressHuaweiObsImg(url, opts) {
70
70
  * @param opts
71
71
  * @returns
72
72
  */
73
- function compressTencentObsImg(url, { w, h }) {
74
- const prefix = `${url}?imageMogr2/thumbnail/`;
75
- if (w && h) return `${prefix}!${w || ""}x${h || ""}r`;
76
- if (w) return `${prefix}${w || ""}x`;
77
- if (h) return `${prefix}x${h || ""}`;
78
- return url;
73
+ function compressTencentObsImg(url, opts) {
74
+ const { w = "", h = "", m = "lfit", p, q } = opts;
75
+ const actions = ["imageMogr2"];
76
+ if (p) {
77
+ actions.push("thumbnail");
78
+ actions.push(`!${p}p`);
79
+ } else if (w || h) {
80
+ actions.push("thumbnail");
81
+ switch (m) {
82
+ case "mfit":
83
+ actions.push(`!${w}x${h}r`);
84
+ break;
85
+ case "fill":
86
+ actions.push(`!${w}x${h}r`);
87
+ actions.push("crop");
88
+ actions.push(`${w || h}x${h || w}`);
89
+ actions.push("gravity");
90
+ actions.push("center");
91
+ break;
92
+ default: actions.push(`${w}x${h}`);
93
+ }
94
+ }
95
+ if (q) {
96
+ actions.push("rquality");
97
+ actions.push(Math.min(100, Math.max(0, q)));
98
+ }
99
+ return `${url}?${actions.join("/")}`;
79
100
  }
80
101
  function compressObsImg(url, opts) {
81
102
  switch (opts.source) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@foundbyte/uni-libs",
3
3
  "description": "FoundByte Uni Libs",
4
4
  "author": "yangshuai <704807396@qq.com>",
5
- "version": "1.0.9",
5
+ "version": "1.1.0",
6
6
  "private": false,
7
7
  "type": "module",
8
8
  "main": "es/index.js",