mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-09 22:43:09 +08:00
✨ Feature(custom): add new config field temp dir path
ISSUES CLOSED: #112
This commit is contained in:
@@ -296,6 +296,7 @@ SETTINGS_TAB_SYNC_CONFIG: Sync and Configuration
|
|||||||
SETTINGS_TAB_UPLOAD: Upload
|
SETTINGS_TAB_UPLOAD: Upload
|
||||||
SETTINGS_TAB_ADVANCED: Advanced
|
SETTINGS_TAB_ADVANCED: Advanced
|
||||||
SETTINGS_TAB_UPDATE: Update
|
SETTINGS_TAB_UPDATE: Update
|
||||||
|
SETTINGS_GENERAL_TEMP_DIR_PATH: Temporary directory path
|
||||||
# shortcut-page
|
# shortcut-page
|
||||||
|
|
||||||
BUILTIN_CLIPBOARD_TIPS: Use builtin clipboard function to upload instead of using scripts
|
BUILTIN_CLIPBOARD_TIPS: Use builtin clipboard function to upload instead of using scripts
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ SETTINGS_TAB_SYNC_CONFIG: 同步与配置
|
|||||||
SETTINGS_TAB_UPLOAD: 上传设置
|
SETTINGS_TAB_UPLOAD: 上传设置
|
||||||
SETTINGS_TAB_ADVANCED: 高级设置
|
SETTINGS_TAB_ADVANCED: 高级设置
|
||||||
SETTINGS_TAB_UPDATE: 更新
|
SETTINGS_TAB_UPDATE: 更新
|
||||||
|
SETTINGS_GENERAL_TEMP_DIR_PATH: 临时文件夹路径
|
||||||
# shortcut-page
|
# shortcut-page
|
||||||
|
|
||||||
SHORTCUT_NAME: 快捷键名称
|
SHORTCUT_NAME: 快捷键名称
|
||||||
|
|||||||
@@ -297,6 +297,7 @@ SETTINGS_TAB_SYNC_CONFIG: 同步與配置
|
|||||||
SETTINGS_TAB_UPLOAD: 上傳設置
|
SETTINGS_TAB_UPLOAD: 上傳設置
|
||||||
SETTINGS_TAB_ADVANCED: 高級設置
|
SETTINGS_TAB_ADVANCED: 高級設置
|
||||||
SETTINGS_TAB_UPDATE: 更新
|
SETTINGS_TAB_UPDATE: 更新
|
||||||
|
SETTINGS_GENERAL_TEMP_DIR_PATH: 本地暫存路徑
|
||||||
# shortcut-page
|
# shortcut-page
|
||||||
|
|
||||||
SHORTCUT_NAME: 快捷鍵名稱
|
SHORTCUT_NAME: 快捷鍵名稱
|
||||||
|
|||||||
@@ -67,6 +67,13 @@ export const manageIpcList = {
|
|||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('openDirectorySelectDialog', async () => {
|
||||||
|
const res = await dialog.showOpenDialog({
|
||||||
|
properties: ['openDirectory']
|
||||||
|
})
|
||||||
|
return res.filePaths[0]
|
||||||
|
})
|
||||||
|
|
||||||
ipcMain.handle('openFileSelectDialog', async () => {
|
ipcMain.handle('openFileSelectDialog', async () => {
|
||||||
const res = await dialog.showOpenDialog({
|
const res = await dialog.showOpenDialog({
|
||||||
properties: ['openFile', 'multiSelections']
|
properties: ['openFile', 'multiSelections']
|
||||||
|
|||||||
@@ -48,8 +48,18 @@ export function isInputConfigValid (config: any): boolean {
|
|||||||
|
|
||||||
export const getFileMimeType = (filePath: string): string => mime.lookup(filePath) || 'application/octet-stream'
|
export const getFileMimeType = (filePath: string): string => mime.lookup(filePath) || 'application/octet-stream'
|
||||||
|
|
||||||
const checkTempFolderExist = async () => {
|
const getTempDirPath = () => {
|
||||||
const tempPath = path.join(app.getPath('downloads'), 'piclistTemp')
|
const defaultPath = path.join(app.getPath('downloads'), 'piclistTemp')
|
||||||
|
try {
|
||||||
|
const configFilePath = path.join(app.getPath('userData'), 'data.json')
|
||||||
|
const { settings: { tempDirPath = '' } = {} } = fs.readJSONSync(configFilePath) || {}
|
||||||
|
return tempDirPath ? path.join(tempDirPath, 'piclistTemp') : defaultPath
|
||||||
|
} catch (e) {
|
||||||
|
return defaultPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkTempFolderExist = async (tempPath: string) => {
|
||||||
try {
|
try {
|
||||||
await fs.access(tempPath)
|
await fs.access(tempPath)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -58,8 +68,8 @@ const checkTempFolderExist = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const downloadFileFromUrl = async (urls: string[]) => {
|
export const downloadFileFromUrl = async (urls: string[]) => {
|
||||||
const tempPath = path.join(app.getPath('downloads'), 'piclistTemp')
|
const tempPath = getTempDirPath()
|
||||||
await checkTempFolderExist()
|
await checkTempFolderExist(tempPath)
|
||||||
const result = [] as string[]
|
const result = [] as string[]
|
||||||
for (let i = 0; i < urls.length; i++) {
|
for (let i = 0; i < urls.length; i++) {
|
||||||
const finishDownload = promisify(Stream.finished)
|
const finishDownload = promisify(Stream.finished)
|
||||||
@@ -78,7 +88,7 @@ export const downloadFileFromUrl = async (urls: string[]) => {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export const clearTempFolder = () => fs.emptyDirSync(path.join(app.getPath('downloads'), 'piclistTemp'))
|
export const clearTempFolder = () => fs.emptyDirSync(getTempDirPath())
|
||||||
|
|
||||||
export const md5 = (str: string, code: 'hex' | 'base64'): string => crypto.createHash('md5').update(str).digest(code)
|
export const md5 = (str: string, code: 'hex' | 'base64'): string => crypto.createHash('md5').update(str).digest(code)
|
||||||
|
|
||||||
|
|||||||
@@ -194,6 +194,18 @@
|
|||||||
{{ $T('SETTINGS_CLICK_TO_SET') }}
|
{{ $T('SETTINGS_CLICK_TO_SET') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item
|
||||||
|
:label="$T('SETTINGS_GENERAL_TEMP_DIR_PATH')"
|
||||||
|
>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
round
|
||||||
|
size="small"
|
||||||
|
@click="handleTempDirPath"
|
||||||
|
>
|
||||||
|
{{ $T('SETTINGS_CLICK_TO_SET') }}
|
||||||
|
</el-button>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -1725,7 +1737,8 @@ const form = reactive<ISettingForm>({
|
|||||||
yourlsSignature: '',
|
yourlsSignature: '',
|
||||||
deleteLocalFile: false,
|
deleteLocalFile: false,
|
||||||
serverKey: '',
|
serverKey: '',
|
||||||
aesPassword: ''
|
aesPassword: '',
|
||||||
|
tempDirPath: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const languageList = i18nManager.languageList.map(item => ({
|
const languageList = i18nManager.languageList.map(item => ({
|
||||||
@@ -1890,6 +1903,7 @@ async function initData () {
|
|||||||
form.deleteLocalFile = settings.deleteLocalFile || false
|
form.deleteLocalFile = settings.deleteLocalFile || false
|
||||||
form.serverKey = settings.serverKey || ''
|
form.serverKey = settings.serverKey || ''
|
||||||
form.aesPassword = settings.aesPassword || 'PicList-aesPassword'
|
form.aesPassword = settings.aesPassword || 'PicList-aesPassword'
|
||||||
|
form.tempDirPath = settings.tempDirPath || ''
|
||||||
currentLanguage.value = settings.language ?? 'zh-CN'
|
currentLanguage.value = settings.language ?? 'zh-CN'
|
||||||
currentStartMode.value = settings.startMode || 'quiet'
|
currentStartMode.value = settings.startMode || 'quiet'
|
||||||
customLink.value = settings.customLink || ''
|
customLink.value = settings.customLink || ''
|
||||||
@@ -2195,6 +2209,15 @@ function handleMiniWindowOntop (val: ICheckBoxValueType) {
|
|||||||
$message.info($T('TIPS_NEED_RELOAD'))
|
$message.info($T('TIPS_NEED_RELOAD'))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleTempDirPath (evt: Event) {
|
||||||
|
const result = await invokeToMain('openDirectorySelectDialog')
|
||||||
|
if (result) {
|
||||||
|
form.tempDirPath = result
|
||||||
|
saveConfig('settings.tempDirPath', form.tempDirPath)
|
||||||
|
$message.info($T('TIPS_NEED_RELOAD'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleMiniIconPath (evt: Event) {
|
async function handleMiniIconPath (evt: Event) {
|
||||||
const result = await invokeToMain('openFileSelectDialog')
|
const result = await invokeToMain('openFileSelectDialog')
|
||||||
if (result && result[0]) {
|
if (result && result[0]) {
|
||||||
|
|||||||
1
src/universal/types/i18n.d.ts
vendored
1
src/universal/types/i18n.d.ts
vendored
@@ -292,6 +292,7 @@ interface ILocales {
|
|||||||
SETTINGS_TAB_UPLOAD: string
|
SETTINGS_TAB_UPLOAD: string
|
||||||
SETTINGS_TAB_ADVANCED: string
|
SETTINGS_TAB_ADVANCED: string
|
||||||
SETTINGS_TAB_UPDATE: string
|
SETTINGS_TAB_UPDATE: string
|
||||||
|
SETTINGS_GENERAL_TEMP_DIR_PATH: string
|
||||||
SHORTCUT_NAME: string
|
SHORTCUT_NAME: string
|
||||||
SHORTCUT_BIND: string
|
SHORTCUT_BIND: string
|
||||||
SHORTCUT_STATUS: string
|
SHORTCUT_STATUS: string
|
||||||
|
|||||||
3
src/universal/types/view.d.ts
vendored
3
src/universal/types/view.d.ts
vendored
@@ -29,7 +29,8 @@ interface ISettingForm {
|
|||||||
yourlsSignature: string,
|
yourlsSignature: string,
|
||||||
deleteLocalFile: boolean,
|
deleteLocalFile: boolean,
|
||||||
serverKey: string,
|
serverKey: string,
|
||||||
aesPassword: string
|
aesPassword: string,
|
||||||
|
tempDirPath: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IShortKeyMap {
|
interface IShortKeyMap {
|
||||||
|
|||||||
Reference in New Issue
Block a user