Skip to content

Commit 56f6415

Browse files
committed
fix: fix example problem
1 parent 0d7d851 commit 56f6415

File tree

9 files changed

+78
-49
lines changed

9 files changed

+78
-49
lines changed

package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nova-admin",
33
"type": "module",
4-
"version": "0.9.14",
4+
"version": "0.9.15",
55
"private": true,
66
"description": "a clean and concise back-end management template based on Vue3, Vite5, Typescript, and Naive UI.",
77
"author": {
@@ -50,42 +50,42 @@
5050
"sizecheck": "npx vite-bundle-visualizer"
5151
},
5252
"dependencies": {
53-
"@vueuse/core": "^13.1.0",
54-
"alova": "^3.2.10",
53+
"@vueuse/core": "^13.3.0",
54+
"alova": "^3.3.2",
5555
"colord": "^2.9.3",
5656
"echarts": "^5.6.0",
57-
"md-editor-v3": "^5.4.5",
58-
"pinia": "^3.0.2",
59-
"pinia-plugin-persistedstate": "^4.2.0",
57+
"md-editor-v3": "^5.6.1",
58+
"pinia": "^3.0.3",
59+
"pinia-plugin-persistedstate": "^4.3.0",
6060
"quill": "^2.0.3",
6161
"radash": "^12.1.0",
62-
"vue": "^3.5.13",
62+
"vue": "^3.5.16",
6363
"vue-draggable-plus": "^0.6.0",
64-
"vue-i18n": "^11.1.3",
65-
"vue-router": "^4.5.0"
64+
"vue-i18n": "^11.1.5",
65+
"vue-router": "^4.5.1"
6666
},
6767
"devDependencies": {
68-
"@antfu/eslint-config": "^4.12.0",
68+
"@antfu/eslint-config": "^4.14.1",
6969
"@iconify-json/icon-park-outline": "^1.2.2",
7070
"@iconify/vue": "^4.3.0",
71-
"@types/node": "^22.14.1",
72-
"@vitejs/plugin-vue": "^5.2.3",
73-
"@vitejs/plugin-vue-jsx": "^4.1.2",
74-
"eslint": "^9.24.0",
75-
"lint-staged": "^15.5.1",
76-
"naive-ui": "^2.41.0",
71+
"@types/node": "^24.0.1",
72+
"@vitejs/plugin-vue": "^5.2.4",
73+
"@vitejs/plugin-vue-jsx": "^4.2.0",
74+
"eslint": "^9.29.0",
75+
"lint-staged": "^16.1.2",
76+
"naive-ui": "^2.41.1",
7777
"sass": "^1.86.3",
78-
"simple-git-hooks": "^2.12.1",
78+
"simple-git-hooks": "^2.13.0",
7979
"typescript": "^5.8.3",
80-
"unocss": "^0.65.4",
81-
"unplugin-auto-import": "^19.1.2",
80+
"unocss": "^66.2.0",
81+
"unplugin-auto-import": "^19.3.0",
8282
"unplugin-icons": "^22.1.0",
83-
"unplugin-vue-components": "^28.5.0",
84-
"vite": "^6.2.6",
83+
"unplugin-vue-components": "^28.7.0",
84+
"vite": "^6.3.5",
8585
"vite-bundle-visualizer": "^1.2.1",
8686
"vite-plugin-compression": "^0.5.1",
87-
"vite-plugin-vue-devtools": "7.7.2",
88-
"vue-tsc": "^2.2.8"
87+
"vite-plugin-vue-devtools": "7.7.6",
88+
"vue-tsc": "^2.2.10"
8989
},
9090
"simple-git-hooks": {
9191
"pre-commit": "pnpm lint-staged"

src/components/common/IconSelect.vue

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,22 @@ function handleSelectIconTag(icon: string) {
9595
9696
// 包含当前分类或所有图标列表
9797
const icons = computed(() => {
98+
if (!iconList.value[currentTab.value])
99+
return []
98100
const hasTag = !!currentTag.value
99-
if (hasTag)
100-
return iconList.value[currentTab.value]?.categories[currentTag.value]
101-
else
102-
return iconList.value[currentTab.value].icons
101+
return hasTag
102+
? iconList.value[currentTab.value]?.categories[currentTag.value] || []
103+
: iconList.value[currentTab.value].icons || []
103104
})
104105
105106
// 符合搜索条件的图标列表
107+
const filteredIcons = computed(() => {
108+
return icons.value?.filter(i => i.includes(searchValue.value)) || []
109+
})
110+
111+
// 当前页显示的图标
106112
const visibleIcons = computed(() => {
107-
return icons.value?.filter(i => i
108-
.includes(searchValue.value))?.slice((currentPage.value - 1) * 200, (currentPage.value) * 200)
113+
return filteredIcons.value.slice((currentPage.value - 1) * 200, currentPage.value * 200)
109114
})
110115
111116
const showModal = ref(false)
@@ -191,7 +196,7 @@ function clearIcon() {
191196
<n-flex justify="center">
192197
<n-pagination
193198
v-model:page="currentPage"
194-
:item-count="icons?.length"
199+
:item-count="filteredIcons.length"
195200
:page-size="200"
196201
/>
197202
</n-flex>

src/hooks/useTabScroll.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NScrollbar } from 'naive-ui'
2-
import { ref, watchEffect, type Ref } from 'vue'
2+
import { ref, type Ref, watchEffect } from 'vue'
33
import { throttle } from 'radash'
44

55
export function useTabScroll(currentTabPath: Ref<string>) {
@@ -9,7 +9,7 @@ export function useTabScroll(currentTabPath: Ref<string>) {
99
const handleTabSwitch = (distance: number) => {
1010
scrollbar.value?.scrollTo({
1111
left: distance,
12-
behavior: 'smooth'
12+
behavior: 'smooth',
1313
})
1414
}
1515

@@ -18,7 +18,7 @@ export function useTabScroll(currentTabPath: Ref<string>) {
1818
const currentTabElement = document.querySelector(`[data-tab-path="${currentTabPath.value}"]`) as HTMLElement
1919
const tabBarScrollWrapper = document.querySelector('.tab-bar-scroller-wrapper .n-scrollbar-container')
2020
const tabBarScrollContent = document.querySelector('.tab-bar-scroller-content')
21-
21+
2222
if (currentTabElement && tabBarScrollContent && tabBarScrollWrapper) {
2323
const tabLeft = currentTabElement.offsetLeft
2424
const tabBarLeft = tabBarScrollWrapper.scrollLeft
@@ -28,7 +28,8 @@ export function useTabScroll(currentTabPath: Ref<string>) {
2828

2929
if (tabLeft + tabWidth + safeArea.value + containerPR > wrapperWidth + tabBarLeft) {
3030
handleTabSwitch(tabLeft + tabWidth + containerPR - wrapperWidth + safeArea.value)
31-
} else if (tabLeft - safeArea.value < tabBarLeft) {
31+
}
32+
else if (tabLeft - safeArea.value < tabBarLeft) {
3233
handleTabSwitch(tabLeft - safeArea.value)
3334
}
3435
}
@@ -38,7 +39,7 @@ export function useTabScroll(currentTabPath: Ref<string>) {
3839
const handleScroll = throttle({ interval: 120 }, (step: number) => {
3940
scrollbar.value?.scrollBy({
4041
left: step * 400,
41-
behavior: 'smooth'
42+
behavior: 'smooth',
4243
})
4344
})
4445

@@ -59,6 +60,6 @@ export function useTabScroll(currentTabPath: Ref<string>) {
5960
scrollbar,
6061
onWheel,
6162
safeArea,
62-
handleTabSwitch
63+
handleTabSwitch,
6364
}
6465
}

src/service/http/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { $t } from '@/utils'
2+
23
/** 默认实例的Aixos配置 */
34
export const DEFAULT_ALOVA_OPTIONS = {
45
// 请求超时时间,默认15秒

src/typings/global.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ declare namespace NaiveUI {
2828
type ThemeColor = 'default' | 'error' | 'primary' | 'info' | 'success' | 'warning'
2929
}
3030

31-
// 修复naive-ui的TabPane组件的slots类型 https://github.com/tusen-ai/naive-ui/issues/6779 ,但是直接这样会导致更多类型报错,也无法查看naive-ui的源码
32-
// declare module 'naive-ui' {
33-
// interface TabPaneSlots {
34-
// tab?: () => VNode[]
35-
// }
36-
// }
3731
declare namespace Storage {
3832
interface Session {
3933
dict: DictMap

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './storage'
22
export * from './array'
33
export * from './i18n'
44
export * from './icon'
5+
export * from './normalize'

src/utils/normalize.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* 统一化存储单位,字节转化为英文缩写`bytes`, `KB`, `MB`, `GB`
3+
*
4+
* @param {number} bytes 需要转换的字节大小
5+
* @returns {string} 转化后的字节字符串
6+
* @example
7+
* ```
8+
* // Output: '1 MB'
9+
* normalizeSizeUnits(1048576)
10+
* ```
11+
*/
12+
export function normalizeSizeUnits(bytes: number): string {
13+
if (bytes === 0)
14+
return '0 bytes'
15+
16+
const units = ['bytes', 'KB', 'MB', 'GB']
17+
const index = Math.floor(Math.log(bytes) / Math.log(1024))
18+
const size = +(bytes / 1024 ** index).toFixed(2)
19+
const unit = units[index]
20+
21+
return `${size} ${unit}`
22+
}

src/views/dashboard/workbench/components/chart.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { useEcharts } from '@/hooks'
33
import type { ECOption } from '@/hooks'
4+
45
// 折线图
56
const lineOptions = ref<ECOption>({
67
tooltip: {

src/views/demo/fetch/components/DownLoadWithProgress.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import {
33
downloadFile,
44
} from '@/service'
55
import { useRequest } from 'alova/client'
6+
import { normalizeSizeUnits } from '@/utils'
67
78
const emit = defineEmits<{
89
update: [data: any]
910
}>()
1011
11-
const filePath = ref('https://images.unsplash.com/photo-1663529628961-80aa6ebcd157?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=764&q=80')
12+
const fileURL = ref('https://images.unsplash.com/photo-1663529628961-80aa6ebcd157?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=764&q=80')
1213
13-
const { downloading, abort, send, data } = useRequest(downloadFile(filePath.value), {
14+
const { loading, downloading, abort, send, data } = useRequest(() => downloadFile(fileURL.value), {
1415
// 当immediate为false时,默认不发出
1516
immediate: false,
1617
})
@@ -24,7 +25,10 @@ const downloadProcess = computed(() => {
2425
async function handleDownloadFile() {
2526
await send()
2627
emit('update', 'fileOk')
27-
downloadLink(data.value, 'fileOk')
28+
const urlObj = new URL(fileURL.value)
29+
const pathname = urlObj.pathname
30+
const name = pathname.split('/')[1]
31+
downloadLink(data.value, name)
2832
}
2933
3034
function downloadLink(data: Blob, name: string) {
@@ -42,10 +46,10 @@ function downloadLink(data: Blob, name: string) {
4246
<template>
4347
<n-card title="带进度的下载文件" size="small">
4448
<n-space vertical>
45-
<n-input v-model:value="filePath" />
46-
<div>文件大小:{{ downloading.total }}B</div>
47-
<div>已下载:{{ downloading.loaded }}B</div>
48-
<n-progress type="line" indicator-placement="inside" :percentage="downloadProcess" />
49+
<n-input v-model:value="fileURL" />
50+
<div>文件大小:{{ normalizeSizeUnits(downloading.total) }}</div>
51+
<div>已下载:{{ normalizeSizeUnits(downloading.loaded) }}</div>
52+
<n-progress type="line" indicator-placement="inside" :processing="loading" :percentage="downloadProcess" />
4953
<n-space>
5054
<n-button strong secondary @click="handleDownloadFile">
5155
开始下载

0 commit comments

Comments
 (0)