mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat(plugin): add ctx.base.openExternal ctx.base.openPath methods
This commit is contained in:
@@ -3,7 +3,7 @@ import type { Doc } from '@fe/types'
|
||||
import * as api from '@fe/support/api'
|
||||
import { getSettings } from './setting'
|
||||
import { FLAG_DEMO } from '@fe/support/args'
|
||||
import { binMd5, fileToBase64URL, getLogger } from '@fe/utils'
|
||||
import { binMd5, quote, fileToBase64URL, getLogger } from '@fe/utils'
|
||||
import { basename, resolve, extname, dirname, relative } from '@fe/utils/path'
|
||||
import { dayjs } from '@fe/context/lib'
|
||||
import { useModal } from '@fe/support/ui/modal'
|
||||
@@ -66,3 +66,19 @@ export async function inputPassword (title: string, hint: string, throwError = f
|
||||
|
||||
return password
|
||||
}
|
||||
|
||||
/**
|
||||
* open an external uri
|
||||
* @param uri
|
||||
*/
|
||||
export async function openExternal (uri: string) {
|
||||
api.rpc(`require('electron').shell.openExternal(${quote(uri)})`)
|
||||
}
|
||||
|
||||
/**
|
||||
* open a path
|
||||
* @param uri
|
||||
*/
|
||||
export async function openPath (path: string) {
|
||||
api.rpc(`require('electron').shell.openPath(${quote(path)})`)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,15 @@ export * as path from './path'
|
||||
export * as storage from './storage'
|
||||
export * as crypto from './crypto'
|
||||
|
||||
/**
|
||||
* quote string
|
||||
* @param str
|
||||
* @param quote
|
||||
*/
|
||||
export function quote (str: string, quote = '`') {
|
||||
return quote + str.replaceAll(quote, '\\' + quote) + quote
|
||||
}
|
||||
|
||||
export const encodeMarkdownLink = (path: string) => {
|
||||
return path
|
||||
.replace(/\(/g, '%28')
|
||||
|
||||
Reference in New Issue
Block a user