@cc-component/cc-core 1.6.2 → 1.6.4

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.
@@ -148,7 +148,7 @@ export class EffectSingleCase {
148
148
  if (params && params.bundle) bundleName = params.bundle;
149
149
  node = instantiate(App.GetAsset(bundleName, params.path))//ViewUtil.createPrefabNode(path, bundleName);
150
150
  // //@ts-ignore
151
- // node.asset_path = path;
151
+ node.asset_path = App.res.getAssetKey(params.path, params.bundle)
152
152
  // if (params && params.isPlayFinishedRelease) {
153
153
  // node.addComponent(EffectFinishedRelease);
154
154
  // }
@@ -292,7 +292,7 @@ export class EffectSingleCase {
292
292
  this.res.set(params.path, params.bundle);
293
293
  const prefab = await App.LoadAsset(params.bundle, params.path, Prefab);
294
294
  const node = instantiate(prefab)
295
-
295
+ node.asset_path = App.res.getAssetKey(params.path, params.bundle)
296
296
  this.updateNode(node, params)
297
297
  resolve(node);
298
298
  });
@@ -243,6 +243,36 @@ export class Tools {
243
243
  }
244
244
 
245
245
  }
246
+
247
+ /**数字格式化 1.2万 1.2亿 */
248
+ formatNumber(num: number, fixNum: number = 2): string {
249
+ const k = 10000;
250
+ const sizes = ['', '万', '亿', '万亿', '万亿'];
251
+ //return num.toString();
252
+ if (num < k) {
253
+ if (fixNum > 0) {
254
+ // 使用整数运算避免浮点误差
255
+ const factor = Math.pow(10, fixNum);
256
+ const adjustedNum = Math.round(num * factor * 1000) / 1000; // 微调避免精度问题
257
+ const truncated = Math.floor(adjustedNum) / factor;
258
+ let result = truncated.toFixed(fixNum);
259
+ return result.replace(/\.?0+$/, '');
260
+ }
261
+ return Math.floor(num).toString();
262
+ } else {
263
+ const i = Math.floor(Math.log(num) / Math.log(k));
264
+ const scaledNum = num / Math.pow(k, i);
265
+ if (fixNum > 0) {
266
+ // 使用整数运算避免浮点误差
267
+ const factor = Math.pow(10, fixNum);
268
+ const adjustedNum = Math.round(scaledNum * factor * 1000) / 1000; // 微调避免精度问题
269
+ const truncated = Math.floor(adjustedNum) / factor;
270
+ let result = truncated.toFixed(fixNum);
271
+ return result.replace(/\.?0+$/, '') + sizes[i];
272
+ }
273
+ return Math.floor(scaledNum).toString() + sizes[i];
274
+ }
275
+ }
246
276
  }
247
277
 
248
278
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-core",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",