卡片结构
This commit is contained in:
@@ -76,23 +76,23 @@
|
|||||||
const viewsOpts = computed(() => [
|
const viewsOpts = computed(() => [
|
||||||
{
|
{
|
||||||
name: '主机列表',
|
name: '主机列表',
|
||||||
key: 'host',
|
key: 'hostView',
|
||||||
type: 'radio-group',
|
type: 'radio-group',
|
||||||
defaultVal: appStore.host,
|
defaultVal: appStore.hostView,
|
||||||
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
|
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '主机秘钥',
|
name: '主机秘钥',
|
||||||
key: 'hostKeys',
|
key: 'hostKeyView',
|
||||||
type: 'radio-group',
|
type: 'radio-group',
|
||||||
defaultVal: appStore.hostKeys,
|
defaultVal: appStore.hostKeyView,
|
||||||
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
|
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '主机身份',
|
name: '主机身份',
|
||||||
key: 'hostIdentity',
|
key: 'hostIdentityView',
|
||||||
type: 'radio-group',
|
type: 'radio-group',
|
||||||
defaultVal: appStore.hostIdentity,
|
defaultVal: appStore.hostIdentityView,
|
||||||
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
|
options: [{ value: 'table', label: '表格' }, { value: 'card', label: '卡片' }]
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ const defaultConfig: AppState = {
|
|||||||
menuWidth: 220,
|
menuWidth: 220,
|
||||||
colorWeak: false,
|
colorWeak: false,
|
||||||
// 用户偏好-页面视图
|
// 用户偏好-页面视图
|
||||||
host: 'table',
|
hostView: 'table',
|
||||||
hostKeys: 'table',
|
hostKeyView: 'table',
|
||||||
hostIdentity: 'table',
|
hostIdentityView: 'table',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineStore('app', {
|
export default defineStore('app', {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export type Theme = 'light' | 'dark'
|
export type Theme = 'light' | 'dark'
|
||||||
export type Device = 'desktop' | 'mobile'
|
export type Device = 'desktop' | 'mobile'
|
||||||
export type ViewType = 'table' | 'card'
|
export type ViewType = 'table' | 'card' | undefined
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用状态
|
* 应用状态
|
||||||
@@ -36,7 +36,7 @@ export interface UserPreferenceLayout {
|
|||||||
* 用户偏好 - 页面视图
|
* 用户偏好 - 页面视图
|
||||||
*/
|
*/
|
||||||
export interface UserPreferenceViews {
|
export interface UserPreferenceViews {
|
||||||
host: ViewType | string;
|
hostView: ViewType;
|
||||||
hostKeys: ViewType | string;
|
hostKeyView: ViewType;
|
||||||
hostIdentity: ViewType | string;
|
hostIdentityView: ViewType;
|
||||||
}
|
}
|
||||||
|
|||||||
108
orion-ops-ui/src/views/asset/host/components/host-card-list.vue
Normal file
108
orion-ops-ui/src/views/asset/host/components/host-card-list.vue
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<template>
|
||||||
|
<div class="card-list-layout">
|
||||||
|
<div class="card-list-header">
|
||||||
|
<!-- title slot -->
|
||||||
|
<!-- plusIcon | field field field searchFieldInput searchIcon resetIcon -->
|
||||||
|
<!-- margin -->
|
||||||
|
<!-- cardList / empty -->
|
||||||
|
<!-- margin -->
|
||||||
|
<!-- page -->
|
||||||
|
|
||||||
|
<div>
|
||||||
|
title
|
||||||
|
</div>
|
||||||
|
<div class="card-list-header-left">
|
||||||
|
</div>
|
||||||
|
<div class="card-list-header-right">
|
||||||
|
right search/add
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
card 区域
|
||||||
|
<a-row :gutter="cardLayoutGutter">
|
||||||
|
<a-col v-for="item in list"
|
||||||
|
:key="item.id"
|
||||||
|
class="wrapper"
|
||||||
|
v-bind="cardLayoutCols">
|
||||||
|
<a-card class="general-card"
|
||||||
|
:bordered="false"
|
||||||
|
:hoverable="true"
|
||||||
|
style="width: 98%; height: 120px;">
|
||||||
|
<template #title>
|
||||||
|
{{ item.name }}
|
||||||
|
</template>
|
||||||
|
<template #extra>
|
||||||
|
<icon-more />
|
||||||
|
</template>
|
||||||
|
</a-card>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
page 区域
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'host-card-list'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
const cardLayoutGutter = [
|
||||||
|
{ xs: 16, sm: 16, md: 16 },
|
||||||
|
{ xs: 16, sm: 16, md: 16 }
|
||||||
|
];
|
||||||
|
|
||||||
|
const cardLayoutCols = {
|
||||||
|
xs: 24,
|
||||||
|
sm: 12,
|
||||||
|
md: 8,
|
||||||
|
lg: 6,
|
||||||
|
xl: 4,
|
||||||
|
xxl: 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
const list = ref<Array<any>>([]);
|
||||||
|
|
||||||
|
for (let i = 0; i < 20; i++) {
|
||||||
|
list.value.push({
|
||||||
|
id: i + 1,
|
||||||
|
name: `名称 ${i + 1}`,
|
||||||
|
host: `192.168.1.${i}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
.card-list-layout {
|
||||||
|
.card-list-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
background: var(--color-bg-4);
|
||||||
|
|
||||||
|
&-left {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-right {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.general-card {
|
||||||
|
transition-property: all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.general-card:hover {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -138,8 +138,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import useLoading from '@/hooks/loading';
|
|
||||||
import { updateHostConfigStatus, updateHostConfig } from '@/api/asset/host';
|
import { updateHostConfigStatus, updateHostConfig } from '@/api/asset/host';
|
||||||
import { HostSshConfig, AuthTypeEnum } from '@/views/asset/host/types/host-config.types';
|
import { HostSshConfig, AuthTypeEnum } from '@/views/asset/host/types/host-config.types';
|
||||||
import { sshRules } from '@/views/asset/host/types/host-config.rules';
|
import { sshRules } from '@/views/asset/host/types/host-config.rules';
|
||||||
@@ -147,7 +146,7 @@
|
|||||||
import HostIdentitySelector from '@/components/asset/host-identity/host-identity-selector.vue';
|
import HostIdentitySelector from '@/components/asset/host-identity/host-identity-selector.vue';
|
||||||
import { toOptions } from '@/utils/enum';
|
import { toOptions } from '@/utils/enum';
|
||||||
import { FieldRule, Message } from '@arco-design/web-vue';
|
import { FieldRule, Message } from '@arco-design/web-vue';
|
||||||
import { RoleUpdateRequest } from '@/api/user/role';
|
import useLoading from '@/hooks/loading';
|
||||||
|
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="layout-container">
|
<div class="layout-container">
|
||||||
<!-- 表格 -->
|
<!-- 列表-表格 -->
|
||||||
<host-table ref="table"
|
<host-table v-if="renderTable"
|
||||||
|
ref="table"
|
||||||
|
@openAdd="() => modal.openAdd()"
|
||||||
|
@openUpdate="(e) => modal.openUpdate(e)"
|
||||||
|
@openUpdateConfig="(e) => config.open(e)" />
|
||||||
|
<!-- 列表-卡片 -->
|
||||||
|
<host-card-list v-else
|
||||||
|
ref="card"
|
||||||
@openAdd="() => modal.openAdd()"
|
@openAdd="() => modal.openAdd()"
|
||||||
@openUpdate="(e) => modal.openUpdate(e)"
|
@openUpdate="(e) => modal.openUpdate(e)"
|
||||||
@openUpdateConfig="(e) => config.open(e)" />
|
@openUpdateConfig="(e) => config.open(e)" />
|
||||||
@@ -21,15 +28,21 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { computed, onUnmounted, ref } from 'vue';
|
||||||
|
import { useAppStore, useCacheStore } from '@/store';
|
||||||
import HostTable from './components/host-table.vue';
|
import HostTable from './components/host-table.vue';
|
||||||
|
import HostCardList from '@/views/asset/host/components/host-card-list.vue';
|
||||||
import HostFormModal from './components/host-form-modal.vue';
|
import HostFormModal from './components/host-form-modal.vue';
|
||||||
import { onUnmounted, ref } from 'vue';
|
|
||||||
import { useCacheStore } from '@/store';
|
|
||||||
import HostConfigDrawer from '@/views/asset/host/components/host-config-drawer.vue';
|
import HostConfigDrawer from '@/views/asset/host/components/host-config-drawer.vue';
|
||||||
|
|
||||||
const table = ref();
|
const table = ref();
|
||||||
|
const card = ref();
|
||||||
const modal = ref();
|
const modal = ref();
|
||||||
const config = ref();
|
const config = ref();
|
||||||
|
const appStore = useAppStore();
|
||||||
|
|
||||||
|
// FIXME 临时
|
||||||
|
const renderTable = computed(() => appStore.hostView === 'card');
|
||||||
|
|
||||||
// 卸载时清除 tags cache
|
// 卸载时清除 tags cache
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user