mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
feat: improve file path selection in Setting.vue
This commit is contained in:
@@ -154,15 +154,16 @@ export default defineComponent({
|
||||
|
||||
const onClick = async (e: Event) => {
|
||||
const target = e.target as HTMLInputElement
|
||||
if (target.name && target.name.endsWith('[path]')) {
|
||||
if (target.tagName === 'INPUT' && target.name) {
|
||||
const jsonPath = target.name.replace(/\]/g, '').replace(/\[/g, '.')
|
||||
const field = editor.getEditor(jsonPath)
|
||||
const { canceled, filePaths } = await api.choosePath({
|
||||
properties: ['openDirectory', 'createDirectory'],
|
||||
})
|
||||
|
||||
if (!canceled && filePaths[0]) {
|
||||
field.setValue(filePaths[0])
|
||||
if (field && field.schema.openDialogOptions) {
|
||||
const { canceled, filePaths } = await api.choosePath(field.schema.openDialogOptions)
|
||||
|
||||
if (!canceled && filePaths[0]) {
|
||||
field.setValue(filePaths[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ const schema: SettingSchema = ({
|
||||
path: {
|
||||
type: 'string',
|
||||
title: 'T_setting-panel.schema.repos.path',
|
||||
openDialogOptions: { properties: ['openDirectory', 'createDirectory'] },
|
||||
options: {
|
||||
inputAttributes: { placeholder: 'T_setting-panel.schema.repos.path-placeholder', style: 'cursor: pointer' }
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { VNode } from 'vue'
|
||||
import type { OpenDialogOptions } from 'electron'
|
||||
import type { Language, MsgPath } from '@share/i18n'
|
||||
import type { Doc, FileItem, PathItem, Repo } from '@share/types'
|
||||
import type MarkdownIt from 'markdown-it'
|
||||
@@ -29,6 +30,7 @@ export type SettingSchema = {
|
||||
defaultValue: BuildInSettings[K] extends any ? BuildInSettings[K] : any,
|
||||
enum?: string[] | number [],
|
||||
group: SettingGroup,
|
||||
openDialogOptions?: OpenDialogOptions,
|
||||
needReloadWindowWhenChanged?: boolean,
|
||||
validator?: (schema: SettingSchema['properties'][K], value: BuildInSettings[K], path: string) =>
|
||||
{path: string, property: K, message: string}[]
|
||||
@@ -43,6 +45,7 @@ export type SettingSchema = {
|
||||
options: {
|
||||
inputAttributes: { placeholder: TTitle }
|
||||
}
|
||||
openDialogOptions?: OpenDialogOptions,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user