Просмотр исходного кода

系统特殊功能特殊按钮整合

wangxiaoyi 1 год назад
Родитель
Сommit
08b661c45f

+ 152 - 3
src/layout/header-aside/components/header-tools/index.vue

@@ -8,6 +8,23 @@
                 </el-button>
             </el-tooltip>
             <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item v-if="$nodeEnv" @click.native="handleClick">
+                    <div v-if="logLength > 0">
+                        <el-badge
+                            :max="99"
+                            size="small"
+                            class="custom-badge"
+                            :value="logLengthError"
+                            :is-dot="logLengthError === 0"
+                        >
+                            <ibps-icon
+                                :name="logLengthError === 0 ? 'dot-circle-o' : 'bug'"
+                            /> </el-badge>{{ tooltipContent }}
+                    </div>
+                    <div v-else>
+                        <ibps-icon name="dot-circle-o" />{{ tooltipContent }}
+                    </div>
+                </el-dropdown-item>
                 <el-dropdown-item
                     v-for="(item, index) in tools"
                     :key="index"
@@ -21,18 +38,102 @@
             :visible.sync="showConvertAes"
             @close="() => showConvertAes = false"
         />
+        <change-environment
+            v-if="showBaseUrl"
+            :visible.sync="showBaseUrl"
+            @close="() => showBaseUrl = false"
+        />
+        <el-dialog
+            :title="tooltipContent"
+            :visible.sync="dialogVisible"
+            :close-on-click-modal="false"
+            :close-on-press-escape="false"
+            append-to-body
+            fullscreen
+        >
+            <ibps-error-log-list />
+            <div slot="footer" class="el-dialog--center el-dialog--bottom">
+                <el-button
+                    type="primary"
+                    size="mini"
+                    :loading="uploading"
+                    @click="handleUpload"
+                >
+                    <ibps-icon name="cloud-upload" />
+                    {{ $t("layout.header-aside.header-error-log.upload.button") }}
+                </el-button>
+
+                <el-button type="danger" size="mini" @click="handleLogClean">
+                    <ibps-icon name="trash-o" />
+                    {{ $t("common.buttons.clean") }}
+                </el-button>
+            </div>
+        </el-dialog>
     </div>
 </template>
 <script>
+import ChangeEnvironment from '@/views/platform/system/tools/changeEnvironment.vue'
 import ConvertAes from '@/views/platform/system/tools/convertByAes.vue'
