123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <script setup lang="ts">
- import { useSettingsStore } from '@/pinia'
- import { CloseOutlined, DashboardOutlined, DatabaseOutlined } from '@ant-design/icons-vue'
- import { storeToRefs } from 'pinia'
- import { useRouter } from 'vue-router'
- const settingsStore = useSettingsStore()
- const { environment } = storeToRefs(settingsStore)
- const router = useRouter()
- async function clear_env() {
- await router.push('/dashboard')
- settingsStore.clear_environment()
- }
- const is_local = computed(() => {
- return environment.value.id === 0
- })
- const node_id = computed(() => environment.value.id)
- watch(node_id, async () => {
- await router.push('/dashboard')
- location.reload()
- })
- const { server_name } = storeToRefs(useSettingsStore())
- </script>
- <template>
- <div class="indicator">
- <div class="container">
- <DatabaseOutlined />
- <span
- v-if="is_local"
- class="env-name"
- >
- {{ server_name || $gettext('Local') }}
- </span>
- <span
- v-else
- class="env-name"
- >
- {{ environment.name }}
- </span>
- <ATag @click="clear_env">
- <DashboardOutlined v-if="is_local" />
- <CloseOutlined v-else />
- </ATag>
- </div>
- </div>
- </template>
- <style scoped lang="less">
- .ant-layout-sider-collapsed {
- .ant-tag, .env-name {
- display: none;
- }
- .indicator {
- .container {
- justify-content: center;
- }
- }
- }
- .indicator {
- padding: 20px 20px 16px 20px;
- .container {
- border-radius: 16px;
- border: 1px solid #91d5ff;
- background: #e6f7ff;
- padding: 5px 15px;
- color: #096dd9;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .env-name {
- max-width: 85px;
- text-overflow: ellipsis;
- white-space: nowrap;
- line-height: 1em;
- overflow: hidden;
- }
- .ant-tag {
- cursor: pointer;
- margin-right: 0;
- padding: 0 5px;
- }
- }
- }
- .dark {
- .container {
- border: 1px solid #545454;
- background: transparent;
- color: #bebebe;
- }
- }
- </style>
|