Skip to content

Commit

Permalink
feat: #319 PicGO图形化配置界面-打开配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Feb 8, 2023
1 parent eb50672 commit 597f42a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions components/picgo/PicgoIndex.vue
Expand Up @@ -275,6 +275,10 @@ const { picgoManageData, picgoManageMethods } = usePicgoManage(props, {
margin: 16px 0 16px;
}
.upload-status {
margin-top: 10px;
}
.upload-btn-list {
}
Expand Down
10 changes: 9 additions & 1 deletion components/picgo/setting/PicgoConfigSetting.vue
Expand Up @@ -27,7 +27,9 @@
<div>
<el-form label-width="125px">
<el-form-item :label="$t('setting.picgo.picgo.open.config.file')">
<el-button>{{ $t("setting.picgo.picgo.click.to.open") }}</el-button>
<el-button @click="handleOpenFile"
>{{ $t("setting.picgo.picgo.click.to.open") }}
</el-button>
</el-form-item>

<el-form-item :label="$t('setting.picgo.picgo.choose.showed.picbed')">
Expand All @@ -50,6 +52,7 @@
import { onBeforeMount, reactive, ref } from "vue"
import picgoUtil from "~/utils/otherlib/picgoUtil"
import { LogFactory } from "~/utils/logUtil"
import siyuanBrowserUtil from "~/utils/otherlib/siyuanBrowserUtil"
const logger = LogFactory.getLogger(
"components/picgo/setting/PicgoConfigSetting.vue"
Expand Down Expand Up @@ -89,6 +92,11 @@ function handleShowPicBedListChange(val: ICheckBoxValueType[]) {
logger.debug("保存启用的图床", list)
}
const handleOpenFile = () => {
const picgoCfgPath = picgoUtil.getPicgoCfgPath()
siyuanBrowserUtil.openPath(picgoCfgPath)
}
onBeforeMount(() => {
// 获取图床列表
getPicBeds()
Expand Down
2 changes: 1 addition & 1 deletion locales/zh_CN.ts
Expand Up @@ -444,5 +444,5 @@ export default {
"setting.picgo.picbed.uploader.config.name": "图床配置名",
"setting.picgo.picbed.uploader.config.name.placeholder": "请输入配置名称",
"setting.picgo.index.tip":
"注意:此处上传的图片不会自动插入文档中,请手动点击复制按钮复制链接,然后Ctrl+V粘贴到文档中。该图片列表仅展示此文档包含的图片。",
"注意:此处上传的图片不会自动插入文档中,请手动点击复制按钮复制链接,然后 Ctrl+V 粘贴到文档中。该图片列表仅展示此文档包含的图片。",
}
10 changes: 10 additions & 0 deletions public/lib/siyuan/publish-helper.js
Expand Up @@ -70,6 +70,16 @@ const initPublishHelper = () => {
window.syp = {
pageId: undefined,
renderPublishHelper: () => {},
openPath: () => {},
}

/**
* 打开文件
* @param absFilePath 文件绝对路径
*/
window.syp.openPath = (absFilePath) => {
const { shell } = window.require("electron")
shell.openPath(absFilePath)
}

/**
Expand Down
18 changes: 18 additions & 0 deletions utils/otherlib/siyuanBrowserUtil.js
Expand Up @@ -117,10 +117,28 @@ const fitTheme = () => {
console.log("适配customstyle完成=>", customstyle)
}

/**
* 打开文件
* @param absFilePath 文件绝对路径
*/
const openPath = (absFilePath) => {
const syWin = getSiyuanWindow()

if (syWin.syp && syWin.syp.openPath) {
// 打开弹窗
syWin.syp.openPath(absFilePath)
} else {
ElMessage.warning(
"openPath失败,未找到hook方法,请在自定义js片段添加 import('/widgets/sy-post-publisher/lib/siyuanhook.js') ,并重启思源笔记"
)
}
}

// 统一访问入口
const siyuanBrowserUtil = {
fitTheme,
getSiyuanWindow,
openPath,
}

export default siyuanBrowserUtil

0 comments on commit 597f42a

Please sign in to comment.