Feature(custom): add new set item to open config file path

This commit is contained in:
Kuingsmile
2024-02-21 23:13:47 -08:00
parent 97d083df5a
commit 4be82e0afc
7 changed files with 52 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ import {
PICGO_GET_BY_ID_DB,
PICGO_REMOVE_BY_ID_DB,
PICGO_OPEN_FILE,
PICGO_OPEN_DIRECTORY,
PASTE_TEXT,
OPEN_WINDOW,
GET_LANGUAGE_LIST,
@@ -379,6 +380,18 @@ const handleOpenFile = () => {
})
}
const handleOpenDirectory = () => {
ipcMain.on(PICGO_OPEN_DIRECTORY, (event: IpcMainEvent, dirPath?: string, inStorePath: boolean = true) => {
if (inStorePath) {
dirPath = path.join(STORE_PATH, dirPath || '')
}
if (!dirPath || !fs.existsSync(dirPath)) {
return
}
shell.openPath(dirPath)
})
}
const handleOpenWindow = () => {
ipcMain.on(OPEN_WINDOW, (event: IpcMainEvent, windowName: IWindowList) => {
const window = windowManager.get(windowName)
@@ -431,6 +444,7 @@ export default {
handleImportLocalPlugin()
handleUpdateAllPlugin()
handleOpenFile()
handleOpenDirectory()
handleOpenWindow()
handleI18n()
handleRPCActions()

View File

@@ -283,6 +283,18 @@
{{ $T('SETTINGS_CLICK_TO_OPEN') }}
</el-button>
</el-form-item>
<el-form-item
:label="$T('SETTINGS_CONFIG_FILE_PATH')"
>
<el-button
type="primary"
round
size="small"
@click="openDirectory()"
>
{{ $T('SETTINGS_CLICK_TO_OPEN') }}
</el-button>
</el-form-item>
</el-form>
</el-row>
</el-col>
@@ -582,6 +594,18 @@
label-width="50%"
size="small"
>
<el-form-item
:label="$T('SETTINGS_LOG_FILE_PATH')"
>
<el-button
type="primary"
round
size="small"
@click="openDirectory()"
>
{{ $T('SETTINGS_CLICK_TO_OPEN') }}
</el-button>
</el-form-item>
<el-form-item
:label="$T('SETTINGS_SET_LOG_FILE')"
>
@@ -1603,7 +1627,7 @@ import { Reading, Close, Edit, InfoFilled } from '@element-plus/icons-vue'
import pkg from 'root/package.json'
// 事件常量
import { PICGO_OPEN_FILE, OPEN_URL, GET_PICBEDS, HIDE_DOCK } from '#/events/constants'
import { PICGO_OPEN_FILE, PICGO_OPEN_DIRECTORY, OPEN_URL, GET_PICBEDS, HIDE_DOCK } from '#/events/constants'
import { IRPCActionType } from '~/universal/types/enum'
// Electron 相关
@@ -2046,6 +2070,10 @@ function openFile (file: string) {
sendToMain(PICGO_OPEN_FILE, file)
}
function openDirectory (directory?: string, inStorePath = true) {
sendToMain(PICGO_OPEN_DIRECTORY, directory, inStorePath)
}
function openLogSetting () {
logFileVisible.value = true
}

View File

@@ -13,6 +13,7 @@ export const PICGO_UPDATE_BY_ID_DB = 'PICGO_UPDATE_BY_ID_DB'
export const PICGO_GET_BY_ID_DB = 'PICGO_GET_BY_ID_DB'
export const PICGO_REMOVE_BY_ID_DB = 'PICGO_REMOVE_BY_ID_DB'
export const PICGO_OPEN_FILE = 'PICGO_OPEN_FILE'
export const PICGO_OPEN_DIRECTORY = 'PICGO_OPEN_DIRECTORY'
export const OPEN_DEVTOOLS = 'OPEN_DEVTOOLS'
export const SHOW_MINI_PAGE_MENU = 'SHOW_MINI_PAGE_MENU'
export const SHOW_MAIN_PAGE_MENU = 'SHOW_MAIN_PAGE_MENU'

View File

@@ -190,6 +190,8 @@ interface ILocales {
SETTINGS_NEWEST_VERSION: string
SETTINGS_GETING: string
SETTINGS_TIPS_HAS_NEW_VERSION: string
SETTINGS_LOG_FILE_PATH: string
SETTINGS_CONFIG_FILE_PATH: string
SETTINGS_LOG_FILE: string
SETTINGS_GUI_LOG_FILE: string
SETTINGS_MANAGE_LOG_FILE: string