File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,7 +346,13 @@ const toggleTheme = (event: MouseEvent) => {
346346 <p class =" dropdown-content-title" >{{ level1.name }}</p >
347347 <div class =" dropdown-content flex-center dropdown-100" >
348348 <div class =" dropdown-app hand" v-for =" app in level1.children.filter(lv => !lv.hide)" :key =" app.title" >
349- <a class =" dropdown-app" :href =" app.href" rel =" noopener noreferrer" >
349+ <a
350+ class =" dropdown-app"
351+ :href =" app.href"
352+ rel =" noopener noreferrer"
353+ :download =" app.download || false"
354+ @click =" app.onClick ? app.onClick($event) : null"
355+ >
350356 <img class =" app-dropdown-logo" :src =" app.logo" />
351357 <div >
352358 <div class =" app-title" > {{ app.title }} </div >
@@ -419,7 +425,14 @@ const toggleTheme = (event: MouseEvent) => {
419425 </div >
420426 <div v-if =" level1.children?.length" class =" dropdown-menu" >
421427 <div class =" dropdown-app hand" v-for =" app in level1.children.filter(lv => !lv.hide)" :key =" app.title" >
422- <a class =" dropdown-app" :href =" app.href" target =" _blank" rel =" noopener noreferrer" >
428+ <a
429+ class =" dropdown-app"
430+ :href =" app.href"
431+ target =" _blank"
432+ rel =" noopener noreferrer"
433+ :download =" app.download || false"
434+ @click =" app.onClick ? app.onClick($event) : null"
435+ >
423436 {{ app.title }}
424437 </a >
425438 </div >
Original file line number Diff line number Diff line change 1- const envName = import . meta. env . VITE_EnvName
21import tinyAbout from '../../../home/public/images/logo-about.svg'
32import tinyAi from '../../../home/public/images/logo-ai-extension.svg'
43import tinyTech from '../../../home/public/images/logo-tech.svg'
@@ -9,6 +8,19 @@ import tinyRobot from '../assets/appIcon/tiny-robot.svg'
98import sketch from '../../../home/public/images/logo-sketch.svg'
109
1110const createIsUnderline = ( path ) => ( ) => location . pathname . startsWith ( path )
11+ const downloadFile = ( filePath :string , fileName :string ) => {
12+ const link = document . createElement ( 'a' )
13+
14+ // 确保 filePath 不以斜杠开头
15+ const href = filePath . startsWith ( '/' ) ? filePath . slice ( 1 ) : filePath
16+ // 根据环境设置 link.href
17+ link . href = `${ import . meta. env . BASE_URL } ${ href } `
18+ link . download = fileName || 'download-file'
19+ document . body . appendChild ( link )
20+
21+ link . click ( )
22+ document . body . removeChild ( link )
23+ }
1224
1325const menuItems = [
1426 {
@@ -151,9 +163,14 @@ const menuItems = [
151163 {
152164 title : 'Sketch 资源下载' ,
153165 desc : 'Sketch 组件资源包' ,
154- href : ' /downloadFile/TinyVue3.0_UI.KIT_202508.sketch' ,
166+ href : ` /downloadFile/TinyVue3.0_UI.KIT_202508.sketch` ,
155167 logo : sketch ,
156- github : ''
168+ github : '' ,
169+ download : true ,
170+ onClick : ( event : MouseEvent ) => {
171+ event . preventDefault ( ) ;
172+ downloadFile ( `/downloadFile/TinyVue3\.0_UI\.KIT_202508\.sketch` , 'sketch' )
173+ }
157174 }
158175 ]
159176 }
You can’t perform that action at this time.
0 commit comments