fix: version() 尝试两种元数据访问方式(直接/嵌套),加 qDebug 排查
This commit is contained in:
@@ -122,7 +122,16 @@ QString NetworkMonitorApplet::ipv6Address() const
|
|||||||
QString NetworkMonitorApplet::version() const
|
QString NetworkMonitorApplet::version() const
|
||||||
{
|
{
|
||||||
// metadata.json 结构:{ "Plugin": { "Version": "x.y.z", ... } }
|
// metadata.json 结构:{ "Plugin": { "Version": "x.y.z", ... } }
|
||||||
return pluginMetaData().value("Plugin").toMap().value("Version").toString();
|
// DPluginMetaData 内部存储方式不确定:可能已展开 Plugin 层级(value("Version") 直接可用),
|
||||||
|
// 也可能保留原始嵌套结构(需 value("Plugin").toMap().value("Version"))
|
||||||
|
// 两种都尝试,取非空值
|
||||||
|
const DPluginMetaData meta = pluginMetaData();
|
||||||
|
QString v = meta.value("Version").toString();
|
||||||
|
if (v.isEmpty()) {
|
||||||
|
v = meta.value("Plugin").toMap().value("Version").toString();
|
||||||
|
}
|
||||||
|
qDebug() << "[JNetApplet] version() =" << v;
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkMonitorApplet::refresh()
|
void NetworkMonitorApplet::refresh()
|
||||||
|
|||||||
Reference in New Issue
Block a user