mirror of https://github.com/logseq/logseq
improve(ios): add plugin util to get document root path
parent
7ddfa66004
commit
2256b63e88
|
@ -10,4 +10,5 @@
|
|||
|
||||
CAP_PLUGIN(Utils, "Utils",
|
||||
CAP_PLUGIN_METHOD(isZoomed, CAPPluginReturnPromise);
|
||||
CAP_PLUGIN_METHOD(getDocumentRoot, CAPPluginReturnPromise);
|
||||
)
|
||||
|
|
|
@ -14,9 +14,21 @@ public class Utils: CAPPlugin {
|
|||
@objc func isZoomed(_ call: CAPPluginCall) {
|
||||
|
||||
var isZoomed: Bool {
|
||||
return UIScreen.main.scale < UIScreen.main.nativeScale
|
||||
UIScreen.main.scale < UIScreen.main.nativeScale
|
||||
}
|
||||
|
||||
call.resolve(["isZoomed": isZoomed])
|
||||
}
|
||||
|
||||
@objc func getDocumentRoot(_ call: CAPPluginCall) {
|
||||
let doc = FileManager.default.urls(
|
||||
for: .documentDirectory,
|
||||
in: .userDomainMask).first
|
||||
|
||||
if doc != nil {
|
||||
call.resolve(["documentRoot": doc!.path])
|
||||
} else {
|
||||
call.resolve(["documentRoot": ""])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue