2018-05-08 02:04:43 -04:00
|
|
|
<template>
|
|
|
|
<div id="rename-page">
|
2018-05-08 11:56:02 -04:00
|
|
|
<el-form
|
|
|
|
@submit.native.prevent
|
|
|
|
>
|
2018-05-08 02:04:43 -04:00
|
|
|
<el-form-item
|
2022-01-18 10:10:49 -05:00
|
|
|
:label="$T('FILE_RENAME')"
|
2018-05-08 02:04:43 -04:00
|
|
|
>
|
2019-12-19 06:17:21 -05:00
|
|
|
<el-input
|
2018-05-08 02:04:43 -04:00
|
|
|
v-model="fileName"
|
|
|
|
size="small"
|
2018-05-08 11:56:02 -04:00
|
|
|
@keyup.enter.native="confirmName"
|
2018-05-08 02:04:43 -04:00
|
|
|
></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<el-row>
|
|
|
|
<div class="pull-right">
|
2022-01-18 10:10:49 -05:00
|
|
|
<el-button @click="cancel" round size="mini">{{ $T('CANCEL') }}</el-button>
|
|
|
|
<el-button type="primary" @click="confirmName" round size="mini">{{ $T('CONFIRM') }}</el-button>
|
2018-05-08 02:04:43 -04:00
|
|
|
</div>
|
|
|
|
</el-row>
|
|
|
|
</div>
|
|
|
|
</template>
|
2019-12-19 06:17:21 -05:00
|
|
|
<script lang="ts">
|
2022-01-08 22:20:56 -05:00
|
|
|
import { RENAME_FILE_NAME } from '#/events/constants'
|
2019-12-19 06:17:21 -05:00
|
|
|
import { Component, Vue } from 'vue-property-decorator'
|
2018-12-10 04:13:48 -05:00
|
|
|
import mixin from '@/utils/mixin'
|
2019-12-19 06:17:21 -05:00
|
|
|
import {
|
|
|
|
ipcRenderer,
|
|
|
|
IpcRendererEvent
|
|
|
|
} from 'electron'
|
|
|
|
@Component({
|
2018-05-08 02:04:43 -04:00
|
|
|
name: 'rename-page',
|
2019-12-19 06:17:21 -05:00
|
|
|
mixins: [mixin]
|
|
|
|
})
|
|
|
|
export default class extends Vue {
|
|
|
|
fileName: string = ''
|
2022-01-08 22:20:56 -05:00
|
|
|
originName: string = ''
|
2019-12-19 06:17:21 -05:00
|
|
|
id: string | null = null
|
2018-05-08 02:04:43 -04:00
|
|
|
created () {
|
2022-01-08 22:20:56 -05:00
|
|
|
ipcRenderer.on(RENAME_FILE_NAME, (event: IpcRendererEvent, newName: string, originName: string, id: string) => {
|
|
|
|
this.fileName = newName
|
|
|
|
this.originName = originName
|
2018-05-08 02:04:43 -04:00
|
|
|
this.id = id
|
|
|
|
})
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
confirmName () {
|
2022-01-08 22:20:56 -05:00
|
|
|
ipcRenderer.send(`${RENAME_FILE_NAME}${this.id}`, this.fileName)
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2019-12-19 06:17:21 -05:00
|
|
|
cancel () {
|
2022-01-08 22:20:56 -05:00
|
|
|
// if cancel, use origin file name
|
|
|
|
ipcRenderer.send(`${RENAME_FILE_NAME}${this.id}`, this.originName)
|
2019-12-19 06:17:21 -05:00
|
|
|
}
|
2022-01-04 10:40:28 -05:00
|
|
|
|
2018-05-08 02:04:43 -04:00
|
|
|
beforeDestroy () {
|
2019-12-19 06:17:21 -05:00
|
|
|
ipcRenderer.removeAllListeners('rename')
|
2018-05-08 02:04:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style lang='stylus'>
|
|
|
|
#rename-page
|
|
|
|
padding 0 20px
|
|
|
|
.pull-right
|
|
|
|
float right
|
|
|
|
.el-form-item__label
|
|
|
|
color #ddd
|
2019-12-19 06:17:21 -05:00
|
|
|
</style>
|