@complex-suite/component
Advanced tools
+15
-1
@@ -12,2 +12,13 @@ import { reactive } from "vue" | ||
| let decimalStr = '' | ||
| let isNegative = false | ||
| // 先取绝对值处理,避免负数导致小数部分 slice(1) 截取错误("-0.56".slice(1) => "0.56" 而非 ".56") | ||
| if (typeof data === 'number') { | ||
| if (data < 0) { | ||
| isNegative = true | ||
| data = -data | ||
| } | ||
| } else if (typeof data === 'string' && data.startsWith('-')) { | ||
| isNegative = true | ||
| data = data.slice(1) | ||
| } | ||
| if (decimal) { | ||
@@ -17,3 +28,3 @@ let decimalData = 0; | ||
| if (decimalData) { | ||
| // 去掉首位的0 | ||
| // 此时 decimalData 为正数,toString 以 "0." 开头,slice(1) 去掉 "0" 得到 ".xxx" | ||
| decimalStr = decimalData.toString().slice(1) | ||
@@ -31,2 +42,5 @@ } | ||
| } | ||
| if (isNegative) { | ||
| strList.unshift('-') | ||
| } | ||
| if (list) { | ||
@@ -33,0 +47,0 @@ return decimalStr ? strList.concat(decimalStr.split('')) : strList |
+18
-2
@@ -0,2 +1,20 @@ | ||
| <!-- | ||
| 版本规则: | ||
| - 顶部 `### current` 记录当前未发版的改动(可能为空)。 | ||
| - 版本升级发版时,将 `current` 更替为本次发版版本号(如 `### 5.0.12`),并在其上方新建一个空的 `### current`。 | ||
| - 这样每次发版后,顶部始终保留一个 `### current`(可能为空)用于记录后续改动。 | ||
| --> | ||
| ### current | ||
| ### 5.0.15 | ||
| - fix(file-view): `FileView.checkAccept` 通配符分支 `if (fileType && acceptItem.includes('*'))` 改为 `else if`,与前面的 startsWith/精确匹配分支形成互斥语义,逻辑等价。 | ||
| - fix(file-view): `FileView.checkAccept` 无扩展名时 `parts.length > 1` 才取扩展名,无扩展名时 fileName 为空字符串,避免与 ext 匹配。 | ||
| - fix(high-text): `HighText.getHighIndex` 返回 `Set<number>`,`initList` 用 `indexSet.has(index)` O(1) 查找,替代原 Array.includes O(n) 遍历。 | ||
| - fix(config): `parseNumberByComma` 修复负数+小数输出错误,先取绝对值处理,最后补负号,避免 `"-0.56".slice(1)` 截取错误。 | ||
| - fix(number-change): `NumberChange` 卸载时调用 `cancelAnimationFrame` 清理 rAF,避免动画未完成时卸载导致 rAF 残留。 | ||
| - fix(high-text): `HighText` 的 watch 增加 `target`/`limitNum`/`limitCase` 监听,这几个属性变化时重新构建高亮列表。 | ||
| - fix(file-view): `FileView.checkAccept` 校验时 `accept.split(',').map(s => s.trim().toLowerCase())`,兼容带空格或大写的 accept 配置,避免合法文件被误判拒绝。 | ||
| - fix(high-text): `HighText` 渲染时先展开 `...option` 再赋值合并后的 class(合并 baseClass 和 option.class),保留默认高亮 class 不被覆盖。 | ||
| ### `5.0.11` | ||
@@ -23,4 +41,2 @@ - chore: 小版本升级,保持与套件其他子包版本同步。 | ||
| ### Doing | ||
| ### `4.10.4` | ||
@@ -27,0 +43,0 @@ - refactor: 将TypeScript类型导入语法升级为type关键字形式 |
+4
-4
| { | ||
| "name": "@complex-suite/component", | ||
| "version": "5.0.14", | ||
| "version": "5.0.15", | ||
| "description": "a complex component", | ||
@@ -15,5 +15,5 @@ "type": "module", | ||
| "dependencies": { | ||
| "@complex-suite/data": "5.0.14", | ||
| "@complex-suite/utils": "3.0.14", | ||
| "@complex-suite/plugin": "5.0.14" | ||
| "@complex-suite/plugin": "5.0.15", | ||
| "@complex-suite/utils": "3.0.15", | ||
| "@complex-suite/data": "5.0.15" | ||
| }, | ||
@@ -20,0 +20,0 @@ "peerDependencies": { |
@@ -49,3 +49,4 @@ <template> | ||
| change: false, | ||
| currentData: 0 | ||
| currentData: 0, | ||
| rafId: 0 | ||
| } | ||
@@ -61,2 +62,7 @@ }, | ||
| }, | ||
| beforeUnmount() { | ||
| if (this.rafId) { | ||
| cancelAnimationFrame(this.rafId) | ||
| } | ||
| }, | ||
| methods: { | ||
@@ -76,3 +82,3 @@ onChange() { | ||
| this.currentData = getNum((startData + currentOffset), 'round', decimal) | ||
| requestAnimationFrame(step) | ||
| this.rafId = requestAnimationFrame(step) | ||
| } else { | ||
@@ -84,3 +90,3 @@ this.currentData = this.data | ||
| } | ||
| requestAnimationFrame(step) | ||
| this.rafId = requestAnimationFrame(step) | ||
| } | ||
@@ -87,0 +93,0 @@ } |
@@ -48,4 +48,6 @@ <style scoped> | ||
| const fileType = file.type | ||
| const fileName = '.' + file.name.split('.').pop()?.toLowerCase() | ||
| const acceptList = accept.split(',') | ||
| const parts = file.name.split('.') | ||
| const ext = parts.length > 1 ? parts.pop()!.toLowerCase() : '' | ||
| const fileName = ext ? '.' + ext : '' | ||
| const acceptList = accept.split(',').map(s => s.trim().toLowerCase()) | ||
| return acceptList.some(acceptItem => { | ||
@@ -56,3 +58,3 @@ if (acceptItem.startsWith('.')) { | ||
| return true | ||
| } if (fileType && acceptItem.includes('*')) { | ||
| } else if (fileType && acceptItem.includes('*')) { | ||
| acceptItem = acceptItem.split('*').join('') | ||
@@ -59,0 +61,0 @@ return fileType.includes(acceptItem) |
@@ -48,2 +48,11 @@ import { defineComponent, h, PropType } from "vue" | ||
| } | ||
| }, | ||
| target() { | ||
| this.initList(this.data as string | number | undefined) | ||
| }, | ||
| limitNum() { | ||
| this.initList(this.data as string | number | undefined) | ||
| }, | ||
| limitCase() { | ||
| this.initList(this.data as string | number | undefined) | ||
| } | ||
@@ -60,6 +69,6 @@ }, | ||
| }) | ||
| const indexList = this.getHighIndex(findList, this.target.length) | ||
| const indexSet = this.getHighIndex(findList, this.target.length) | ||
| this.list = origindata.split('').map((char, index) => ({ | ||
| data: char, | ||
| high: indexList.includes(index) | ||
| high: indexSet.has(index) | ||
| })) | ||
@@ -69,9 +78,9 @@ } | ||
| getHighIndex(startList: number[], size: number) { | ||
| const list = [] | ||
| const set = new Set<number>() | ||
| for (let i = 0; i < startList.length; i++) { | ||
| for (let n = 0; n < size; n++) { | ||
| list.push(startList[i] + n) | ||
| set.add(startList[i] + n) | ||
| } | ||
| } | ||
| return list | ||
| return set | ||
| } | ||
@@ -84,5 +93,9 @@ }, | ||
| const option = !item.high ? this.defaultOption : this.highOption | ||
| // 合并 class 而非覆盖,保留默认高亮 class | ||
| const baseClass = !item.high ? '' : 'complex-high-text-is-high' | ||
| const optionClass = option?.class | ||
| const mergedClass = [baseClass, optionClass].filter(Boolean).join(' ') || undefined | ||
| return h('span', { | ||
| class: !item.high ? '' : 'complex-high-text-is-high', | ||
| ...option | ||
| ...option, | ||
| class: mergedClass | ||
| }, item.data) | ||
@@ -89,0 +102,0 @@ })) |
31969
10.38%405
7.14%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated