33e56fb56f
桌面壳移除未由 Rust 真实驱动的 network.statusChanged 能力 桌面网络状态保留 Rust 主站可达性主动查询 门禁禁止桌面网络事件回退到 WebView online 状态 文档和项目记忆同步桌面网络能力边界
117 lines
3.4 KiB
Rust
117 lines
3.4 KiB
Rust
pub(crate) fn capabilities() -> Vec<&'static str> {
|
|
vec![
|
|
"host.getRuntime",
|
|
"appearance.getColorScheme",
|
|
"host.events",
|
|
"app.lifecycle",
|
|
"share.open",
|
|
"share.setTarget",
|
|
"navigation.openNativePage",
|
|
"navigation.canGoBack",
|
|
"app.reloadWebView",
|
|
"app.openExternalUrl",
|
|
"app.setTitle",
|
|
"app.setBadgeCount",
|
|
"network.status",
|
|
"clipboard.writeText",
|
|
"clipboard.readText",
|
|
"file.exportText",
|
|
"file.importText",
|
|
"file.importDocument",
|
|
"file.exportImage",
|
|
"file.importImage",
|
|
"file.importAudio",
|
|
"file.exportAudio",
|
|
"file.imageDropped",
|
|
"notification.showLocal",
|
|
]
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use serde_json::Value;
|
|
use std::collections::HashSet;
|
|
|
|
#[test]
|
|
fn runtime_capability_list_stays_ordered() {
|
|
assert_eq!(
|
|
capabilities(),
|
|
vec![
|
|
"host.getRuntime",
|
|
"appearance.getColorScheme",
|
|
"host.events",
|
|
"app.lifecycle",
|
|
"share.open",
|
|
"share.setTarget",
|
|
"navigation.openNativePage",
|
|
"navigation.canGoBack",
|
|
"app.reloadWebView",
|
|
"app.openExternalUrl",
|
|
"app.setTitle",
|
|
"app.setBadgeCount",
|
|
"network.status",
|
|
"clipboard.writeText",
|
|
"clipboard.readText",
|
|
"file.exportText",
|
|
"file.importText",
|
|
"file.importDocument",
|
|
"file.exportImage",
|
|
"file.importImage",
|
|
"file.importAudio",
|
|
"file.exportAudio",
|
|
"file.imageDropped",
|
|
"notification.showLocal",
|
|
]
|
|
);
|
|
assert!(Value::from(capabilities()).as_array().is_some());
|
|
}
|
|
|
|
#[test]
|
|
fn runtime_capability_list_keeps_desktop_boundaries() {
|
|
let desktop_capabilities = capabilities();
|
|
let unique_capabilities = desktop_capabilities.iter().copied().collect::<HashSet<_>>();
|
|
|
|
assert_eq!(unique_capabilities.len(), desktop_capabilities.len());
|
|
|
|
for capability in [
|
|
"host.getRuntime",
|
|
"appearance.getColorScheme",
|
|
"host.events",
|
|
"app.lifecycle",
|
|
"share.open",
|
|
"share.setTarget",
|
|
"navigation.openNativePage",
|
|
"navigation.canGoBack",
|
|
"app.reloadWebView",
|
|
"app.openExternalUrl",
|
|
"app.setTitle",
|
|
"app.setBadgeCount",
|
|
"network.status",
|
|
"clipboard.writeText",
|
|
"clipboard.readText",
|
|
"file.exportText",
|
|
"file.importText",
|
|
"file.importDocument",
|
|
"file.exportImage",
|
|
"file.importImage",
|
|
"file.importAudio",
|
|
"file.exportAudio",
|
|
"file.imageDropped",
|
|
"notification.showLocal",
|
|
] {
|
|
assert!(desktop_capabilities.contains(&capability));
|
|
}
|
|
|
|
for capability in [
|
|
"auth.requestLogin",
|
|
"payment.request",
|
|
"file.captureImage",
|
|
"scanner.scanQrCode",
|
|
"haptics.impact",
|
|
] {
|
|
assert!(!desktop_capabilities.contains(&capability));
|
|
}
|
|
}
|
|
}
|