<script lang="ts" setup>
|
import { onMounted, reactive, toRefs } from 'vue';
|
|
import { useMessage } from '@jnpf/hooks';
|
import { ScrollContainer } from '@jnpf/ui';
|
import { useModal } from '@jnpf/ui/modal';
|
import { openWindow } from '@jnpf/utils';
|
|
import { delSystem, getSystemList } from '#/api/system/system';
|
import { $t } from '#/locales';
|
import { APP_BACKEND_PREFIX, APP_PREFIX } from '#/utils/constants';
|
|
import Form from './Form.vue';
|
|
defineOptions({ name: 'AppCenter' });
|
|
interface State {
|
keyword: string;
|
loading: boolean;
|
list: any[];
|
}
|
|
const { createConfirm, createMessage } = useMessage();
|
const state = reactive<State>({
|
keyword: '',
|
loading: false,
|
list: [],
|
});
|
const { keyword, loading, list } = toRefs(state);
|
const [registerForm, { openModal: openFormModal }] = useModal();
|
|
function openSystem(enCode) {
|
const url = `${window.location.origin}/${APP_PREFIX + enCode}`;
|
if (url) openWindow(url);
|
}
|
function addOrUpdateHandle(id = '') {
|
openFormModal(true, { id });
|
}
|
function handleDelete(id) {
|
createConfirm({
|
iconType: 'warning',
|
title: $t('common.tipTitle'),
|
content: $t('common.delTip'),
|
onOk: () => {
|
delSystem(id).then((res) => {
|
createMessage.success(res.msg);
|
initData();
|
});
|
},
|
});
|
}
|
function initData() {
|
state.loading = true;
|
getSystemList({ keyword: state.keyword })
|
.then((res) => {
|
state.list = res.data.list || [];
|
state.loading = false;
|
})
|
.catch(() => {
|
state.loading = false;
|
});
|
}
|
onMounted(() => {
|
initData();
|
});
|
</script>
|
|
<template>
|
<div class="appCenter-container" v-loading="loading">
|
<div class="appCenter-container-header">
|
<a-button type="primary" pre-icon="icon-ym icon-ym-btn-add" @click="addOrUpdateHandle()">创建应用</a-button>
|
<div class="header-right">
|
<a-input-search placeholder="搜索应用" allow-clear v-model:value="keyword" :bordered="false" @search="initData" />
|
</div>
|
</div>
|
<div class="appCenter-container-main">
|
<ScrollContainer>
|
<div class="appCenter-container-list">
|
<a-row :gutter="20" class="w-full">
|
<a-col class="app-item" :xs="12" :sm="8" :xl="6" :xxl="4" v-for="item in list" :key="item.id" @click="openSystem(APP_BACKEND_PREFIX + item.enCode)">
|
<a-card hoverable>
|
<div class="app-item-main">
|
<div class="item-icon" :style="{ backgroundColor: item.backgroundColor || '#008cff' }">
|
<i :class="item.icon"></i>
|
</div>
|
<div class="app-item-text">
|
<p class="app-item-title" :title="item.fullName">{{ item.fullName }}</p>
|
<p class="app-item-code" :title="item.enCode">{{ item.enCode }}</p>
|
</div>
|
</div>
|
<div class="item-action">
|
<a-tooltip placement="bottom" title="访问应用">
|
<div class="item-action-item">
|
<div class="item-action-icon" @click.stop="openSystem(item.enCode)">
|
<i class="icon-ym icon-ym-enter"></i>
|
</div>
|
</div>
|
</a-tooltip>
|
<a-tooltip placement="bottom" :title="$t('common.delText')">
|
<div class="item-action-item" v-if="item.hasDelete">
|
<div class="item-action-icon" @click.stop="handleDelete(item.id)">
|
<i class="icon-ym icon-ym-app-delete"></i>
|
</div>
|
</div>
|
</a-tooltip>
|
</div>
|
</a-card>
|
</a-col>
|
</a-row>
|
</div>
|
<jnpf-empty v-if="!list.length" />
|
</ScrollContainer>
|
</div>
|
<Form @register="registerForm" @reload="initData" />
|
</div>
|
</template>
|
|
<style lang="scss" scoped>
|
.appCenter-container {
|
position: relative;
|
display: flex;
|
flex-direction: column;
|
height: 100%;
|
overflow: hidden;
|
background: var(--component-background);
|
border-radius: var(--radius);
|
|
.appCenter-container-header {
|
display: flex;
|
flex-shrink: 0;
|
align-items: center;
|
justify-content: space-between;
|
height: 73px;
|
padding: 0 24px;
|
background-color: #f7f8fa;
|
|
.header-right {
|
width: 220px;
|
padding: 0 6px;
|
overflow: hidden;
|
background: var(--component-background);
|
border-radius: 16px;
|
}
|
|
:deep(.ant-input-search) {
|
.ant-input-affix-wrapper {
|
border: none !important;
|
border-radius: 0;
|
|
&.ant-input-affix-wrapper-focused {
|
box-shadow: unset;
|
}
|
}
|
|
.ant-btn {
|
height: 31px;
|
outline: none !important;
|
outline-offset: 0 !important;
|
border: none !important;
|
border-radius: 0;
|
transition: unset !important;
|
|
& > div {
|
display: none;
|
}
|
}
|
}
|
}
|
|
.appCenter-container-main {
|
flex: 1;
|
overflow: hidden;
|
|
.appCenter-container-list {
|
display: flex;
|
flex-wrap: wrap;
|
place-content: flex-start flex-start;
|
padding: 40px 77px 20px;
|
}
|
|
.app-item {
|
margin-bottom: 20px;
|
cursor: pointer;
|
|
:deep(.ant-card) {
|
height: 152px;
|
border-radius: 8px;
|
}
|
|
.app-item-main {
|
display: flex;
|
align-items: center;
|
margin-bottom: 24px;
|
|
.item-icon {
|
display: flex;
|
flex-shrink: 0;
|
align-items: center;
|
justify-content: center;
|
width: 56px;
|
height: 56px;
|
margin-right: 10px;
|
color: #fff;
|
border-radius: 8px;
|
|
i {
|
font-size: 34px;
|
}
|
}
|
|
.app-item-text {
|
flex: 1;
|
min-width: 0;
|
|
.app-item-title {
|
margin-bottom: 8px;
|
overflow: hidden;
|
text-overflow: ellipsis;
|
font-size: 16px;
|
font-weight: 500;
|
line-height: 22px;
|
white-space: nowrap;
|
}
|
|
.app-item-code {
|
overflow: hidden;
|
text-overflow: ellipsis;
|
font-size: 14px;
|
line-height: 20px;
|
color: var(--text-color-label);
|
white-space: nowrap;
|
}
|
}
|
}
|
|
.item-action {
|
display: flex;
|
align-items: center;
|
|
.item-action-item {
|
position: relative;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
width: 50%;
|
|
&::before {
|
position: absolute;
|
top: 4px;
|
left: 0;
|
display: block;
|
width: 1px;
|
height: 16px;
|
overflow: hidden;
|
content: '';
|
background: var(--border-color-base);
|
}
|
|
&:first-child {
|
&::before {
|
display: none;
|
}
|
}
|
|
.item-action-icon {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
width: 26px;
|
height: 26px;
|
color: var(--text-color-label);
|
border-radius: 2px;
|
|
&:hover {
|
background: var(--app-main-background);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
.dark {
|
.appCenter-container {
|
.appCenter-container-header {
|
background-color: var(--app-content-background);
|
border-bottom: 1px solid var(--border-color-base1);
|
}
|
}
|
}
|
</style>
|