feat: Add demo mode handling (#8548)

This commit is contained in:
ChengPlay 2025-05-06 18:05:16 +08:00 committed by GitHub
parent c460d9fd7d
commit 47d9c996aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 32 additions and 111 deletions

View file

@ -10,14 +10,18 @@ import (
) )
var whiteUrlList = map[string]struct{}{ var whiteUrlList = map[string]struct{}{
"/core/api/v2/auth/login": {}, "/api/v2/dashboard/app/launcher/option": {},
"/api/v2/websites/config": {}, "/api/v2/websites/config": {},
"/api/v2/websites/waf/config": {}, "/api/v2/websites/waf/config": {},
"/api/v2/files/loadfile": {}, "/api/v2/files/loadfile": {},
"/api/v2/files/size": {}, "/api/v2/files/size": {},
"/api/v2/logs/operation": {}, "/api/v2/runtimes/sync": {},
"/api/v2/logs/login": {}, "/api/v2/toolbox/device/base": {},
"/core/api/v2/auth/logout": {},
"/api/v2/core/auth/login": {},
"/api/v2/core/logs/login": {},
"/api/v2/core/logs/operation": {},
"/api/v2/core/auth/logout": {},
"/api/v2/apps/installed/loadport": {}, "/api/v2/apps/installed/loadport": {},
"/api/v2/apps/installed/check": {}, "/api/v2/apps/installed/check": {},
@ -27,13 +31,18 @@ var whiteUrlList = map[string]struct{}{
"/api/v2/databases/status": {}, "/api/v2/databases/status": {},
"/api/v2/databases/baseinfo": {}, "/api/v2/databases/baseinfo": {},
"/api/v2/waf/attack/stat": {}, "/api/v2/xpack/waf/attack/stat": {},
"/api/v2/waf/config/website": {}, "/api/v2/xpack/waf/config/website": {},
"/api/v2/xpack/waf/relation/stat": {},
"/api/v2/monitor/stat": {}, "/api/v2/xpack/monitor/stat": {},
"/api/v2/monitor/visitors": {}, "/api/v2/xpack/monitor/visitors": {},
"/api/v2/monitor/visitors/loc": {}, "/api/v2/xpack/monitor/visitors/loc": {},
"/api/v2/monitor/qps": {}, "/api/v2/xpack/monitor/qps": {},
"/api/v2/xpack/monitor/logs/stat": {},
"/api/v2/xpack/monitor/websites": {},
"/api/v2/xpack/monitor/trend": {},
"/api/v2/xpack/monitor/rank": {},
} }
func DemoHandle() gin.HandlerFunc { func DemoHandle() gin.HandlerFunc {

View file

@ -1,83 +0,0 @@
<template>
<div v-loading="loading">
<DrawerPro v-model="drawerVisible" :header="$t('terminal.groupChange')" @close="handleClose" size="small">
<el-form @submit.prevent ref="hostInfoRef" label-position="top" :model="dialogData" :rules="rules">
<el-form-item :label="$t('commons.table.group')" prop="group">
<el-select filterable v-model="dialogData.groupID" clearable style="width: 100%">
<div v-for="item in groupList" :key="item.id">
<el-option :label="item.name" :value="item.id" />
</div>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="drawerVisible = false">{{ $t('commons.button.cancel') }}</el-button>
<el-button type="primary" @click="onSubmit(hostInfoRef)">
{{ $t('commons.button.confirm') }}
</el-button>
</template>
</DrawerPro>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive } from 'vue';
import type { ElForm } from 'element-plus';
import { Rules } from '@/global/form-rules';
import { getGroupList } from '@/api/modules/group';
const loading = ref();
interface DialogProps {
group: string;
groupType: string;
}
const drawerVisible = ref(false);
const dialogData = ref({
groupID: 0,
groupType: '',
});
const groupList = ref();
const acceptParams = (params: DialogProps): void => {
dialogData.value.groupType = params.groupType;
loadGroups(params.group);
drawerVisible.value = true;
};
const emit = defineEmits(['search', 'change']);
const handleClose = () => {
drawerVisible.value = false;
};
type FormInstance = InstanceType<typeof ElForm>;
const hostInfoRef = ref<FormInstance>();
const rules = reactive({
groupID: [Rules.requiredSelect],
});
const loadGroups = async (groupName: string) => {
const res = await getGroupList(dialogData.value.groupType);
groupList.value = res.data;
for (const group of groupList.value) {
if (group.name === groupName) {
dialogData.value.groupID = group.id;
break;
}
}
};
const onSubmit = (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) return;
loading.value = true;
emit('change', Number(dialogData.value.groupID));
loading.value = false;
drawerVisible.value = false;
});
};
defineExpose({
acceptParams,
});
</script>

View file

