Add host platform detection and macOS styles
Expose host platform to the UI and apply platform-specific styling. Backend: add CurrentPlatformName() and include "platform" in the JSON sent from NebulaController so the frontend can know the host OS. Frontend: detectHostPlatform() initializes state.platform, applyPlatform() sets a platform-* body class, and applyState() applies it. CSS: add .platform-macos rules to adjust title padding and hide window controls on macOS. Also fix FilePathToUrl to avoid producing an extra slash when the encoded path already starts with '/'.
This commit is contained in:
@@ -165,6 +165,18 @@ std::string GetChromeDisplayUrl(const std::string& url) {
|
||||
return nebula::ui::IsInternalHomeUrl(url) ? std::string{} : url;
|
||||
}
|
||||
|
||||
const char* CurrentPlatformName() {
|
||||
#if defined(_WIN32)
|
||||
return "windows";
|
||||
#elif defined(__APPLE__)
|
||||
return "macos";
|
||||
#elif defined(__linux__)
|
||||
return "linux";
|
||||
#else
|
||||
return "unknown";
|
||||
#endif
|
||||
}
|
||||
|
||||
void SetBrowserVisible(CefRefPtr<CefBrowser> browser, bool visible) {
|
||||
if (!browser) {
|
||||
return;
|
||||
@@ -1127,6 +1139,7 @@ void NebulaController::SendChromeState(const nebula::browser::NebulaTab& tab) {
|
||||
",\"canGoForward\":" + std::string(tab.CanGoForward() ? "true" : "false") +
|
||||
",\"favicon\":\"" + nebula::browser::JsonEscape(tab.favicon_url) + "\"" +
|
||||
",\"zoomLevel\":" + std::to_string(zoom_level) +
|
||||
",\"platform\":\"" + CurrentPlatformName() + "\"" +
|
||||
",\"tabs\":" + tabs_json +
|
||||
"});";
|
||||
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ std::string FilePathToUrl(std::filesystem::path path) {
|
||||
for (char ch : value) {
|
||||
encoded += ch == ' ' ? "%20" : std::string(1, ch);
|
||||
}
|
||||
return "file:///" + encoded;
|
||||
return encoded.starts_with('/') ? "file://" + encoded : "file:///" + encoded;
|
||||
}
|
||||
|
||||
std::string GetChromeUrl() {
|
||||
|
||||
Reference in New Issue
Block a user