mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-18 00:06:40 +00:00
feat(website): add website config checkout (#9752)
This commit is contained in:
@@ -32,6 +32,8 @@ export namespace Website {
|
||||
}
|
||||
|
||||
export interface WebsiteDTO extends Website {
|
||||
status: string;
|
||||
expireDate: string;
|
||||
errorLogPath: string;
|
||||
accessLogPath: string;
|
||||
sitePath: string;
|
||||
|
||||
@@ -11,28 +11,30 @@
|
||||
<LayoutContent :title="$t('website.websiteConfig')" :back-name="'Website'" v-loading="loading">
|
||||
<template #app>
|
||||
<WebsiteStatus
|
||||
v-if="website.id > 0"
|
||||
v-if="website"
|
||||
:id="id"
|
||||
@select="selectWebsite"
|
||||
:primary-domain="website.primaryDomain"
|
||||
:status="website.status"
|
||||
:expire-date="website.expireDate"
|
||||
/>
|
||||
</template>
|
||||
<template #leftToolBar>
|
||||
<el-button type="primary" :plain="index !== 'basic'" @click="changeTab('basic')">
|
||||
<el-button type="primary" :plain="props.tab !== 'basic'" @click="changeTab('basic')">
|
||||
{{ $t('website.basic') }}
|
||||
</el-button>
|
||||
<el-button type="primary" :plain="index !== 'log'" @click="changeTab('log')">
|
||||
<el-button type="primary" :plain="props.tab !== 'log'" @click="changeTab('log')">
|
||||
{{ $t('commons.button.log') }}
|
||||
</el-button>
|
||||
<el-button type="primary" :plain="index !== 'resource'" @click="changeTab('resource')">
|
||||
<el-button type="primary" :plain="props.tab !== 'resource'" @click="changeTab('resource')">
|
||||
{{ $t('website.source', 2) }}
|
||||
</el-button>
|
||||
</template>
|
||||
<template #main>
|
||||
<MainDiv :heightDiff="260">
|
||||
<Basic :website="website" v-if="index === 'basic' && website.id" :heightDiff="320"></Basic>
|
||||
<Log :id="id" v-if="index === 'log'"></Log>
|
||||
<Resource :id="id" v-if="index === 'resource'"></Resource>
|
||||
<MainDiv v-if="website" :heightDiff="260">
|
||||
<Basic :website="website" v-if="props.tab === 'basic'" :heightDiff="320"></Basic>
|
||||
<Log :id="id" v-if="props.tab === 'log'"></Log>
|
||||
<Resource :id="id" v-if="props.tab === 'resource'"></Resource>
|
||||
</MainDiv>
|
||||
</template>
|
||||
</LayoutContent>
|
||||
@@ -40,13 +42,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import Basic from './basic/index.vue';
|
||||
import Resource from './resource/index.vue';
|
||||
import Log from './log/index.vue';
|
||||
import WebsiteStatus from '@/views/website/website/status/index.vue';
|
||||
import { getWebsite } from '@/api/modules/website';
|
||||
import { GetRuntime } from '@/api/modules/runtime';
|
||||
import type { Website } from '@/api/interface/website';
|
||||
import { routerToNameWithParams } from '@/utils/router';
|
||||
import MainDiv from '@/components/main-div/index.vue';
|
||||
import { useGlobalStore } from '@/composables/useGlobalStore';
|
||||
@@ -66,34 +68,19 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const id = ref(0);
|
||||
const index = ref('basic');
|
||||
const website = ref<any>({});
|
||||
const loading = ref(false);
|
||||
const configPHP = ref(false);
|
||||
const id = Number(props.id);
|
||||
const website = ref<Website.WebsiteDTO>();
|
||||
const loading = ref(true);
|
||||
|
||||
watch(index, (curr, old) => {
|
||||
if (curr != old) {
|
||||
changeTab(curr);
|
||||
}
|
||||
});
|
||||
|
||||
const changeTab = (index: string) => {
|
||||
routerToNameWithParams('WebsiteConfig', { id: id.value, tab: index });
|
||||
};
|
||||
const changeTab = (tab: string) => routerToNameWithParams('WebsiteConfig', { id, tab });
|
||||
const selectWebsite = (id: number) => routerToNameWithParams('WebsiteConfig', { id, tab: props.tab });
|
||||
|
||||
onMounted(async () => {
|
||||
index.value = props.tab;
|
||||
id.value = Number(props.id);
|
||||
loading.value = true;
|
||||
const res = await getWebsite(id.value);
|
||||
website.value = res.data;
|
||||
if (res.data.type === 'runtime') {
|
||||
const runRes = await GetRuntime(res.data.runtimeID);
|
||||
if (runRes.data.type == 'php' && runRes.data.resource === 'appstore') {
|
||||
configPHP.value = true;
|
||||
}
|
||||
try {
|
||||
const { data } = await getWebsite(id);
|
||||
website.value = data;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
loading.value = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,21 @@
|
||||
<div class="app-status">
|
||||
<el-card>
|
||||
<div>
|
||||
<el-tag effect="dark" type="success">{{ props.primaryDomain }}</el-tag>
|
||||
<el-select
|
||||
class="website-select"
|
||||
:model-value="props.id"
|
||||
:aria-label="$t('menu.website')"
|
||||
filterable
|
||||
remote
|
||||
remote-show-suffix
|
||||
:remote-method="search"
|
||||
:loading="loading && page === 0"
|
||||
@end-reached="loadMore"
|
||||
@change="(id) => emit('select', id)"
|
||||
>
|
||||
<template #label>{{ props.primaryDomain }}</template>
|
||||
<el-option v-for="site in options" :key="site.id" :value="site.id" :label="site.primaryDomain" />
|
||||
</el-select>
|
||||
<span class="status-content">
|
||||
<Status class="span-font" :key="props.status" :status="props.status"></Status>
|
||||
</span>
|
||||
@@ -20,9 +34,13 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { searchWebsites } from '@/api/modules/website';
|
||||
import type { Website } from '@/api/interface/website';
|
||||
import Status from '@/components/status/index.vue';
|
||||
import { dateFormatSimple } from '@/utils/date';
|
||||
const props = defineProps({
|
||||
id: { type: Number, required: true },
|
||||
primaryDomain: {
|
||||
type: String,
|
||||
default: '',
|
||||
@@ -37,10 +55,58 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits<{ select: [id: number] }>();
|
||||
const options = ref<Website.WebsiteRes[]>([]);
|
||||
const loading = ref(false);
|
||||
const page = ref(0);
|
||||
let total = 0;
|
||||
let query = '';
|
||||
let revision = 0;
|
||||
|
||||
const fetchPage = async () => {
|
||||
const request = revision;
|
||||
const nextPage = page.value + 1;
|
||||
loading.value = true;
|
||||
try {
|
||||
const { data } = await searchWebsites({
|
||||
page: nextPage,
|
||||
pageSize: 20,
|
||||
name: query,
|
||||
orderBy: 'favorite',
|
||||
order: 'descending',
|
||||
websiteGroupId: 0,
|
||||
});
|
||||
if (request !== revision) return;
|
||||
options.value = options.value.concat(data.items ?? []);
|
||||
total = data.total;
|
||||
page.value = nextPage;
|
||||
} finally {
|
||||
if (request === revision) loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const search = (name: string) => {
|
||||
if (query === name && (loading.value || page.value > 0)) return;
|
||||
revision++;
|
||||
query = name;
|
||||
page.value = 0;
|
||||
total = 0;
|
||||
options.value = [];
|
||||
return fetchPage();
|
||||
};
|
||||
|
||||
const loadMore = (direction: string) => {
|
||||
if (direction === 'bottom' && !loading.value && options.value.length < total) return fetchPage();
|
||||
};
|
||||
|
||||
const isEver = (time: string) => {
|
||||
const expireDate = new Date(time);
|
||||
return expireDate > new Date('9999-12-30');
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
<style scoped>
|
||||
.website-select {
|
||||
width: min(18rem, 100%);
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user