1
1
<script setup lang="ts">
2
2
import { computed , nextTick , ref , shallowRef , watch } from ' vue'
3
3
import type { Ref } from ' vue'
4
- import { SearchIcon , XIcon } from ' @modrinth/assets'
4
+ import { SearchIcon , XIcon , ClipboardCopyIcon , GlobeIcon , ExternalIcon } from ' @modrinth/assets'
5
5
import type { Category , GameVersion , Platform , ProjectType , SortType , Tags } from ' @modrinth/ui'
6
6
import {
7
7
SearchFilterControl ,
@@ -25,6 +25,8 @@ import NavTabs from '@/components/ui/NavTabs.vue'
25
25
import type Instance from ' @/components/ui/Instance.vue'
26
26
import InstanceIndicator from ' @/components/ui/InstanceIndicator.vue'
27
27
import { defineMessages , useVIntl } from ' @vintl/vintl'
28
+ import ContextMenu from ' @/components/ui/ContextMenu.vue'
29
+ import { openUrl } from ' @tauri-apps/plugin-opener'
28
30
29
31
const { formatMessage } = useVIntl ()
30
32
@@ -351,6 +353,36 @@ const messages = defineMessages({
351
353
},
352
354
})
353
355
356
+ const options = ref (null )
357
+ const handleRightClick = (event , result ) => {
358
+ options .value .showMenu (event , result , [
359
+ {
360
+ name: ' install' ,
361
+ },
362
+ {
363
+ type: ' divider' ,
364
+ },
365
+ {
366
+ name: ' open_link' ,
367
+ },
368
+ {
369
+ name: ' copy_link' ,
370
+ },
371
+ ])
372
+ }
373
+ const handleOptionsClick = (args ) => {
374
+ switch (args .option ) {
375
+ case ' open_link' :
376
+ openUrl (` https://modrinth.com/${args .item .project_type }/${args .item .slug } ` )
377
+ break
378
+ case ' copy_link' :
379
+ navigator .clipboard .writeText (
380
+ ` https://modrinth.com/${args .item .project_type }/${args .item .slug } ` ,
381
+ )
382
+ break
383
+ }
384
+ }
385
+
354
386
await refreshSearch ()
355
387
</script >
356
388
@@ -477,7 +509,12 @@ await refreshSearch()
477
509
newlyInstalled.push(id)
478
510
}
479
511
"
512
+ @contextmenu.prevent.stop =" (event) => handleRightClick(event, result)"
480
513
/>
514
+ <ContextMenu ref =" options" @option-clicked =" handleOptionsClick" >
515
+ <template #open_link > <GlobeIcon /> Open in Modrinth <ExternalIcon /> </template >
516
+ <template #copy_link > <ClipboardCopyIcon /> Copy link </template >
517
+ </ContextMenu >
481
518
</section >
482
519
<div class =" flex justify-end" >
483
520
<pagination
0 commit comments