v2.0.0
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { shell, clipboard } from 'electron'
|
||||
|
||||
|
||||
/**
|
||||
* 在资源管理器中打开目录
|
||||
* @param {string} dir
|
||||
*/
|
||||
export const openDirInExplorer = (dir: string) => {
|
||||
shell.showItemInFolder(dir)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在浏览器打开URL
|
||||
* @param {*} url
|
||||
*/
|
||||
export const openUrl = async(url: string) => {
|
||||
if (!/^https?:\/\//.test(url)) return
|
||||
await shell.openExternal(url)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 复制文本到剪贴板
|
||||
* @param str
|
||||
*/
|
||||
export const clipboardWriteText = (str: string) => {
|
||||
clipboard.writeText(str)
|
||||
}
|
||||
|
||||
/**
|
||||
* 从剪贴板读取文本
|
||||
* @returns
|
||||
*/
|
||||
export const clipboardReadText = (): string => {
|
||||
return clipboard.readText()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user