<template>
|
<page>
|
<div class="setting">
|
<el-divider content-position="left">设置下载目录</el-divider>
|
<div class="setDownloadPathBox">
|
<el-input style="width: 300px; margin-right: 10px" v-model="downloadPath" disabled />
|
<el-button type="primary" @click="setPath">设置目录</el-button>
|
<el-button type="primary" @click="openPath">打开目录</el-button>
|
</div>
|
</div>
|
</page>
|
</template>
|
|
<script setup lang="ts">
|
import { ref, reactive, inject, onMounted } from 'vue'
|
import { ElMessage } from 'element-plus'
|
const downloadPath = ref('')
|
onMounted(() => {
|
const path = window.electronAPI.getDownloadPath()
|
downloadPath.value = path
|
})
|
const setPath = () => {
|
const path = window.electronAPI.openSelectFileOrFolderDialog({
|
title: '选择下载目录',
|
properties: ['openDirectory']
|
})
|
downloadPath.value = path[0]
|
const data = window.electronAPI.setDownloadPath(path[0])
|
if (data.state) {
|
ElMessage({
|
message: '设置成功!',
|
type: 'success'
|
})
|
} else {
|
ElMessage({
|
message: data.msg,
|
type: 'error'
|
})
|
}
|
}
|
const openPath = () => {
|
const data = window.electronAPI.openPath(downloadPath.value)
|
if (!data.state) {
|
ElMessage({
|
message: data.msg,
|
type: 'error'
|
})
|
}
|
}
|
</script>
|
|
<style lang="less">
|
.setting {
|
width: 100%;
|
height: 100%;
|
box-sizing: border-box;
|
padding: 10px 50px;
|
.setDownloadPathBox {
|
display: flex;
|
}
|
}
|
</style>
|