+import IbpsErrorLogList from '../header-error-log/components/list'
+import {
+    cleanFormCache,
+    cleanPlatformCache
+} from '@/api/platform/system/cache'
+import { mapGetters, mapState, mapMutations } from 'vuex'
 export default {
     components: {
-        ConvertAes
+        ChangeEnvironment,
+        ConvertAes,
+        IbpsErrorLogList
+    },
+    props: {
+        isSuper: {
+            type: Boolean,
+            default: false
+        }
+    },
+    computed: {
+        ...mapState('ibps/log', ['log']),
+        ...mapGetters('ibps', {
+            logLength: 'log/length',
+            logLengthError: 'log/lengthError'
+        }),
+        tooltipContent () {
+            return this.logLength === 0
+                ? this.$t('layout.header-aside.header-error-log.empty')
+                : this.logLengthError > 0
+                    ? this.$t('layout.header-aside.header-error-log.logError', {
+                        logLength: this.logLength,
+                        logLengthError: this.logLengthError
+                    })
+                    : this.$t('layout.header-aside.header-error-log.logInfo', {
+                        logLength: this.logLength
+                    })
+        }
     },
     data () {
         return {
+            uploading: false,
             showConvertAes: false,
-            tools: [
+            showErrorLog: false,
+            showBaseUrl: false,
+            dialogVisible: false,
+            tools: []
+        }
+    },
+    mounted () {
+        if (this.isSuper) {
+            this.tools = [
+                {
+                    name: '清除平台缓存',
+                    visible: 'showPlatform',
+                    icon: 'ibps-icon-eercast'
+                },
+                {
+                    name: '清除表单缓存',
+                    visible: 'showForm',
+                    icon: 'ibps-icon-connectdevelop'
+                },
                 {
                     name: 'AES加解密',
                     visible: 'showConvertAes',
@@ -40,10 +141,58 @@ export default {
                 }
             ]
         }
+        if (this.$nodeEnv === 'development') {
+            const nodeEnvArry = [
+                {
+                    name: '切换环境',
+                    visible: 'showBaseUrl',
+                    icon: 'ibps-icon-wifi'
+                }
+            ]
+            this.tools = nodeEnvArry.concat(this.tools)
+        }
     },
     methods: {
         handleShowDialog (visible) {
-            this[visible] = true
+            if (visible === 'showPlatform') {
+                cleanPlatformCache().then(() => {
+                    this.$message.success('清除平台缓存成功!')
+                })
+            } else if (visible === 'showForm') {
+                cleanFormCache().then(() => {
+                    this.$message.success('清除表单缓存成功!')
+                })
+            } else {
+                this[visible] = true
+            }
+        },
+        ...mapMutations('ibps/log', ['clean']),
+        handleClick () {
+            if (this.logLength > 0) {
+                this.dialogVisible = true
+            }
+        },
+        handleLogClean () {
+            this.dialogVisible = false
+            this.clean()
+        },
+        // Log upload
+        handleUpload () {
+            this.uploading = true
+            this.$notify({
+                type: 'info',
+                title: this.$t('notify.special.upload.start.title'),
+                message: this.$t('notify.special.upload.start.message')
+            })
+            // TODO:后端接口
+            setTimeout(() => {
+                this.uploading = false
+                this.$notify({
+                    type: 'success',
+                    title: this.$t('notify.special.upload.success.title'),
+                    message: this.$t('notify.special.upload.success.message')
+                })
+            }, 3000)
         }
     }
 }

+ 5 - 5
src/layout/header-aside/layout.vue

@@ -83,8 +83,8 @@
                     <!-- 如果你只想在开发环境显示这个按钮请添加 v-if="$nodeEnv === 'development'" -->
                     <!-- 全局搜索放大镜、日志、环境切换、全屏 -->
                     <!-- <ibps-header-search @click="handleSearchClick" /> -->
-                    <ibps-header-error-log v-if="$nodeEnv === 'development'" />
-                    <ibps-header-base-url v-if="$nodeEnv === 'development'" />
+                    <!-- <ibps-header-error-log v-if="$nodeEnv === 'development'" />
+                    <ibps-header-base-url v-if="$nodeEnv === 'development'" /> -->
 
                     <!-- <ibps-header-download />
                     <ibps-header-locking />
@@ -94,9 +94,9 @@
                     <ibps-header-fullscreen />
                     <ibps-header-tenant /> -->
 
-                    <ibps-header-clean-cache v-if="isSuper" type="platform" />
-                    <ibps-header-clean-cache v-if="isSuper" type="form" />
-                    <ibps-header-tools v-if="isSuper" />
+                    <!-- <ibps-header-clean-cache v-if="isSuper" type="platform" />
+                    <ibps-header-clean-cache v-if="isSuper" type="form" /> -->
+                    <ibps-header-tools :isSuper="isSuper" />
                     <!-- <ibps-header-clean-cache v-if="isSuper" type="oauth" />
                     <ibps-header-clean-cache v-if="isSuper" type="office" /> -->
 

+ 202 - 0
src/views/platform/system/tools/changeEnvironment.vue

@@ -0,0 +1,202 @@
+
+<template>
+    <div>
+        <el-dialog
+            :title="$t('plugins.api-base-url.title')"
+            :visible.sync="active"
+            width="400px"
+            custom-class="changeEnvironment"
+            append-to-body
+            :close-on-click-modal="false"
+            :close-on-press-escape="false"
+            @close="handleClose"
+        >
+            <el-scrollbar>
+                <div class="wrapper">
+                    <div
+                        v-for="option of options"
+                        :key="option.value"
+                        class="item"
+                    >
+                        <el-button
+                            size="default"
+                            :type="isItemActive(option.value) ? 'primary' : 'default'"
+                            style="width: 100%;"
+                            @click="onSelect(option.value,option.single)"
+                        >
+                            <div flex="main:justify cross:center">
+                                <div flex="dir:top cross:top">
+                                    <div class="item-name">
+                                        {{ getTitle(option.name) }}
+                                        ( {{ option.single? $t('plugins.api-base-url.constants.type.single') :$t('plugins.api-base-url.constants.type.non-single') }} )
+                                    </div>
+                                    <div class="item-value">
+                                        {{ option.value }}
+                                    </div>
+                                </div>
+                                <span v-if="isItemActive(option.value)">
+                                    <ibps-icon class="item-icon" name="check-circle" />
+                                </span>
+                                <span
+                                    v-else-if="option.type === 'custom'"
+                                    @click.stop="onRemove(option.value)"
+                                >
+                                    <ibps-icon class="item-icon" name="close" />
+                                </span>
+                            </div>
+                        </el-button>
+                    </div>
+                </div>
+            </el-scrollbar>
+            <el-divider>{{ $t('plugins.api-base-url.or') }}</el-divider>
+            <div flex="main:justify cross:center">
+                <el-input
+                    v-model="customBaseUrl"
+                    class="ibps-mr-5"
+                />
+                <el-tooltip
+                    effect="dark"
+                    :content="$t('plugins.api-base-url.singleApp')"
+                    placement="bottom"
+                >
+                    <el-switch v-model="customSingle" />
+                </el-tooltip>
+                <el-button
+                    :disabled="customBaseUrl.length === 0"
+                    @click="onSetCustom"
+                >{{ $t('plugins.api-base-url.button.ok') }}</el-button>
+            </div>
+            <el-divider />
+            <el-button
+                type="primary"
+                style="width:100%;"
+                @click="onConfirm"
+            >{{ $t('plugins.api-base-url.button.confirm') }}</el-button>
+        </el-dialog>
+    </div>
+</template>
+
+<script>
+import { mapState, mapGetters, mapActions } from 'vuex'
+import { SINGLE_APP, BASE_API } from '@/api/baseUrl'
+export default {
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        }
+    },
+    data () {
+        return {
+            active: this.visible,
+            customBaseUrl: '',
+            customSingle: '',
+            baseUrl: this.base,
+            baseSingle: this.single
+        }
+    },
+    watch: {
+        visible: {
+            handler (val, oldVal) {
+                this.active = this.visible
+            }
+        }
+    },
+    computed: {
+        ...mapState('ibps/api', [
+            'base'
+        ]),
+        ...mapState('ibps/api', [
+            'single'
+        ]),
+        ...mapGetters('ibps/api', [
+            'options'
+        ])
+    },
+    mounted () {
+        this.initData()
+    },
+    methods: {
+        ...mapActions('ibps/api', {
+            baseUrlCustom: 'custom',
+            baseUrlSet: 'set',
+            baseUrlOptionRemove: 'remove'
+        }),
+        initData () {
+            this.customBaseUrl = BASE_API()
+            this.customSingle = SINGLE_APP()
+
+            this.baseUrl = this.base
+            this.baseSingle = this.single
+        },
+        onSelect (value, single) {
+            this.baseUrl = value
+            this.baseSingle = single
+        },
+        onSetCustom () {
+            this.baseUrlCustom({
+                baseUrl: this.customBaseUrl,
+                single: this.customSingle
+            })
+        },
+        onConfirm () {
+            this.$emit('close', false)
+            if (this.base === this.baseUrl) {
+                return
+            }
+            this.baseUrlSet({
+                baseUrl: this.baseUrl,
+                single: this.baseSingle,
+                vm: this
+            })
+            this.$router.replace('/refresh')
+        },
+        handleClose () {
+            this.$emit('close', false)
+        },
+        onRemove (value) {
+            this.baseUrlOptionRemove(value)
+        },
+        isItemActive (value) {
+            return this.baseUrl === value
+        },
+        getTitle (name) {
+            const nameLower = name.toLowerCase()
+            if (this.$te('plugins.api-base-url.constants.env.' + nameLower)) {
+                return this.$t('plugins.api-base-url.constants.env.' + nameLower)
+            }
+            return name
+        }
+    }
+}
+</script>
+  <style lang="scss" scoped>
+  .changeEnvironment {
+    .el-dialog__body {
+      .wrapper {
+        max-height: 220px;
+        .item {
+          &:last-child {
+            .el-button {
+              margin-bottom: 0px;
+            }
+          }
+          .el-button {
+            margin-bottom: 10px;
+            .item-name {
+              font-size: 14px;
+              font-weight: bold;
+              margin-bottom: 4px;
+            }
+            .item-value {
+              font-size: 12px;
+            }
+            .item-icon {
+              font-size: 24px;
+            }
+          }
+        }
+      }
+    }
+  }
+  </style>