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 21, 2023
1 parent 5dcf4e1 commit ff8c1b2
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 20 deletions.
6 changes: 5 additions & 1 deletion components/picgo/setting/PicbedSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@
selected: config._id === profileData.defaultConfigId,
}"
>
{{ $t("setting.picgo.picbed.selected.tip") }}
{{
config._id === profileData.defaultConfigId
? $t("setting.picgo.picbed.selected.tip")
: $t("setting.picgo.picbed.unselected.tip")
}}
</div>
</el-card>
</div>
Expand Down
30 changes: 30 additions & 0 deletions components/picgo/setting/PicgoPluginSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ import { debounce, DebouncedFunc } from "lodash"
import { useI18n } from "vue-i18n"
import { PicgoPageMenuType } from "~/utils/platform/picgo/picgoPlugin"
import ConfigForm from "~/components/picgo/common/ConfigForm.vue"
import { reloadPage } from "~/utils/browserUtil"
const logger = LogFactory.getLogger(
"components/picgo/setting/PicgoPluginSetting.vue"
Expand Down Expand Up @@ -494,6 +495,34 @@ onBeforeMount(() => {
loading.value = false
})
picgoUtil.ipcRegisterEvent("updateSuccess", (evt, data) => {
loading.value = false
logger.info("PicgoPluginSetting接收到updateSuccess事件,data=>", data)
const body = data.rawArgs.body
const success = data.rawArgs.success
const errMsg = data.rawArgs.errMsg
pluginData.pluginList.forEach((item) => {
if (item.fullName === body) {
item.ing = false
item.hasInstall = success
}
})
if (success) {
picgoUtil.ipcHandleEvent("getPicBeds")
ElMessage.success(t("setting.picgo.plugin.update.success"))
} else {
ElMessage.error(errMsg)
}
showPluginConfigForm.value = false
loading.value = false
reloadPage()
})
picgoUtil.ipcRegisterEvent("picgoConfigPlugin", (evt, data) => {
loading.value = false
logger.info("PicgoPluginSetting接收到picgoConfigPlugin事件,data=>", data)
Expand Down Expand Up @@ -524,6 +553,7 @@ onBeforeUnmount(() => {
picgoUtil.ipcRemoveEvent("installPluginFinished")
picgoUtil.ipcRemoveEvent("picgoHandlePluginIng")
picgoUtil.ipcRemoveEvent("uninstallSuccess")
picgoUtil.ipcRemoveEvent("updateSuccess")
picgoUtil.ipcRemoveEvent("picgoConfigPlugin")
})
</script>
Expand Down
2 changes: 2 additions & 0 deletions locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ export default {
"setting.picgo.picgo.click.to.open": "Click open",
"setting.picgo.picgo.choose.showed.picbed": "Please select showed picbed",
"setting.picgo.picbed.selected.tip": "Selected",
"setting.picgo.picbed.unselected.tip": "Unselected",
"setting.picgo.picbed.set.default": "Set as default picbed",
"setting.picgo.picbed.current.selected.tip": "Current selected picbed is:",
"setting.picgo.picbed.current.tip": "Current picbed is:",
Expand Down Expand Up @@ -490,4 +491,5 @@ export default {
"setting.picgo.plugin.work": "Work",
"setting.picgo.plugin.nowork": "Nowork",
"setting.picgo.plugin.nouse": "Nouse",
"setting.picgo.plugin.update.success": "Update success",
}
2 changes: 2 additions & 0 deletions locales/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ export default {
"setting.picgo.picgo.click.to.open": "点击打开",
"setting.picgo.picgo.choose.showed.picbed": "请选择显示的图床",
"setting.picgo.picbed.selected.tip": "已选中",
"setting.picgo.picbed.unselected.tip": "未选中",
"setting.picgo.picbed.set.default": "设为默认图床",
"setting.picgo.picbed.current.selected.tip": "已选中图床:",
"setting.picgo.picbed.current.tip": "当前默认图床是:",
Expand Down Expand Up @@ -488,4 +489,5 @@ export default {
"setting.picgo.plugin.work": "已兼容",
"setting.picgo.plugin.nowork": "不兼容",
"setting.picgo.plugin.nouse": "不可用",
"setting.picgo.plugin.update.success": "更新成功",
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sy-post-publisher",
"private": true,
"version": "0.7.0-beta6",
"version": "0.6.8",
"scripts": {
"serve": "python scripts/serve.py",
"dev": "python scripts/dev.py",
Expand All @@ -11,7 +11,7 @@
"docs": "jsdoc -c jsdoc.json utils/api.ts",
"prettier": "prettier --write .",
"prepare": "husky install",
"new": "python scripts/version.py 0.7.0-beta6",
"new": "python scripts/version.py 0.7.0",
"widget": "python scripts/widget.py",
"ext": "python scripts/ext.py",
"package": "pnpm widget && pnpm ext"
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.dev.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "开发版 - 思源笔记发布辅助工具",
"version": "0.7.0-beta6",
"version": "0.7.0",
"manifest_version": 3,
"author": "terwer",
"description": "思源笔记发布辅助工具,支持博客式只读浏览,多平台文章发布。",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.prod.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "思源笔记发布辅助工具",
"version": "0.7.0-beta6",
"version": "0.7.0",
"manifest_version": 3,
"author": "terwer",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion public/mv2/manifest-v2-for-firefox.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "开发版 - 思源笔记发布辅助工具",
"version": "0.7.0-beta6",
"version": "0.7.0",
"manifest_version": 2,
"author": "terwer",
"icons": {
Expand Down
2 changes: 1 addition & 1 deletion public/widget.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "sy-post-publisher",
"author": "terwer",
"url": "https://github.com/terwer/src-sy-post-publisher",
"version": "0.7.0-beta6"
"version": "0.7.0"
}
26 changes: 26 additions & 0 deletions utils/browserUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ export const reloadPage = (): void => {
}, 200)
}

/**
* 刷新当前tab页面
*
* @param msg 消息提示
* @param type 消息类型
*/
const reloadPageWithMessage = (msg, type = "success"): void => {
if (type == "success") {
ElMessage.success(msg)
} else if (type == "warn") {
ElMessage.warning(msg)
}

setTimeout(function () {
if (isBrowser()) {
window.location.reload()
}
}, 200)
}

export const readJSONFileFormDialog = async (): Promise<FileWithHandle[]> => {
return await fileOpen({
description: "JSON files",
Expand Down Expand Up @@ -186,3 +206,9 @@ export function isInChromeExtension() {
}
return window.location.href.indexOf("chrome-extension://") > -1
}

const browserUtil = {
reloadPageWithMessage,
}

export default browserUtil
23 changes: 10 additions & 13 deletions utils/otherlib/picgoUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import idUtil from "~/utils/idUtil"
import strUtil from "~/utils/strUtil"
import siyuanBrowserUtil from "~/utils/otherlib/siyuanBrowserUtil"
import { PicgoPageMenuType } from "~/utils/platform/picgo/picgoPlugin"
import browserUtil, { reloadPage } from "~/utils/browserUtil"

// Pico上传Api封装
const picGoUploadApi = new PicGoUploadApi()
Expand Down Expand Up @@ -520,10 +521,8 @@ const buildPluginMenu = (plugin, i18nFunc) => {
savePicgoConfig({
[`picgoPlugins.${plugin.fullName}`]: true,
})
// ipcHandleEvent("picgoTogglePlugin", {
// fullName:plugin.fullName,
// status:true
// })

browserUtil.reloadPageWithMessage("插件已启用,即将刷新页面...")
},
}

Expand All @@ -536,22 +535,15 @@ const buildPluginMenu = (plugin, i18nFunc) => {
savePicgoConfig({
[`picgoPlugins.${plugin.fullName}`]: false,
})
// const window = windowManager.get(IWindowList.SETTING_WINDOW)!
// window.webContents.send(PICGO_HANDLE_PLUGIN_ING, plugin.fullName)
// window.webContents.send(PICGO_TOGGLE_PLUGIN, plugin.fullName, false)
// window.webContents.send(PICGO_HANDLE_PLUGIN_DONE, plugin.fullName)

// ipcHandleEvent("picgoTogglePlugin", {
// fullName:plugin.fullName,
// status:false
// })

if (plugin.config.transformer.name) {
handleRestoreState("transformer", plugin.config.transformer.name)
}
if (plugin.config.uploader.name) {
handleRestoreState("uploader", plugin.config.uploader.name)
}

browserUtil.reloadPageWithMessage("插件已禁用,即将刷新页面...")
},
}

Expand Down Expand Up @@ -583,6 +575,11 @@ const buildPluginMenu = (plugin, i18nFunc) => {
template.push(uninstallItem)
template.push(updateItem)

template.push({
label: " -------- ",
click() {},
})

// 插件自定义菜单配置
const pluginI18n = i18nFunc(PicgoPageMenuType.PicgoPageMenuType_Plugin)
for (const i in plugin.config) {
Expand Down

0 comments on commit ff8c1b2

Please sign in to comment.