feat: support developer mode.

pull/59/head
ruibaby 2019-11-23 22:54:45 +08:00
parent 7ecdd1d074
commit 39afb3d127
5 changed files with 106 additions and 14 deletions

View File

@ -1,20 +1,54 @@
<template>
<div class="logo">
<router-link :to="{ name:'Dashboard' }">
<a
href="javascript:void(0);"
@click="onLogoClick()"
>
<h1 class="logo-title">Halo</h1>
<h1 class="logo-sub-title">Dashboard</h1>
</router-link>
<h1
class="logo-sub-title"
style="padding-left: 10px;"
>Dashboard</h1>
</a>
</div>
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
import optionApi from '@/api/option'
export default {
name: 'Logo'
name: 'Logo',
data() {
return {
clickCount: 0,
optionsToCreate: {
developer_mode: true
}
}
},
computed: {
...mapGetters(['options'])
},
methods: {
...mapActions(['loadOptions']),
onLogoClick() {
this.clickCount++
if (this.clickCount === 10) {
optionApi.save(this.optionsToCreate).then(response => {
this.loadOptions()
this.$message.success(`开发者选项已启用!`)
this.clickCount = 0
this.$router.push({ name: 'ToolList' })
})
} else if (this.clickCount >= 5) {
if (this.options.developer_mode) {
this.$message.info(`当前已启用开发者选项!`)
this.clickCount = 0
} else {
this.$message.info(`再点击 ${10 - this.clickCount} 次即可启用开发者选项!`)
}
}
}
}
}
</script>
<style scope>
.logo-sub-title{
padding-left: 10px;
}
</style>

View File

@ -166,6 +166,13 @@ export const asyncRouterMap = [
redirect: '/system/options',
meta: { title: '系统', icon: 'setting' },
children: [
{
path: '/system/developer/options',
name: 'DeveloperOptions',
hidden: true,
component: () => import('@/views/system/developer/DeveloperOptions'),
meta: { title: '开发者选项', hiddenHeaderContent: false }
},
{
path: '/system/options',
name: 'OptionForm',
@ -195,10 +202,6 @@ export const asyncRouterMap = [
}
]
/**
* 基础路由
* @type { *[] }
*/
export const constantRouterMap = [
{
path: '/login',

View File

@ -5,6 +5,7 @@ import {
import optionApi from '@/api/option'
const keys = [
'blog_url',
'developer_mode',
'attachment_upload_image_preview_enable',
'attachment_upload_max_parallel_uploads',
'attachment_upload_max_files'

View File

@ -2,6 +2,30 @@
<div class="page-header-index-wide">
<div class="card-content">
<a-row :gutter="12">
<a-col
v-if="options.developer_mode"
:xl="6"
:lg="6"
:md="12"
:sm="24"
:xs="24"
:style="{ marginBottom: '12px' }"
>
<a-card
:bordered="false"
:bodyStyle="{ padding: '16px' }"
>
<div slot="title">
<a-icon type="experiment" /> 开发者选项
</div>
<p>点击进入开发者选项页面</p>
<a-button
type="primary"
style="float:right"
@click="handleToDeveloperOptions()"
>进入</a-button>
</a-card>
</a-col>
<a-col
:xl="6"
:lg="6"
@ -70,6 +94,7 @@
</template>
<script>
import { mapGetters } from 'vuex'
import backupApi from '@/api/backup'
import BackupDrawer from './components/BackupDrawer'
@ -82,6 +107,9 @@ export default {
uploadHandler: backupApi.importMarkdown
}
},
computed: {
...mapGetters(['options'])
},
methods: {
handleImportMarkdown() {
this.markdownUpload = true
@ -97,6 +125,9 @@ export default {
this.$message.error(`${info.file.name} 导入失败!`)
}
},
handleToDeveloperOptions() {
this.$router.push({ name: 'DeveloperOptions' })
},
onUploadClose() {
this.$refs.upload.handleClearFileList()
}

View File

@ -0,0 +1,23 @@
<template>
<div class="page-header-index-wide">
<a-row>
<a-col :span="24">
<div class="card-container">
<a-tabs type="card">
<a-tab-pane key="general">
<span slot="tab">
<a-icon type="tool" />请求追踪
</span>
请求追踪
</a-tab-pane>
</a-tabs>
</div>
</a-col>
</a-row>
</div>
</template>
<script>
export default {
}
</script>