Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
testMenu
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蔡芬
testMenu
Commits
4a9a085d
提交
4a9a085d
authored
4月 04, 2023
作者:
macmini
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
list
上级
f0ba692e
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
4 行删除
+26
-4
package-lock.json
package-lock.json
+0
-0
softList.js
src/main/plugins/softList.js
+25
-4
mainWindow.js
src/main/windows/mainWindow.js
+1
-0
没有找到文件。
package-lock.json
deleted
100644 → 0
浏览文件 @
f0ba692e
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/main/plugins/softList.js
浏览文件 @
4a9a085d
const
{
exec
,
execSync
}
=
require
(
'child_process'
);
const
{
exec
,
execSync
}
=
require
(
'child_process'
);
const
fs
=
require
(
'fs'
);
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
class
SoftList
{
class
SoftList
{
constructor
(
mainWindow
)
{
constructor
(
mainWindow
)
{
...
@@ -29,6 +30,17 @@ class SoftList {
...
@@ -29,6 +30,17 @@ class SoftList {
}
}
}
}
/* 查找linux icon */
findIcon
(
iconName
)
{
try
{
const
stdout
=
execSync
(
`find /usr/share/icons -name "
${
iconName
}
.*"`
);
const
iconPaths
=
stdout
.
toString
().
split
(
'
\
n'
).
filter
(
path
=>
path
.
trim
()
!==
''
);
return
iconPaths
;
}
catch
(
error
)
{
console
.
error
(
`命令执行失败:
${
error
}
`
);
return
null
;
}
}
/* 获取linux 快捷方式 列表 */
/* 获取linux 快捷方式 列表 */
getLinuxList
()
{
getLinuxList
()
{
exec
(
'ls /usr/share/applications/*.desktop'
,
(
error
,
stdout
,
stderr
)
=>
{
exec
(
'ls /usr/share/applications/*.desktop'
,
(
error
,
stdout
,
stderr
)
=>
{
...
@@ -47,10 +59,17 @@ class SoftList {
...
@@ -47,10 +59,17 @@ class SoftList {
const
execCommand
=
execLine
?
execLine
.
substr
(
5
)
:
null
;
const
execCommand
=
execLine
?
execLine
.
substr
(
5
)
:
null
;
const
nameOfZhLine
=
lines
.
find
(
line
=>
line
.
startsWith
(
'Name[zh_CN]='
));
const
nameOfZhLine
=
lines
.
find
(
line
=>
line
.
startsWith
(
'Name[zh_CN]='
));
const
nameOfZh
=
nameOfZhLine
?
nameOfZhLine
.
substr
(
5
)
:
''
;
const
nameOfZh
=
nameOfZhLine
?
nameOfZhLine
.
substr
(
5
)
:
''
;
// 图标为SVG或PNG格式
// icon判断是否绝对路径
if
(
icon
&&
icon
.
indexOf
(
".png"
)
==
-
1
)
{
if
(
!
path
.
isAbsolute
(
icon
)
)
{
icon
=
`/usr/share/icons/hicolor/48x48/apps/
${
icon
}
.png`
let
iconList
=
this
.
findIcon
(
icon
);
if
(
iconList
.
length
>
0
)
{
icon
=
iconList
[
0
];
}
}
}
// 图标为SVG或PNG格式
// if(icon && icon.indexOf(".png") == -1) {
// icon = `/usr/share/icons/hicolor/48x48/apps/${icon}.png`
// }
// icon = `/usr/share/icons/hicolor/48x48/apps/${icon}`
// icon = `/usr/share/icons/hicolor/48x48/apps/${icon}`
// 2. 打开应用程序的.desktop文件,并查找“Icon=”行。这一行包含应用程序的图标文件的路径。
// 2. 打开应用程序的.desktop文件,并查找“Icon=”行。这一行包含应用程序的图标文件的路径。
...
@@ -221,6 +240,7 @@ class SoftList {
...
@@ -221,6 +240,7 @@ class SoftList {
addFile
.
execCommand
=
`open '
${
addFile
.
path
}
'`
;
addFile
.
execCommand
=
`open '
${
addFile
.
path
}
'`
;
addFile
.
name
=
addFile
.
shortName
;
addFile
.
name
=
addFile
.
shortName
;
// addFile.icon = '';
// addFile.icon = '';
// process.platform === 'linux'
addFile
.
icon
=
this
.
softList
.
getMacIconPath
({
fileName
:
addFile
.
shortName
,
appPath
:
addFile
.
path
});
addFile
.
icon
=
this
.
softList
.
getMacIconPath
({
fileName
:
addFile
.
shortName
,
appPath
:
addFile
.
path
});
addFile
.
icon
=
this
.
softList
.
icns2Png
({
iconPath
:
addFile
.
icon
,
fileNameShort
:
addFile
.
shortName
});
addFile
.
icon
=
this
.
softList
.
icns2Png
({
iconPath
:
addFile
.
icon
,
fileNameShort
:
addFile
.
shortName
});
addFile
.
icon
=
this
.
softList
.
pngToBase64
(
addFile
.
icon
);
addFile
.
icon
=
this
.
softList
.
pngToBase64
(
addFile
.
icon
);
...
@@ -245,7 +265,8 @@ class SoftList {
...
@@ -245,7 +265,8 @@ class SoftList {
// return this.$t(i)
// return this.$t(i)
return
1
return
1
}
}
}
}
}
}
export
default
SoftList
export
default
SoftList
src/main/windows/mainWindow.js
浏览文件 @
4a9a085d
...
@@ -31,6 +31,7 @@ class MainWindow {
...
@@ -31,6 +31,7 @@ class MainWindow {
}
else
{
}
else
{
createProtocol
(
'app'
)
createProtocol
(
'app'
)
this
.
win
.
loadURL
(
'app://./index.html'
)
this
.
win
.
loadURL
(
'app://./index.html'
)
this
.
win
.
webContents
.
openDevTools
({
mode
:
'detach'
})
}
}
this
.
win
.
on
(
'closed'
,
()
=>
{
this
.
win
.
on
(
'closed'
,
()
=>
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论