feat: 增加配置界面交互,修改菜单

pull/44/head
zhengkunwang223 2 years ago committed by zhengkunwang223
parent ff2b4d030e
commit 4596c496ee

@ -1,11 +1,11 @@
<template> <template>
<el-config-provider :locale="i18nLocale" :button="config" :size="assemblySize"> <el-config-provider :locale="i18nLocale" :button="config" :size="assemblySize">
<router-view></router-view> <router-view v-if="isRouterAlive"></router-view>
</el-config-provider> </el-config-provider>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, computed } from 'vue'; import { reactive, computed, ref, nextTick, provide } from 'vue';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import zhCn from 'element-plus/es/locale/lang/zh-cn'; import zhCn from 'element-plus/es/locale/lang/zh-cn';
import en from 'element-plus/es/locale/lang/en'; import en from 'element-plus/es/locale/lang/en';
@ -24,6 +24,16 @@ const i18nLocale = computed((): any => {
}); });
const assemblySize = computed((): string => globalStore.assemblySize); const assemblySize = computed((): string => globalStore.assemblySize);
let isRouterAlive = ref(true);
const reload = () => {
isRouterAlive.value = false;
nextTick(function () {
isRouterAlive.value = true;
});
};
provide('reload', reload);
</script> </script>
<style scoped lang="scss"></style> <style scoped lang="scss"></style>

@ -1,11 +1,9 @@
<template> <template>
<!-- <el-icon class="back-button" @click="jump">
<Back />
</el-icon> -->
<el-page-header :content="header" @back="jump" /> <el-page-header :content="header" @back="jump" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { inject } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
const router = useRouter(); const router = useRouter();
const props = defineProps({ const props = defineProps({
@ -13,9 +11,13 @@ const props = defineProps({
name: String, name: String,
to: Object, to: Object,
header: String, header: String,
reload: Boolean,
}); });
function jump() { function jump() {
const { path, name, to } = props; const { path, name, to, reload } = props;
if (reload) {
reloadPage();
}
if (path) { if (path) {
router.push(path); router.push(path);
} }
@ -26,16 +28,6 @@ function jump() {
router.push(to); router.push(to);
} }
} }
</script>
<style lang="scss"> let reloadPage: Function = inject('reload');
// .back-button { </script>
// cursor: pointer;
// margin-right: 10px;
// font-weight: 600;
// &:active {
// transform: scale(0.85);
// }
// }
</style>

@ -139,7 +139,7 @@ export default {
cronjob: '', cronjob: '',
host: '', host: '',
security: '', security: '',
files: '', files: '',
monitor: '', monitor: '',
terminal: '', terminal: '',
settings: '', settings: '',
@ -752,5 +752,6 @@ export default {
aliasHelper: '', aliasHelper: '',
lastBackupAt: '', lastBackupAt: '',
null: '无', null: '无',
nginxConfig: 'Nginx',
}, },
}; };

@ -7,8 +7,10 @@
:name="backName" :name="backName"
:to="backTo" :to="backTo"
:header="header" :header="header"
:reload="reload"
v-if="showBack" v-if="showBack"
></back-button> ></back-button>
<!-- <el-page-header @back="reload" v-if="showBack" :content="header"></el-page-header> -->
<span v-else>{{ header }}</span> <span v-else>{{ header }}</span>
</slot> </slot>
</div> </div>
@ -37,11 +39,12 @@ const prop = defineProps({
backPath: String, backPath: String,
backName: String, backName: String,
backTo: Object, backTo: Object,
reload: Boolean,
}); });
const showBack = computed(() => { const showBack = computed(() => {
const { backPath, backName, backTo } = prop; const { backPath, backName, backTo, reload } = prop;
return backPath || backName || backTo; return backPath || backName || backTo || reload;
}); });
</script> </script>

@ -36,14 +36,6 @@ const webSiteRouter = {
title: 'menu.ssl', title: 'menu.ssl',
}, },
}, },
{
path: '/websites/nginx',
name: 'Config',
component: () => import('@/views/website/config/index.vue'),
meta: {
title: 'menu.config',
},
},
], ],
}; };

@ -1,9 +1,9 @@
<template> <template>
<div ref="websiteRef"> <LayoutContent>
<LayoutContent> <AppStatus :app-key="'nginx'" @setting="setting"></AppStatus>
<AppStatus :app-key="'nginx'" :parentRef="websiteRef"></AppStatus> <br />
<br /> <el-card v-if="!openNginxConfig">
<el-card> <LayoutContent :header="$t('website.website')">
<ComplexTable :pagination-config="paginationConfig" :data="data" @search="search()"> <ComplexTable :pagination-config="paginationConfig" :data="data" @search="search()">
<template #toolbar> <template #toolbar>
<el-button type="primary" plain @click="openCreate"> <el-button type="primary" plain @click="openCreate">
@ -30,13 +30,16 @@
fix fix
/> />
</ComplexTable> </ComplexTable>
</el-card> </LayoutContent>
</el-card>
<el-card v-if="openNginxConfig">
<NginxConfig></NginxConfig>
</el-card>
<CreateWebSite ref="createRef" @close="search"></CreateWebSite> <CreateWebSite ref="createRef" @close="search"></CreateWebSite>
<DeleteWebsite ref="deleteRef" @close="search"></DeleteWebsite> <DeleteWebsite ref="deleteRef" @close="search"></DeleteWebsite>
<WebSiteGroup ref="groupRef"></WebSiteGroup> <WebSiteGroup ref="groupRef"></WebSiteGroup>
</LayoutContent> </LayoutContent>
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -49,6 +52,7 @@ import WebSiteGroup from './group/index.vue';
import { SearchWebSites } from '@/api/modules/website'; import { SearchWebSites } from '@/api/modules/website';
import { WebSite } from '@/api/interface/website'; import { WebSite } from '@/api/interface/website';
import AppStatus from '@/components/app-status/index.vue'; import AppStatus from '@/components/app-status/index.vue';
import NginxConfig from './nginx/index.vue';
import i18n from '@/lang'; import i18n from '@/lang';
import router from '@/routers'; import router from '@/routers';
@ -56,7 +60,7 @@ import router from '@/routers';
const createRef = ref(); const createRef = ref();
const deleteRef = ref(); const deleteRef = ref();
const groupRef = ref(); const groupRef = ref();
const websiteRef = ref(); let openNginxConfig = ref(false);
const paginationConfig = reactive({ const paginationConfig = reactive({
currentPage: 1, currentPage: 1,
@ -77,6 +81,9 @@ const search = async () => {
paginationConfig.total = res.data.total; paginationConfig.total = res.data.total;
}); });
}; };
const setting = () => {
openNginxConfig.value = true;
};
const openConfig = (id: number) => { const openConfig = (id: number) => {
router.push({ name: 'WebsiteConfig', params: { id: id, tab: 'basic' } }); router.push({ name: 'WebsiteConfig', params: { id: id, tab: 'basic' } });

@ -1,5 +1,5 @@
<template> <template>
<LayoutContent></LayoutContent> <LayoutContent :header="$t('website.nginxConfig')" :reload="true"></LayoutContent>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
Loading…
Cancel
Save