完善功能
This commit is contained in:
53
src-tauri/nsis-hooks.nsh
Normal file
53
src-tauri/nsis-hooks.nsh
Normal file
@@ -0,0 +1,53 @@
|
||||
; NSIS installer hooks for yurou
|
||||
; Override file association DefaultIcon to use custom file icon (yurou-sys.png → file-icon.ico)
|
||||
|
||||
!macro NSIS_HOOK_POSTINSTALL
|
||||
; Read the file class (ProgID) registered by Tauri's APP_ASSOCIATE,
|
||||
; then overwrite its DefaultIcon to point to our custom file-icon.ico
|
||||
; instead of the application exe icon.
|
||||
;
|
||||
; This repeats for every extension we registered.
|
||||
; If the extension was not associated (backup value is empty) we skip it.
|
||||
|
||||
!define YUROU_FILE_ICON '"$INSTDIR\file-icon.ico"'
|
||||
|
||||
; .md
|
||||
ReadRegStr $0 SHCTX "Software\Classes\.md" ""
|
||||
StrCmp $0 "" +2 +1
|
||||
WriteRegStr SHCTX "Software\Classes\$0\DefaultIcon" "" ${YUROU_FILE_ICON}
|
||||
|
||||
; .markdown
|
||||
ReadRegStr $0 SHCTX "Software\Classes\.markdown" ""
|
||||
StrCmp $0 "" +2 +1
|
||||
WriteRegStr SHCTX "Software\Classes\$0\DefaultIcon" "" ${YUROU_FILE_ICON}
|
||||
|
||||
; .mdown
|
||||
ReadRegStr $0 SHCTX "Software\Classes\.mdown" ""
|
||||
StrCmp $0 "" +2 +1
|
||||
WriteRegStr SHCTX "Software\Classes\$0\DefaultIcon" "" ${YUROU_FILE_ICON}
|
||||
|
||||
; .mkdn
|
||||
ReadRegStr $0 SHCTX "Software\Classes\.mkdn" ""
|
||||
StrCmp $0 "" +2 +1
|
||||
WriteRegStr SHCTX "Software\Classes\$0\DefaultIcon" "" ${YUROU_FILE_ICON}
|
||||
|
||||
; .mkd
|
||||
ReadRegStr $0 SHCTX "Software\Classes\.mkd" ""
|
||||
StrCmp $0 "" +2 +1
|
||||
WriteRegStr SHCTX "Software\Classes\$0\DefaultIcon" "" ${YUROU_FILE_ICON}
|
||||
|
||||
; .mdwn
|
||||
ReadRegStr $0 SHCTX "Software\Classes\.mdwn" ""
|
||||
StrCmp $0 "" +2 +1
|
||||
WriteRegStr SHCTX "Software\Classes\$0\DefaultIcon" "" ${YUROU_FILE_ICON}
|
||||
|
||||
!undef YUROU_FILE_ICON
|
||||
|
||||
; Notify Windows shell about the association change
|
||||
System::Call "shell32::SHChangeNotify(i,i,i,i) (0x08000000, 0x1000, 0, 0)"
|
||||
!macroend
|
||||
|
||||
!macro NSIS_HOOK_PREUNINSTALL
|
||||
; Cleanup is handled automatically by APP_UNASSOCIATE which deletes the
|
||||
; entire ProgID key — our custom DefaultIcon is removed along with it.
|
||||
!macroend
|
||||
Reference in New Issue
Block a user