Files
orion-visor/orion-ops-ui/src/components/global-setting/index.vue

126 lines
2.7 KiB
Vue
Raw Normal View History

2023-07-24 10:05:07 +08:00
<template>
<div v-if="!appStore.navbar" class="fixed-settings" @click="setVisible">
<a-button type="primary">
<template #icon>
<icon-settings />
</template>
</a-button>
</div>
<a-drawer
:width="300"
unmount-on-close
:visible="visible"
:cancel-text="$t('settings.close')"
:ok-text="$t('settings.copySettings')"
@ok="copySettings"
@cancel="cancel"
>
2023-07-27 18:48:15 +08:00
<template #title> {{ $t('settings.title') }}</template>
2023-07-24 10:05:07 +08:00
<Block :options="contentOpts" :title="$t('settings.content')" />
<Block :options="othersOpts" :title="$t('settings.otherSettings')" />
<a-alert>{{ $t('settings.alertContent') }}</a-alert>
</a-drawer>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import { Message } from '@arco-design/web-vue';
import { useI18n } from 'vue-i18n';
import { useClipboard } from '@vueuse/core';
import { useAppStore } from '@/store';
import Block from './block.vue';
const emit = defineEmits(['cancel']);
const appStore = useAppStore();
const { t } = useI18n();
const { copy } = useClipboard();
const visible = computed(() => appStore.globalSettings);
2023-07-27 18:48:15 +08:00
/**
* 内容配置
*/
2023-07-24 10:05:07 +08:00
const contentOpts = computed(() => [
2023-07-27 18:48:15 +08:00
{
name: 'settings.navbar',
key: 'navbar',
defaultVal: appStore.navbar
},
2023-07-24 10:05:07 +08:00
{
name: 'settings.menu',
key: 'menu',
defaultVal: appStore.menu,
},
{
name: 'settings.topMenu',
key: 'topMenu',
defaultVal: appStore.topMenu,
},
{
2023-07-27 18:48:15 +08:00
name: 'settings.footer',
key: 'footer',
defaultVal:
appStore.footer
},
{
name: 'settings.tabBar',
key: 'tabBar',
defaultVal: appStore.tabBar
2023-07-24 10:05:07 +08:00
},
{
name: 'settings.menuWidth',
key: 'menuWidth',
defaultVal: appStore.menuWidth,
type: 'number',
},
]);
2023-07-27 18:48:15 +08:00
/**
* 其他配置
*/
2023-07-24 10:05:07 +08:00
const othersOpts = computed(() => [
{
name: 'settings.colorWeak',
key: 'colorWeak',
defaultVal: appStore.colorWeak,
},
]);
2023-07-27 18:48:15 +08:00
/**
* 取消配置
*/
2023-07-24 10:05:07 +08:00
const cancel = () => {
appStore.updateSettings({ globalSettings: false });
emit('cancel');
};
2023-07-27 18:48:15 +08:00
/**
* 复制配置
*/
2023-07-24 10:05:07 +08:00
const copySettings = async () => {
const text = JSON.stringify(appStore.$state, null, 2);
await copy(text);
Message.success(t('settings.copySettings.message'));
};
2023-07-27 18:48:15 +08:00
/**
* 显示菜单
*/
2023-07-24 10:05:07 +08:00
const setVisible = () => {
appStore.updateSettings({ globalSettings: true });
};
</script>
<style scoped lang="less">
.fixed-settings {
position: fixed;
top: 280px;
right: 0;
svg {
font-size: 18px;
vertical-align: -4px;
}
}
</style>