Skip to content

Commit

Permalink
添加 gb2312 编码支持
Browse files Browse the repository at this point in the history
  • Loading branch information
F-loat committed May 12, 2018
1 parent d3625f3 commit fb25210
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
<v-toolbar dark color="primary">
<v-toolbar-title class="white--text">字幕转文本工具</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon dark disabled>{{format}}</v-btn>
<v-btn icon dark @click="switchFormat">
<v-icon>swap_horiz</v-icon>
</v-btn>
<v-btn flat dark @click="switchEncoding">{{encoding}}</v-btn>
<v-btn icon dark @click="switchFormat">{{format}}</v-btn>
<a href="https://github.com/F-loat/caption2text" target="_blank">
<v-btn icon dark @click="switchFormat">
<v-btn icon dark>
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 16 16" version="1.1" width="24" aria-hidden="true">
<path fill-rule="evenodd" fill="#fff" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
Expand Down Expand Up @@ -49,7 +47,7 @@
<script>
import MaterialImage from 'material-image'
let scrollTimer
let file, scrollTimer
export default {
name: 'Index',
Expand All @@ -59,6 +57,7 @@ export default {
x: window.innerWidth,
y: window.innerHeight
},
encoding: 'utf-8',
format: 'ass',
source: '',
filename: '',
Expand Down Expand Up @@ -94,7 +93,6 @@ export default {
mounted () {
this.$nextTick(() => {
new MaterialImage()
console.log(this.$parent)
this.$refs.source.addEventListener('scroll', this.scrollSync)
this.$refs.result.addEventListener('scroll', this.scrollSync)
})
Expand All @@ -103,14 +101,18 @@ export default {
resizeHandler () {
this.windowSize = { x: window.innerWidth, y: window.innerHeight }
},
switchEncoding () {
this.encoding = this.encoding === 'utf-8' ? 'gb2312' : 'utf-8'
this.dropFile(null, file)
},
switchFormat () {
this.format = this.format === 'ass' ? 'srt' : 'ass'
},
dropFile (e) {
const file = e.dataTransfer.files[0]
dropFile (e, f) {
file = f || e.dataTransfer.files[0]
const reader = new FileReader()
reader.onload = this.getSourceFromFile
reader.readAsText(file)
reader.readAsText(file, this.encoding)
this.format = file.name.replace(/.*\./, '')
this.filename = file.name.replace(`.${this.format}`, '.txt')
this.snackbar = {
Expand Down

0 comments on commit fb25210

Please sign in to comment.