🔨 Refactor: change vue-js -> vue-ts && add typos

This commit is contained in:
Molunerfinn
2019-12-21 17:28:29 +08:00
parent 29a55ed855
commit b8ec879e23
21 changed files with 333 additions and 300 deletions

View File

@@ -143,7 +143,7 @@ export default class extends Vue {
UBB: 'UBB',
Custom: 'Custom'
}
picBed: PicBedType[] = []
picBed: IPicBedType[] = []
beforeRouteEnter (to: any, from: any, next: any) {
next((vm: any) => {
vm.getGallery()
@@ -166,7 +166,7 @@ export default class extends Vue {
set filterList (val) {
this.images = val
}
getPicBeds (event: IpcRendererEvent, picBeds: PicBedType[]) {
getPicBeds (event: IpcRendererEvent, picBeds: IPicBedType[]) {
this.picBed = picBeds
}
getGallery () {

View File

@@ -40,7 +40,7 @@ export default class extends Vue {
screenY: number = -1
menu: Electron.Menu | null = null
os = ''
picBed: PicBedType[] = []
picBed: IPicBedType[] = []
created () {
this.os = process.platform
ipcRenderer.on('uploadProgress', (event: IpcRendererEvent, progress: number) => {
@@ -90,7 +90,7 @@ export default class extends Vue {
document.getElementById('file-uploader').value = ''
}
ipcSendFiles (files: FileList) {
let sendFiles: FileWithPath[] = []
let sendFiles: IFileWithPath[] = []
Array.from(files).forEach((item, index) => {
let obj = {
name: item.name,

View File

@@ -283,7 +283,7 @@ export default class extends Vue {
miniWindowOntop: db.get('settings.miniWindowOntop') || false,
logLevel
}
picBed: PicBedType[] = []
picBed: IPicBedType[] = []
logFileVisible = false
keyBindingVisible = false
customLinkVisible = false
@@ -325,7 +325,7 @@ export default class extends Vue {
ipcRenderer.send('getPicBeds')
ipcRenderer.on('getPicBeds', this.getPicBeds)
}
getPicBeds (event: Event, picBeds: PicBedType[]) {
getPicBeds (event: Event, picBeds: IPicBedType[]) {
this.picBed = picBeds
this.form.showPicBedList = this.picBed.map(item => {
if (item.visible) {

View File

@@ -102,13 +102,13 @@ import { ipcRenderer } from 'electron'
name: 'shortcut-page'
})
export default class extends Vue {
list: ShortKeyConfig[] = []
list: IShortKeyConfig[] = []
keyBindingVisible = false
shortKeyName = ''
shortKey = ''
currentIndex = 0
created () {
const shortKeyConfig = this.$db.get('settings.shortKey') as ShortKeyConfigs
const shortKeyConfig = this.$db.get('settings.shortKey') as IShortKeyConfigs
this.list = Object.keys(shortKeyConfig).map(item => shortKeyConfig[item])
}
@Watch('keyBindingVisible')
@@ -119,7 +119,7 @@ export default class extends Vue {
const [origin] = item.split(':')
return origin
}
toggleEnable (item: ShortKeyConfig) {
toggleEnable (item: IShortKeyConfig) {
const status = !item.enable
item.enable = status
this.$db.set(`settings.shortKey.${item.name}.enable`, status)

View File

@@ -72,7 +72,7 @@ export default class extends Vue {
showProgress = false
showError = false
pasteStyle = ''
picBed: PicBedType[] = []
picBed: IPicBedType[] = []
picBedName = ''
menu: Electron.Menu | null= null
mounted () {
@@ -122,7 +122,7 @@ export default class extends Vue {
(document.getElementById('file-uploader') as HTMLInputElement).value = ''
}
ipcSendFiles (files: FileList) {
let sendFiles: FileWithPath[] = []
let sendFiles: IFileWithPath[] = []
Array.from(files).forEach((item, index) => {
let obj = {
name: item.name,
@@ -149,7 +149,7 @@ export default class extends Vue {
}
})
}
getPicBeds (event: Event, picBeds: PicBedType[]) {
getPicBeds (event: Event, picBeds: IPicBedType[]) {
this.picBed = picBeds
this.getDefaultPicBed()
}

View File

@@ -64,47 +64,43 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
mixins: [mixin],
@Component({
name: 'aliyun',
data () {
return {
form: {
accessKeyId: '',
accessKeySecret: '',
bucket: '',
area: '',
path: '',
customUrl: ''
}
}
},
mixins: [mixin]
})
export default class extends Vue {
form: IAliYunConfig = {
accessKeyId: '',
accessKeySecret: '',
bucket: '',
area: '',
path: '',
customUrl: ''
}
created () {
const config = this.$db.get('picBed.aliyun')
const config = this.$db.get('picBed.aliyun') as IAliYunConfig
if (config) {
for (let i in config) {
this.form[i] = config[i]
}
this.form = Object.assign({}, config)
}
},
methods: {
confirm () {
this.$refs.aliyun.validate((valid) => {
if (valid) {
this.$db.set('picBed.aliyun', this.form).write()
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
} else {
return false
}
confirm () {
// @ts-ignore
this.$refs.aliyun.validate((valid) => {
if (valid) {
this.$db.set('picBed.aliyun', this.form)
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
})
}
} else {
return false
}
})
}
}
</script>

View File

@@ -56,46 +56,42 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
@Component({
name: 'github',
mixins: [mixin],
data () {
return {
form: {
repo: '',
token: '',
path: '',
customUrl: '',
branch: ''
}
}
},
mixins: [mixin]
})
export default class extends Vue {
form: IGitHubConfig = {
repo: '',
token: '',
path: '',
customUrl: '',
branch: ''
}
created () {
const config = this.$db.get('picBed.github')
const config = this.$db.get('picBed.github') as IGitHubConfig
if (config) {
for (let i in config) {
this.form[i] = config[i]
}
this.form = Object.assign({}, config)
}
},
methods: {
confirm () {
this.$refs.github.validate((valid) => {
if (valid) {
this.$db.set('picBed.github', this.form).write()
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
} else {
return false
}
confirm () {
// @ts-ignore
this.$refs.github.validate((valid) => {
if (valid) {
this.$db.set('picBed.github', this.form)
const successNotification = new Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
})
}
} else {
return false
}
})
}
}
</script>

View File

@@ -36,43 +36,39 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
@Component({
name: 'imgur',
mixins: [mixin],
data () {
return {
form: {
clientId: '',
proxy: ''
}
}
},
mixins: [mixin]
})
export default class extends Vue {
form: IImgurConfig = {
clientId: '',
proxy: ''
}
created () {
const config = this.$db.get('picBed.imgur')
const config = this.$db.get('picBed.imgur') as IImgurConfig
if (config) {
for (let i in config) {
this.form[i] = config[i]
}
this.form = Object.assign({}, config)
}
},
methods: {
confirm () {
this.$refs.imgur.validate((valid) => {
if (valid) {
this.$db.set('picBed.imgur', this.form).write()
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
} else {
return false
}
confirm () {
// @ts-ignore
this.$refs.imgur.validate((valid) => {
if (valid) {
this.$db.set('picBed.imgur', this.form)
const successNotification = new Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
})
}
} else {
return false
}
})
}
}
</script>

View File

@@ -27,57 +27,61 @@
</el-row>
</div>
</template>
<script>
import ConfigForm from '@/components/ConfigForm'
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import ConfigForm from '@/components/ConfigForm.vue'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
import {
ipcRenderer,
IpcRendererEvent
} from 'electron'
@Component({
name: 'OtherPicBed',
mixins: [mixin],
components: {
ConfigForm
},
data () {
return {
type: '',
config: [],
picBedName: ''
}
},
}
})
export default class extends Vue {
type: string = ''
config: any[] = []
picBedName: string = ''
created () {
this.type = this.$route.params.type
this.$electron.ipcRenderer.send('getPicBedConfig', this.$route.params.type)
this.$electron.ipcRenderer.on('getPicBedConfig', this.getPicBeds)
},
methods: {
async handleConfirm () {
const result = await this.$refs.configForm.validate()
if (result !== false) {
this.$db.set(`picBed.${this.type}`, result)
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
}
},
setDefaultPicBed (type) {
this.$db.set('picBed.current', type)
this.defaultPicBed = type
const successNotification = new window.Notification('设置默认图床', {
ipcRenderer.send('getPicBedConfig', this.$route.params.type)
ipcRenderer.on('getPicBedConfig', this.getPicBeds)
}
async handleConfirm () {
// @ts-ignore
const result = await this.$refs.configForm.validate()
if (result !== false) {
this.$db.set(`picBed.${this.type}`, result)
const successNotification = new Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
},
getPicBeds (event, config, name) {
this.config = config
this.picBedName = name
}
},
}
setDefaultPicBed (type: string) {
this.$db.set('picBed.current', type)
// @ts-ignore 来自mixin的数据
this.defaultPicBed = type
const successNotification = new Notification('设置默认图床', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
}
getPicBeds (event: IpcRendererEvent, config: any[], name: string) {
this.config = config
this.picBedName = name
}
beforeDestroy () {
this.$electron.ipcRenderer.removeListener('getPicBedConfig', this.getPicBeds)
ipcRenderer.removeListener('getPicBedConfig', this.getPicBeds)
}
}
</script>

View File

@@ -71,48 +71,44 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
mixins: [mixin],
@Component({
name: 'qiniu',
data () {
return {
form: {
accessKey: '',
secretKey: '',
bucket: '',
url: '',
area: '',
options: '',
path: ''
}
}
},
mixins: [mixin]
})
export default class extends Vue {
form: IQiniuConfig = {
accessKey: '',
secretKey: '',
bucket: '',
url: '',
area: '',
options: '',
path: ''
}
created () {
const config = this.$db.get('picBed.qiniu')
const config = this.$db.get('picBed.qiniu') as IQiniuConfig
if (config) {
for (let i in config) {
this.form[i] = config[i]
}
this.form = Object.assign({}, config)
}
},
methods: {
confirm () {
this.$refs.qiniu.validate((valid) => {
if (valid) {
this.$db.set('picBed.qiniu', this.form).write()
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
} else {
return false
}
confirm () {
// @ts-ignore
this.$refs.qiniu.validate((valid) => {
if (valid) {
this.$db.set('picBed.qiniu', this.form)
const successNotification = new Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
})
}
} else {
return false
}
})
}
}
</script>

View File

@@ -15,24 +15,23 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
mixins: [mixin],
name: 'upyun',
data () {
return {}
},
methods: {
confirm () {
this.$db.set('picBed.smms', true).write()
this.setDefaultPicBed('smms')
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
@Component({
name: 'smms',
mixins: [mixin]
})
export default class extends Vue {
confirm () {
this.$db.set('picBed.smms', true)
// @ts-ignore 来自mixin
this.setDefaultPicBed('smms')
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
}
}

View File

@@ -85,52 +85,49 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
mixins: [mixin],
import { remote } from 'electron'
@Component({
name: 'tcyun',
data () {
return {
form: {
secretId: '',
secretKey: '',
bucket: '',
appId: '',
area: '',
path: '',
customUrl: '',
version: 'v4'
}
}
},
mixins: [mixin]
})
export default class extends Vue {
form: ITcYunConfig = {
secretId: '',
secretKey: '',
bucket: '',
appId: '',
area: '',
path: '',
customUrl: '',
version: 'v4'
}
created () {
const config = this.$db.get('picBed.tcyun')
const config = this.$db.get('picBed.tcyun') as ITcYunConfig
if (config) {
for (let i in config) {
this.form[i] = config[i]
}
this.form = Object.assign({}, config)
}
},
methods: {
confirm () {
this.$refs.tcyun.validate((valid) => {
if (valid) {
this.$db.set('picBed.tcyun', this.form).write()
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
} else {
return false
}
confirm () {
// @ts-ignore
this.$refs.tcyun.validate((valid) => {
if (valid) {
this.$db.set('picBed.tcyun', this.form)
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
})
},
openWiki () {
this.$electron.remote.shell.openExternal('https://github.com/Molunerfinn/PicGo/wiki/%E8%AF%A6%E7%BB%86%E7%AA%97%E5%8F%A3%E7%9A%84%E4%BD%BF%E7%94%A8#腾讯云cos')
}
} else {
return false
}
})
}
openWiki () {
remote.shell.openExternal('https://github.com/Molunerfinn/PicGo/wiki/%E8%AF%A6%E7%BB%86%E7%AA%97%E5%8F%A3%E7%9A%84%E4%BD%BF%E7%94%A8#腾讯云cos')
}
}
</script>

View File

@@ -64,46 +64,42 @@
</el-row>
</div>
</template>
<script>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import mixin from '@/utils/ConfirmButtonMixin'
export default {
@Component({
name: 'upyun',
mixins: [mixin],
data () {
return {
form: {
bucket: '',
operator: '',
password: '',
options: '',
path: ''
}
}
},
mixins: [mixin]
})
export default class extends Vue {
form: IUpYunConfig = {
bucket: '',
operator: '',
password: '',
options: '',
path: ''
}
created () {
const config = this.$db.get('picBed.upyun')
const config = this.$db.get('picBed.upyun') as IUpYunConfig
if (config) {
for (let i in config) {
this.form[i] = config[i]
}
this.form = Object.assign({}, config)
}
},
methods: {
confirm () {
this.$refs.tcyun.validate((valid) => {
if (valid) {
this.$db.set('picBed.upyun', this.form).write()
const successNotification = new window.Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
} else {
return false
}
confirm () {
// @ts-ignore
this.$refs.tcyun.validate((valid) => {
if (valid) {
this.$db.set('picBed.upyun', this.form)
const successNotification = new Notification('设置结果', {
body: '设置成功'
})
successNotification.onclick = () => {
return true
}
})
}
} else {
return false
}
})
}
}
</script>

View File

@@ -3,7 +3,7 @@
<el-row :gutter="16">
<el-col :span="16" :offset="4">
<div class="view-title">
微博图床设置
微博图床设置[已停止支持]
</div>
<el-form
ref="weiboForm"