180 lines
6.1 KiB
Diff
180 lines
6.1 KiB
Diff
From 2e5e459a8aabc563f4d6a51c7927d49c2c12af9d Mon Sep 17 00:00:00 2001
|
|
From: hugang <18768366022@163.com>
|
|
Date: Tue, 23 Jul 2024 15:01:34 +0800
|
|
Subject: [PATCH] fix: clear host group_id after selected cluster
|
|
|
|
---
|
|
.gitignore | 3 +-
|
|
package.json | 3 +
|
|
src/views/assests/HostEdition.vue | 7 ++-
|
|
.../assests/components/AddMoreHostModal.vue | 10 ++-
|
|
vite.config.ts | 61 +++++++++++++------
|
|
5 files changed, 62 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/.gitignore b/.gitignore
|
|
index 7b79c41..dc8bf4e 100644
|
|
--- a/.gitignore
|
|
+++ b/.gitignore
|
|
@@ -6,4 +6,5 @@ dist
|
|
.idea
|
|
.vscode
|
|
src/typings
|
|
-pnpm-lock.yaml
|
|
\ No newline at end of file
|
|
+pnpm-lock.yaml
|
|
+stats.html
|
|
diff --git a/package.json b/package.json
|
|
index 6248d04..0f71172 100644
|
|
--- a/package.json
|
|
+++ b/package.json
|
|
@@ -39,9 +39,12 @@
|
|
"@types/nprogress": "^0.2.3",
|
|
"@vitejs/plugin-vue": "^2.3.4",
|
|
"@vue/compiler-sfc": "^3.3.0",
|
|
+ "esbuild-linux-64": "0.14.54",
|
|
+ "esbuild-linux-arm64": "0.14.54",
|
|
"eslint": "^8.56.0",
|
|
"less": "^4.2.0",
|
|
"mockjs": "^1.1.0",
|
|
+ "rollup-plugin-visualizer": "^5.12.0",
|
|
"typescript": "^4.5.5",
|
|
"vite": "^2.9.18",
|
|
"vite-plugin-mock": "^2.0.1",
|
|
diff --git a/src/views/assests/HostEdition.vue b/src/views/assests/HostEdition.vue
|
|
index b67c56f..2f72ead 100644
|
|
--- a/src/views/assests/HostEdition.vue
|
|
+++ b/src/views/assests/HostEdition.vue
|
|
@@ -306,7 +306,12 @@ onMounted(() => {
|
|
</a-form-item>
|
|
|
|
<a-form-item label="集群" name="cluster_id">
|
|
- <a-select v-model:value="form.cluster_id" placeholder="请选择集群" :disabled="pageType === 'edit'">
|
|
+ <a-select
|
|
+ v-model:value="form.cluster_id"
|
|
+ placeholder="请选择集群"
|
|
+ :disabled="pageType === 'edit'"
|
|
+ @change="form.host_group_id = undefined"
|
|
+ >
|
|
<a-select-option
|
|
v-for="cluster in clusterOptions"
|
|
:key="cluster.cluster_id"
|
|
diff --git a/src/views/assests/components/AddMoreHostModal.vue b/src/views/assests/components/AddMoreHostModal.vue
|
|
index f6c579a..21b3a95 100644
|
|
--- a/src/views/assests/components/AddMoreHostModal.vue
|
|
+++ b/src/views/assests/components/AddMoreHostModal.vue
|
|
@@ -9,7 +9,7 @@ import {
|
|
} from '@ant-design/icons-vue'
|
|
import { type FormInstance, type UploadProps, message } from 'ant-design-vue'
|
|
|
|
-import { h, reactive, ref } from 'vue'
|
|
+import { computed, h, reactive, ref } from 'vue'
|
|
import type { Rule } from 'ant-design-vue/es/form'
|
|
import { storeToRefs } from 'pinia'
|
|
import EditableCell from './EditableCell.vue'
|
|
@@ -37,7 +37,11 @@ const formRules: Record<string, Rule[]> = {
|
|
selectedCluster: [{ required: true, message: '请选择集群', trigger: 'change' }],
|
|
}
|
|
|
|
-const { clusters } = storeToRefs(useClusterStore())
|
|
+const { permissions } = storeToRefs(useClusterStore())
|
|
+
|
|
+const clusterOptions = computed(() =>
|
|
+ permissions.value.map(({ cluster_id, cluster_name }) => ({ cluster_id, cluster_name })),
|
|
+)
|
|
|
|
const modalState = reactive({
|
|
visible: false,
|
|
@@ -308,7 +312,7 @@ function handleEdit(key: string) {
|
|
placeholder="请选择集群"
|
|
style="width: 300px"
|
|
>
|
|
- <template v-for="cluster in clusters" :key="cluster.cluster_id">
|
|
+ <template v-for="cluster in clusterOptions" :key="cluster.cluster_id">
|
|
<a-select-option :value="cluster.cluster_id">
|
|
{{
|
|
cluster.cluster_name
|
|
diff --git a/vite.config.ts b/vite.config.ts
|
|
index 8724409..f105732 100644
|
|
--- a/vite.config.ts
|
|
+++ b/vite.config.ts
|
|
@@ -1,9 +1,17 @@
|
|
+// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved.
|
|
+// licensed under the Mulan PSL v2.
|
|
+// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
+// You may obtain a copy of Mulan PSL v2 at:
|
|
+// http://license.coscl.org.cn/MulanPSL2
|
|
+// THIS SOFTWARE IS PROVIDED ON AN 'AS IS' BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
|
+// IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
|
+// PURPOSE.
|
|
+// See the Mulan PSL v2 for more details.
|
|
import { URL, fileURLToPath } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { viteMockServe } from 'vite-plugin-mock'
|
|
-// import AutoImport from 'unplugin-auto-import/vite';
|
|
-// import Components from 'unplugin-vue-components/vite';
|
|
+import { visualizer } from 'rollup-plugin-visualizer'
|
|
|
|
export default () => {
|
|
return defineConfig({
|
|
@@ -21,22 +29,41 @@ export default () => {
|
|
mockPath: 'mock',
|
|
localEnabled: false,
|
|
}),
|
|
-
|
|
- // https://github.com/antfu/unplugin-auto-import
|
|
- // AutoImport({
|
|
- // imports: ['vue', 'vue-router'],
|
|
- // dts: 'src/typings/auto-imports.d.ts',
|
|
- // vueTemplate: true,
|
|
- // }),
|
|
-
|
|
- // https://github.com/antfu/unplugin-vue-components
|
|
- // Components({
|
|
- // extensions: ['vue'],
|
|
- // include: [/\.vue$/, /\.vue\?vue/],
|
|
- // // dts: 'src/typings/components.d.ts',
|
|
- // dts: true,
|
|
- // }),
|
|
+ visualizer({ open: true }),
|
|
],
|
|
+ build: {
|
|
+ minify: 'terser',
|
|
+ terserOptions: {
|
|
+ compress: {
|
|
+ drop_console: true,
|
|
+ drop_debugger: true,
|
|
+ },
|
|
+ },
|
|
+ rollupOptions: {
|
|
+ output: {
|
|
+ chunkFileNames: 'js/[name]-[hash].js',
|
|
+ entryFileNames: 'js/[name]-[hash].js',
|
|
+ assetFileNames: '[ext]/[name]-[hash].[ext]',
|
|
+ manualChunks(id) {
|
|
+ try {
|
|
+ if (id.includes('node_modules')) {
|
|
+ const name = id.split('node_modules/')[1].split('/')
|
|
+ if (name[0] === '.pnpm') {
|
|
+ return name[1]
|
|
+ }
|
|
+ else {
|
|
+ return name[0]
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ catch (error) {
|
|
+ console.error(error)
|
|
+ }
|
|
+ },
|
|
+
|
|
+ },
|
|
+ },
|
|
+ },
|
|
server: {
|
|
host: '0.0.0.0',
|
|
hmr: true,
|
|
--
|
|
2.33.0
|
|
|