block.vue 1.8 KB
Newer Older
B
baiy 已提交
1 2
<template>
    <div>
B
baiy 已提交
3 4 5
        <div>
            <CellGroup @on-click="open">
                <Cell title="常用工具设置" name="setting"/>
6
                <Cell v-if="is_chrome" title="快捷键设置" name="shortcuts"/>
B
baiy 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19
            </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>
        </div>
        <Drawer title="设置" placement="left" v-model="settingShow" :width="90">
            <setting-block v-if="settingShow"></setting-block>
        </Drawer>
B
baiy 已提交
20 21 22 23
    </div>
</template>

<script>
24
import {isChrome, isUtools, openTab} from '../../helper'
B
baiy 已提交
25
import setting from '../../tool/setting'
B
baiy 已提交
26
import settingBlock from './setting'
B
baiy 已提交
27 28

export default {
B
baiy 已提交
29 30 31
    components: {
        "setting-block": settingBlock
    },
32
    data() {
B
baiy 已提交
33
        return {
34
            settingShow: false,
B
baiy 已提交
35 36
            auto_save_copy: true,
            auto_read_copy: true,
37 38
            is_chrome: isChrome,
            is_utools: isUtools,
B
baiy 已提交
39 40
        }
    },
41
    created() {
B
baiy 已提交
42 43 44
        this.auto_save_copy = setting.autoSaveCopy()
        this.auto_read_copy = setting.autoReadCopy()
    },
45
    beforeDestroy() {
B
baiy 已提交
46 47 48 49
        setting.autoSaveCopy(this.auto_save_copy)
        setting.autoReadCopy(this.auto_read_copy)
    },
    methods: {
50
        open(name) {
B
baiy 已提交
51 52
            switch (name) {
                case 'shortcuts':
B
baiy 已提交
53
                    openTab('chrome://extensions/shortcuts')
B
baiy 已提交
54 55
                    break
                case 'setting':
B
baiy 已提交
56
                    this.settingShow = true
B
baiy 已提交
57 58
                    break
            }
59
        }
B
baiy 已提交
60 61
    },
}
B
baiy 已提交
62
</script>