Skip to content

Commit

Permalink
fixbug
Browse files Browse the repository at this point in the history
  • Loading branch information
angelbests committed Nov 19, 2024
1 parent b7bfd81 commit ade1462
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ crate-type = ["lib", "cdylib", "staticlib"]
tauri-build = { version = "2.0.1", features = [] }
# "devtools"
[dependencies]
tauri = { version = "2.0.2", features = ["protocol-asset", "tray-icon", "image-png", "image-ico"] }
tauri = { version = "2.0.2", features = ["protocol-asset", "tray-icon", "image-png", "image-ico", "devtools"] }
tauri-plugin-shell = "2.0.1"
tauri-plugin-process = "2.0.1"
tauri-plugin-fs = "2.0.1"
Expand Down
30 changes: 25 additions & 5 deletions src/functions/peIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export const setIcon =async function(){
if(ext == 'lnk'){
if(lnks[i].iconLocationPeFile == ""){
// 无图标路径
ext = await extname(lnks[i].targetPath);
try{
ext = await extname(lnks[i].targetPath);
}catch(error){
console.log(error,1,lnks[i])
continue;
}
if(ext == "exe" || ext == "dll" || ext == "ocx" || ext == 'cpl' ){
let icodir = await getIcon(await resolve(lnks[i].targetPath),path)
if(icodir){
Expand Down Expand Up @@ -55,7 +60,12 @@ export const setIcon =async function(){
lnks[i].icoPath = icodir + res[Number(lnks[i].iconLocation)].name
}else if(Number(lnks[i].iconLocation)<0){
let name = await basename(pePath)
name = name.replace("."+await extname(name),"")
try {
name = name.replace("."+await extname(name),"")
} catch (error) {
console.log(error,2,lnks[i])
continue;
}
lnks[i].icoPath = icodir + name + "_" + Math.abs(Number(lnks[i].iconLocation)) + '.ico'
}else{
// 非数字结果
Expand All @@ -68,7 +78,12 @@ export const setIcon =async function(){
}else{
try {
// 有图标路径
ext = await extname(await basename(lnks[i].iconLocationPeFile))
try {
ext = await extname(await basename(lnks[i].iconLocationPeFile))
} catch (error) {
console.log(error,3,lnks[i])
continue;
}
if(ext =='ico' || ext == 'png'){
// 图标路径指向ico路径
if(await exists(lnks[i].iconLocationPeFile)){
Expand All @@ -93,7 +108,12 @@ export const setIcon =async function(){
lnks[i].icoPath = icodir + res[Number(lnks[i].iconLocation)].name
}else if(Number(lnks[i].iconLocation)<0){
let name = await basename(lnks[i].iconLocationPeFile)
name = name.replace("."+await extname(name),"")
try {
name = name.replace("."+await extname(name),"")
} catch (error) {
console.log(error,4,lnks[i])
continue;
}
lnks[i].icoPath = icodir + name + "_" + Math.abs(Number(lnks[i].iconLocation)) + '.ico'
}else{
// 非数字结果
Expand All @@ -113,7 +133,7 @@ export const setIcon =async function(){
}else if(ext == 'url'){
// url快捷方式
let urlico = await getUrlInfo(lnks[i].lnkPath)
if(urlico){
if(await exists(urlico)){
let icoPath = await resolve(path,"other") + '\\'+uuid()+'.ico'
let res = await readFile(urlico);
await writeFile(icoPath,res)
Expand Down

0 comments on commit ade1462

Please sign in to comment.