lime-shared.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view id="shared" style="height: 500px; width: 300px; background-color: aqua;">
  3. </view>
  4. </template>
  5. <script lang="ts">
  6. import { getRect, getAllRect } from '@/uni_modules/lime-shared/getRect'
  7. import { camelCase } from '@/uni_modules/lime-shared/camelCase'
  8. import { canIUseCanvas2d } from '@/uni_modules/lime-shared/canIUseCanvas2d'
  9. import { clamp } from '@/uni_modules/lime-shared/clamp'
  10. import { cloneDeep } from '@/uni_modules/lime-shared/cloneDeep'
  11. import { closest } from '@/uni_modules/lime-shared/closest'
  12. import { debounce } from '@/uni_modules/lime-shared/debounce'
  13. import { fillZero } from '@/uni_modules/lime-shared/fillZero'
  14. import { floatAdd } from '@/uni_modules/lime-shared/floatAdd'
  15. import { floatMul } from '@/uni_modules/lime-shared/floatMul'
  16. import { floatDiv } from '@/uni_modules/lime-shared/floatDiv'
  17. import { floatSub } from '@/uni_modules/lime-shared/floatSub'
  18. import { getClassStr } from '@/uni_modules/lime-shared/getClassStr'
  19. import { getCurrentPage } from '@/uni_modules/lime-shared/getCurrentPage'
  20. import { getStyleStr } from '@/uni_modules/lime-shared/getStyleStr'
  21. import { hasOwn } from '@/uni_modules/lime-shared/hasOwn'
  22. import { isBase64 } from '@/uni_modules/lime-shared/isBase64'
  23. import { isBrowser } from '@/uni_modules/lime-shared/isBrowser'
  24. import { isDef } from '@/uni_modules/lime-shared/isDef'
  25. import { isEmpty } from '@/uni_modules/lime-shared/isEmpty'
  26. import { isFunction } from '@/uni_modules/lime-shared/isFunction'
  27. import { isNumber } from '@/uni_modules/lime-shared/isNumber'
  28. import { isNumeric } from '@/uni_modules/lime-shared/isNumeric'
  29. import { isObject } from '@/uni_modules/lime-shared/isObject'
  30. import { isPromise } from '@/uni_modules/lime-shared/isPromise'
  31. import { isString } from '@/uni_modules/lime-shared/isString'
  32. import { kebabCase } from '@/uni_modules/lime-shared/kebabCase'
  33. import { raf, doubleRaf } from '@/uni_modules/lime-shared/raf'
  34. import { random } from '@/uni_modules/lime-shared/random'
  35. import { range } from '@/uni_modules/lime-shared/range'
  36. import { sleep } from '@/uni_modules/lime-shared/sleep'
  37. import { throttle } from '@/uni_modules/lime-shared/throttle'
  38. import { toArray } from '@/uni_modules/lime-shared/toArray'
  39. import { toBoolean } from '@/uni_modules/lime-shared/toBoolean'
  40. import { toNumber } from '@/uni_modules/lime-shared/toNumber'
  41. import { unitConvert } from '@/uni_modules/lime-shared/unitConvert'
  42. import { getCurrentInstance } from '@/uni_modules/lime-shared/vue'
  43. import { capitalizedAmount } from '@/uni_modules/lime-shared/capitalizedAmount'
  44. // #ifdef VUE2
  45. type UTSJSONObject = any
  46. // #endif
  47. const context = getCurrentInstance()
  48. // getRect('#shared', context!).then(res =>{
  49. // console.log('res', res.bottom)
  50. // })
  51. // getAllRect('#shared', context).then(res =>{
  52. // console.log('res', res)
  53. // })
  54. // console.log('camelCase::', camelCase("hello world"));
  55. // console.log('camelCase::', camelCase("my_name_is_john", true));
  56. // console.log('canIUseCanvas2d::', canIUseCanvas2d());
  57. // console.log('clamp::', clamp(5 ,0, 10));
  58. // console.log('cloneDeep::', cloneDeep<UTSJSONObject>({a:5}));
  59. // console.log('closest::', closest([1, 3, 5, 7, 9], 6));
  60. // const saveData = (data: any) => {
  61. // // 模拟保存数据的操作
  62. // console.log(`Saving data: ${data}`);
  63. // }
  64. // const debouncedSaveData = debounce(saveData, 500);
  65. // debouncedSaveData('Data 1');
  66. // debouncedSaveData('Data 2');
  67. // console.log('fillZero', fillZero(1))
  68. // console.log('floatAdd', floatAdd(0.1, 0.2), floatAdd(1.05, 0.05), floatAdd(0.1, 0.7), floatAdd(0.0001, 0.0002), floatAdd(123.456 , 789.012))
  69. // console.log('floatMul', floatMul(0.1, 0.02), floatMul(1.0255, 100))
  70. // console.log('floatDiv', floatDiv(10.44, 100), floatDiv(1.0255, 100), floatDiv(5.419909340994699, 0.2))
  71. // console.log('floatSub', floatSub(0.4, 0.1), floatSub(1.0255, 100))
  72. const now = () : number => System.nanoTime() / 1_000_000.0
  73. console.log('capitalizedAmount', capitalizedAmount(0.4))
  74. console.log('capitalizedAmount', capitalizedAmount(100))
  75. console.log('capitalizedAmount', capitalizedAmount(100000000))
  76. console.log('capitalizedAmount', capitalizedAmount('2023.04'))
  77. console.log('capitalizedAmount', capitalizedAmount(-1024))
  78. console.log('now', now(), Date.now())
  79. // console.log('getClassStr', getClassStr({hover: true}))
  80. // console.log('getStyleStr', getStyleStr({ color: 'red', fontSize: '16px', backgroundColor: '', border: null }))
  81. // console.log('hasOwn', hasOwn({a: true}, 'key'))
  82. // console.log('isBase64::', isBase64("SGVsbG8sIFdvcmxkIQ=="));
  83. // console.log('isBrowser::', isBrowser);
  84. // console.log('isDef::', isDef('6'));
  85. // console.log('isEmpty::', isEmpty({a: true}));
  86. // const b = () =>{}
  87. // console.log('isFunction::', isFunction(b));
  88. // console.log('isNumber::', isNumber('6'));
  89. // console.log('isNumeric::', isNumeric('6'));
  90. // console.log('isObject::', isObject({}));
  91. // const promise = ():Promise<boolean> => {
  92. // return new Promise((resolve) => {
  93. // resolve(true)
  94. // })
  95. // }
  96. // const a = promise()
  97. // console.log('isPromise::', isPromise(a));
  98. // console.log('isString::', isString('null'));
  99. // console.log('kebabCase::', kebabCase('my love'));
  100. // console.log('raf::', raf(()=>{
  101. // console.log('raf:::1')
  102. // }));
  103. // console.log('doubleRaf::', doubleRaf(()=>{
  104. // console.log('doubleRaf:::1')
  105. // }));
  106. // console.log('random', random(0, 10))
  107. // console.log('random', random(0, 1, 2))
  108. // console.log('range', range(0, 10, 2))
  109. // console.log('sleep', sleep(300).then(res => {
  110. // console.log('log')
  111. // }))
  112. // const handleScroll = (a: string) => {
  113. // console.log("Scroll event handled!", a);
  114. // }
  115. // // // 使用节流函数对 handleScroll 进行节流,间隔时间为 500 毫秒
  116. // const throttledScroll = throttle(handleScroll, 500);
  117. // throttledScroll('5');
  118. // const page = getCurrentPage()
  119. // console.log('getCurrentPage::', page)
  120. // console.log('toArray', toArray<number>(5))
  121. // console.log('toBoolean', toBoolean(5))
  122. // console.log('toNumber', toNumber('5'))
  123. // console.log('unitConvert', unitConvert('5'))
  124. // uni.getImageInfo({
  125. // src: '/static/logo.png',
  126. // success(res) {
  127. // console.log('res', res)
  128. // }
  129. // })
  130. export default {
  131. }
  132. </script>
  133. <style>
  134. </style>