mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 21:02:04 +08:00
fix:一包多desktop只对应最后一个
This commit is contained in:
@@ -95,13 +95,14 @@ QStringList aptssUpdater::getDesktopAppNames()
|
|||||||
packageName); // 新增包名参数
|
packageName); // 新增包名参数
|
||||||
|
|
||||||
}
|
}
|
||||||
|
qDebug()<< "应用名称列表:" << appNames;
|
||||||
return appNames;
|
return appNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringList &appNames, const QString &lang, const QString &packageName)
|
bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringList &appNames, const QString &lang, const QString &packageName)
|
||||||
{
|
{
|
||||||
bool hasFoundName = false;
|
bool hasFoundName = false;
|
||||||
|
QString lastValidName;
|
||||||
QRegularExpression noDisplayRe("^NoDisplay=(true|True)");
|
QRegularExpression noDisplayRe("^NoDisplay=(true|True)");
|
||||||
QRegularExpression nameRe("^Name\\[?" + lang + "?\\]?=(.*)");
|
QRegularExpression nameRe("^Name\\[?" + lang + "?\\]?=(.*)");
|
||||||
QRegularExpression nameOrigRe("^Name=(.*)");
|
QRegularExpression nameOrigRe("^Name=(.*)");
|
||||||
@@ -113,7 +114,7 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringLis
|
|||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue;
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue;
|
||||||
|
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
QString name;
|
QString currentName;
|
||||||
|
|
||||||
QTextStream in(&file);
|
QTextStream in(&file);
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
@@ -128,31 +129,37 @@ bool aptssUpdater::checkDesktopFiles(const QStringList &desktopFiles, QStringLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 优先匹配本地化名称
|
// 优先匹配本地化名称
|
||||||
if (name.isEmpty()) {
|
if (currentName.isEmpty()) {
|
||||||
QRegularExpressionMatch match = nameRe.match(line);
|
QRegularExpressionMatch match = nameRe.match(line);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
name = match.captured(1);
|
currentName = match.captured(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 匹配原始名称
|
// 匹配原始名称
|
||||||
match = nameOrigRe.match(line);
|
match = nameOrigRe.match(line);
|
||||||
if (match.hasMatch()) {
|
if (match.hasMatch()) {
|
||||||
name = match.captured(1);
|
currentName = match.captured(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!skip && !name.isEmpty() && !appNames.contains(name)) {
|
if (!skip && !currentName.isEmpty()) {
|
||||||
appNames << name;
|
lastValidName = currentName; // 只更新最后一个有效名称
|
||||||
hasFoundName = true; // 标记已找到有效名称
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果没有找到任何名称,则使用包名
|
// 处理最终的有效名称
|
||||||
if (!hasFoundName && !appNames.contains(packageName)) {
|
if (!lastValidName.isEmpty()) {
|
||||||
appNames << packageName;
|
if (!appNames.contains(lastValidName)) {
|
||||||
|
appNames << lastValidName;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasFoundName;
|
// 回退到包名
|
||||||
|
if (!appNames.contains(packageName)) {
|
||||||
|
appNames << packageName;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user