block.vue 1.4 KB
Newer Older
B
baiy 已提交
1 2
<template>
    <div>
B
baiy 已提交
3 4 5 6 7 8 9 10 11 12 13 14
        <CellGroup @on-click="open">
            <Cell title="常用工具设置" name="setting"/>
            <Cell title="快捷键设置" name="shortcuts"/>
        </CellGroup>
        <CellGroup>
            <Cell title="自动复制结果到剪贴板">
                <i-switch v-model="auto_save_copy" slot="extra"/>
            </Cell>
            <Cell title="自动读取剪贴板内容">
                <i-switch v-model="auto_read_copy" slot="extra"/>
            </Cell>
        </CellGroup>
B
baiy 已提交
15 16 17 18
    </div>
</template>

<script>
B
baiy 已提交
19
import { openTab } from '../../helper'
B
baiy 已提交
20 21 22
import setting from '../../tool/setting'

export default {
B
baiy 已提交
23
    data () {
B
baiy 已提交
24 25 26 27 28
        return {
            auto_save_copy: true,
            auto_read_copy: true,
        }
    },
B
baiy 已提交
29
    created () {
B
baiy 已提交
30 31 32
        this.auto_save_copy = setting.autoSaveCopy()
        this.auto_read_copy = setting.autoReadCopy()
    },
B
baiy 已提交
33
    beforeDestroy () {
B
baiy 已提交
34 35 36 37
        setting.autoSaveCopy(this.auto_save_copy)
        setting.autoReadCopy(this.auto_read_copy)
    },
    methods: {
B
baiy 已提交
38 39
        open (name) {
            console.log(name)
B
baiy 已提交
40 41
            switch (name) {
                case 'shortcuts':
B
baiy 已提交
42
                    openTab('chrome://extensions/shortcuts')
B
baiy 已提交
43 44
                    break
                case 'setting':
B
baiy 已提交
45
                    openTab('/setting.html')
B
baiy 已提交
46 47
                    break
            }
B
baiy 已提交
48
        },
B
baiy 已提交
49 50
    },
}
B
baiy 已提交
51
</script>