Skip to content

Commit

Permalink
feat: #319 PicGO图形化配置界面-0.7.0-beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Feb 8, 2023
1 parent 58093a2 commit 8a11a68
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
16 changes: 5 additions & 11 deletions components/picgo/setting/PicbedSetting.vue
Expand Up @@ -122,7 +122,7 @@
config-type="uploader"
:id="type"
:config="profileData.curConfig"
:config-id="profileData.defaultConfigId"
:config-id="profileData.curConfigId"
:is-new-form="isNewForm"
@on-change="emitBackFn"
/>
Expand Down Expand Up @@ -230,16 +230,13 @@ function selectItem(id: string) {
function addNewConfig() {
const configObj = picgoUtil.getPicBedConfig(type.value)
profileData.curConfig = configObj.config
profileData.curConfigId = undefined
isNewForm.value = true
showConfigForm.value = true
logger.debug(
"editConfig profileData.defaultConfigId=>",
profileData.defaultConfigId
)
logger.debug("addNewConfig id=>", undefined)
logger.debug("addNewConfig type=>", type.value)
logger.debug("addNewConfig id=>", profileData.curConfigId)
logger.debug("addNewConfig config=>", toRaw(profileData.curConfig))
}
Expand All @@ -250,16 +247,13 @@ function addNewConfig() {
function editConfig(id: string) {
const configObj = picgoUtil.getPicBedConfig(type.value)
profileData.curConfig = configObj.config
profileData.curConfigId = id
isNewForm.value = false
showConfigForm.value = true
logger.info(
"editConfig profileData.defaultConfigId=>",
profileData.defaultConfigId
)
logger.debug("editConfig id=>", id)
logger.debug("editConfig type=>", type.value)
logger.debug("editConfig id=>", profileData.curConfigId)
logger.debug("editConfig config=>", toRaw(profileData.curConfig))
}
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "sy-post-publisher",
"private": true,
"version": "0.6.8",
"version": "0.7.0-beta1",
"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",
"new": "python scripts/version.py 0.7.0-beta1",
"widget": "python scripts/widget.py",
"ext": "python scripts/ext.py",
"package": "pnpm widget && pnpm ext"
Expand Down
2 changes: 1 addition & 1 deletion public/lib/siyuan/publish-helper.js
Expand Up @@ -233,7 +233,7 @@ const initPublishHelper = () => {
{ content: html },
(response) => {
window.siyuan.printWin.loadURL(response.data.url)
window.siyuan.printWin.webContents.openDevTools()
// window.siyuan.printWin.webContents.openDevTools()
}
)
})
Expand Down
17 changes: 12 additions & 5 deletions public/lib/siyuanhook.js
Expand Up @@ -210,8 +210,8 @@ const initMethods = {
const dataDir = getSiyuanDataDir()

// 防止重复挂载
if (syWin.terwer) {
console.warn("terwer已挂载,忽略", entryName)
if (syWin.syp) {
console.warn("syp已挂载,忽略", entryName)
return
}

Expand Down Expand Up @@ -243,20 +243,27 @@ const initMethods = {
entryName,
`${dataDir}/widgets/sy-post-publisher/lib/picgo/picgo.js`,
"sy-picgo"
)
).default

// PicGO存储到配置目录,便于后面插件
const path = syWin.require("path")
const fs = syWin.require("fs")

// 配置文件初始化与数据迁移
const appDataFolder = getCrossPlatformAppDataFolder()
const picgo_cfg_067 = `${dataDir}/widgets/sy-post-publisher/lib/picgo/picgo.cfg.json`
const picgo_cfg_070 = path.join(appDataFolder, "sy-picgo", "picgo.cfg.json")
const picgo_cfg_folder_070 = path.join(appDataFolder, "sy-picgo")
if (!fs.existsSync(picgo_cfg_folder_070)) {
fs.mkdirSync(picgo_cfg_folder_070)
}
const picgo_cfg_070 = path.join(picgo_cfg_folder_070, "picgo.cfg.json")
if (fs.existsSync(picgo_cfg_067) && !fs.existsSync(picgo_cfg_070)) {
console.warn("检测到旧的PicGO配置文件,启动迁移")
fs.copySync(picgo_cfg_067, picgo_cfg_070)
fs.copyFileSync(picgo_cfg_067, picgo_cfg_070)
}
console.warn("PicGO配置文件初始化为=>", picgo_cfg_070)

// 初始化
picgoExtension.initPicgo(picgo_cfg_070)
},
}
Expand Down
4 changes: 2 additions & 2 deletions utils/otherlib/picgoUtil.js
Expand Up @@ -329,7 +329,7 @@ export const updateUploaderConfig = (type, id, config) => {
let updatedConfig
let updatedDefaultId = defaultId
if (existConfig) {
updatedConfig = Object.assign(existConfig, trimValues(config), {
updatedConfig = Object.assign(existConfig, strUtil.trimValues(config), {
_updatedAt: Date.now(),
})
} else {
Expand Down Expand Up @@ -377,7 +377,7 @@ const getPicgoCfgPath = () => {
const syWin = siyuanBrowserUtil.getSiyuanWindow()
const picgo = syWin.SyPicgo.getPicgoObj()

const picgo_cfg_070 = "test"
const picgo_cfg_070 = picgo.configPath
return picgo_cfg_070
}

Expand Down

0 comments on commit 8a11a68

Please sign in to comment.