block.vue 2.1 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_chromium" title="快捷键设置" name="shortcuts"/>
B
baiy 已提交
7 8 9 10 11 12 13 14
            </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>
15 16 17
                <Cell title="读取剪贴板内容过滤首尾不可见字符">
                    <i-switch v-model="auto_read_copy_filter" slot="extra"/>
                </Cell>
B
baiy 已提交
18 19 20 21 22
            </CellGroup>
        </div>
        <Drawer title="设置" placement="left" v-model="settingShow" :width="90">
            <setting-block v-if="settingShow"></setting-block>
        </Drawer>
B
baiy 已提交
23 24 25 26
    </div>
</template>

<script>
27
import {isChromium, isUtools, openTab} from '../../helper'
B
baiy 已提交
28
import setting from '../../tool/setting'
B
baiy 已提交
29
import settingBlock from './setting'
B
baiy 已提交
30 31

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