-
Notifications
You must be signed in to change notification settings - Fork 834
Expand file tree
/
Copy pathOutputFolderSetting.vue
More file actions
73 lines (64 loc) · 1.87 KB
/
OutputFolderSetting.vue
File metadata and controls
73 lines (64 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<template>
<div class="mb-4 py-4 border-b border-gray-200">
<div class="text-base font-medium mb-4">{{ $t('outputFolder') }}</div>
<a-form>
<a-form-item :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-input v-model="currentFolderPath" read-only>
<i slot="addonAfter" class="zwicon-folder-open px-2" @click="handleFolderSelect"></i>
</a-input>
</a-form-item>
<a-form-item :labelCol="formLayout.label" :wrapperCol="formLayout.wrapper" :colon="false">
<a-button type="primary" @click="save">{{ $t('save') }}</a-button>
</a-form-item>
</a-form>
</div>
</template>
<script lang="ts">
import {
app,
ipcRenderer, IpcRendererEvent, remote,
} from 'electron'
import { Vue, Component } from 'vue-property-decorator'
import { State } from 'vuex-class'
@Component
export default class System extends Vue {
@State('site') site!: any
formLayout = {
label: { span: 5 },
wrapper: { span: 12 },
}
currentFolderPath = '-'
mounted() {
this.currentFolderPath = this.site.buildDir
}
save() {
ipcRenderer.send('app-output-folder-setting', this.currentFolderPath)
ipcRenderer.once('app-output-folder-set', (event: IpcRendererEvent, data: any) => {
if (data) {
this.$message.success(this.$t('saved'))
this.$bus.$emit('site-reload')
remote.app.relaunch()
remote.app.quit()
} else {
this.$message.error(this.$t('saveError'))
}
})
}
async handleFolderSelect() {
const res = await remote.dialog.showOpenDialog({
properties: ['openDirectory', 'createDirectory'],
})
if (res.filePaths.length > 0) {
this.currentFolderPath = res.filePaths[0].replace(/\\/g, '/')
}
}
}
</script>
<style lang="less" scoped>
/deep/ .ant-input-group-addon {
padding: 0;
}
.folder-btn {
padding: 0 8px;
}
</style>