mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 11:26:26 +00:00
improve(plugin): basic impls of file storage api for specific plugin context
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { StyleString, UIOptions } from './LSPlugin'
|
||||
import { PluginLocal } from './LSPlugin.core'
|
||||
import { snakeCase } from 'snake-case'
|
||||
import * as path from 'path'
|
||||
|
||||
interface IObject {
|
||||
[key: string]: any;
|
||||
@@ -13,6 +14,31 @@ declare global {
|
||||
}
|
||||
}
|
||||
|
||||
export const IS_DEV = process.env.NODE_ENV === 'development'
|
||||
|
||||
let _appPathRoot
|
||||
|
||||
export async function getAppPathRoot () {
|
||||
if (_appPathRoot) {
|
||||
return _appPathRoot
|
||||
}
|
||||
|
||||
return (_appPathRoot =
|
||||
await invokeHostExportedApi('_callApplication', 'getAppPath')
|
||||
)
|
||||
}
|
||||
|
||||
export async function getSDKPathRoot () {
|
||||
if (IS_DEV) {
|
||||
// TODO: cache in preference file
|
||||
return localStorage.getItem('LSP_DEV_SDK_ROOT') || 'http://localhost:8080'
|
||||
}
|
||||
|
||||
const appPathRoot = await getAppPathRoot()
|
||||
|
||||
return path.join(appPathRoot, 'js')
|
||||
}
|
||||
|
||||
export function isObject (item: any) {
|
||||
return (item === Object(item) && !Array.isArray(item))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user