@ -112,14 +112,13 @@ const loadStatus = async () => {
await getSystemAvailable() await getSystemAvailable()
.then((res) => { .then((res) => {
if (res) { if (res) {
window.location.reload();
toLogin(); toLogin();
clearInterval(Number(timer)); clearInterval(Number(timer));
timer = null; timer = null;
} }
}) })
.catch(() => { .catch(() => {
window.location.reload(); toLogin();
clearInterval(Number(timer)); clearInterval(Number(timer));
timer = null; timer = null;
}); });

View file

@ -34,7 +34,6 @@
import { App } from '@/api/interface/app'; import { App } from '@/api/interface/app';
import { getAppByKey, getAppDetail, searchApp } from '@/api/modules/app'; import { getAppByKey, getAppDetail, searchApp } from '@/api/modules/app';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { defineProps } from 'vue';
const props = defineProps({ const props = defineProps({
mode: { mode: {

View file

@ -10,7 +10,6 @@
</template> </template>
<script setup> <script setup>
import { defineProps } from 'vue';
import { Promotion } from '@element-plus/icons-vue'; import { Promotion } from '@element-plus/icons-vue';
defineProps({ defineProps({
row: { row: {

View file

@ -11,7 +11,7 @@
</template> </template>
<script setup> <script setup>
import { defineProps, computed } from 'vue'; import { computed } from 'vue';
import Status from '@/components/status/index.vue'; import Status from '@/components/status/index.vue';
const props = defineProps({ const props = defineProps({

View file

@ -61,7 +61,6 @@
import { Runtime } from '@/api/interface/runtime'; import { Runtime } from '@/api/interface/runtime';
import { GetNodeScripts } from '@/api/modules/runtime'; import { GetNodeScripts } from '@/api/modules/runtime';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
import { defineProps } from 'vue';
const props = defineProps({ const props = defineProps({
mode: { mode: {

View file

@ -31,7 +31,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps, reactive } from 'vue'; import { reactive } from 'vue';
import { FormRules } from 'element-plus'; import { FormRules } from 'element-plus';
import { Rules } from '@/global/form-rules'; import { Rules } from '@/global/form-rules';
import { Runtime } from '@/api/interface/runtime'; import { Runtime } from '@/api/interface/runtime';

View file

@ -120,7 +120,7 @@ import Extensions from './extension-template/index.vue';
import AppResources from '@/views/website/runtime/php/check/index.vue'; import AppResources from '@/views/website/runtime/php/check/index.vue';
import CreateRuntime from '@/views/website/runtime/php/create/index.vue'; import CreateRuntime from '@/views/website/runtime/php/create/index.vue';
import RouterMenu from '../index.vue'; import RouterMenu from '../index.vue';
import Log from '@/components/log/drawer/index.vue'; import Log from '@/components/log/file-drawer/index.vue';
import ComposeLogs from '@/components/log/compose/index.vue'; import ComposeLogs from '@/components/log/compose/index.vue';
import Config from '@/views/website/runtime/php/config/index.vue'; import Config from '@/views/website/runtime/php/config/index.vue';
import Supervisor from '@/views/website/runtime/php/supervisor/index.vue'; import Supervisor from '@/views/website/runtime/php/supervisor/index.vue';

View file

@ -42,7 +42,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { Rules, checkNumberRange } from '@/global/form-rules'; import { Rules, checkNumberRange } from '@/global/form-rules';
import { FormRules } from 'element-plus'; import { FormRules } from 'element-plus';
import { defineProps } from 'vue';
import { useVModel } from '@vueuse/core'; import { useVModel } from '@vueuse/core';
const props = defineProps({ const props = defineProps({

View file

@ -31,7 +31,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineProps, reactive } from 'vue'; import { reactive } from 'vue';
import { FormRules } from 'element-plus'; import { FormRules } from 'element-plus';
import { Rules } from '@/global/form-rules'; import { Rules } from '@/global/form-rules';
import { Runtime } from '@/api/interface/runtime'; import { Runtime } from '@/api/interface/runtime';

View file

@ -175,7 +175,7 @@ import { MsgError, MsgSuccess } from '@/utils/message';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
import SSLUpload from './upload/index.vue'; import SSLUpload from './upload/index.vue';
import Apply from './apply/index.vue'; import Apply from './apply/index.vue';
import Log from '@/components/log/drawer/index.vue'; import Log from '@/components/log/file-drawer/index.vue';
import Obtain from './obtain/index.vue'; import Obtain from './obtain/index.vue';
import MsgInfo from '@/components/msg-info/index.vue'; import MsgInfo from '@/components/msg-info/index.vue';

View file

@ -139,14 +139,14 @@ onUnmounted(() => {
overflow: hidden; overflow: hidden;
} }
.custom-tabs >>> .el-tabs__header.is-left { .custom-tabs :deep(.el-tabs__header.is-left) {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
flex-shrink: 0; flex-shrink: 0;
} }
.custom-tabs >>> .el-tabs__content { .custom-tabs :deep(.el-tabs__content) {
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;

View file

@ -57,7 +57,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { deleteLoadBalance, getLoadBalances } from '@/api/modules/website'; import { deleteLoadBalance, getLoadBalances } from '@/api/modules/website';
import { defineProps, onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import Operate from './operate/index.vue'; import Operate from './operate/index.vue';
import i18n from '@/lang'; import i18n from '@/lang';
import { Website } from '@/api/interface/website'; import { Website } from '@/api/interface/website';