---完善应用管理
This commit is contained in:
223
src/api/system/jarInfo/index.ts
Normal file
223
src/api/system/jarInfo/index.ts
Normal file
@ -0,0 +1,223 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { ErrorMessageMode } from '/#/axios';
|
||||
|
||||
export interface SysJarInfo {
|
||||
id?: string;
|
||||
name?: string;
|
||||
vs?: string;
|
||||
custom?: string;
|
||||
bootStart?: string;
|
||||
active?: string;
|
||||
libs?: string;
|
||||
ossPath?: string;
|
||||
size?: number;
|
||||
env?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface SysJarInfoPageListSearchModel {
|
||||
name?: string;
|
||||
custom?: string;
|
||||
bootStart?: string;
|
||||
active?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export interface SysJarInfoPageListResultModel {
|
||||
records: SysJarInfo[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface JarHistoryVersion {
|
||||
id?: string;
|
||||
name?: string;
|
||||
vs?: string;
|
||||
custom?: string;
|
||||
bootStart?: string;
|
||||
active?: string;
|
||||
libs?: string;
|
||||
ossPath?: string;
|
||||
size?: number;
|
||||
env?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface JarHistoryVersionPageListResultModel {
|
||||
records: JarHistoryVersion[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface PublishEnv {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
enum Api {
|
||||
JarInfoPage = '/sys/jar/page',
|
||||
JarInfoList = '/sys/jarInfo/list',
|
||||
JarInfo = '/sys/jarInfo',
|
||||
JarHistoryPage = '/sys/jarInfo/history/page',
|
||||
JarDownload = '/sys/jar/ad/download',
|
||||
JarPublish = '/sys/jar/release',
|
||||
PublishEnvs = '/sys/jarInfo/publish/envs',
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询jar包信息分页列表
|
||||
*/
|
||||
export async function getSysJarInfoPageList(
|
||||
params: SysJarInfoPageListSearchModel,
|
||||
mode: ErrorMessageMode = 'modal',
|
||||
) {
|
||||
return defHttp.get<SysJarInfoPageListResultModel>(
|
||||
{
|
||||
url: Api.JarInfoPage,
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询jar包信息列表
|
||||
*/
|
||||
export async function getSysJarInfoList(
|
||||
params: SysJarInfoPageListSearchModel,
|
||||
mode: ErrorMessageMode = 'modal',
|
||||
) {
|
||||
return defHttp.get<SysJarInfo[]>(
|
||||
{
|
||||
url: Api.JarInfoList,
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取jar包信息
|
||||
*/
|
||||
export async function getSysJarInfo(id: string, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.get<SysJarInfo>(
|
||||
{
|
||||
url: Api.JarInfo,
|
||||
params: { id },
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除jar包信息(批量删除)
|
||||
*/
|
||||
export async function deleteSysJarInfo(ids: string[], mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.delete<number>(
|
||||
{
|
||||
url: Api.JarInfo,
|
||||
data: ids,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 新增jar包信息
|
||||
*/
|
||||
export async function addSysJarInfo(jarInfo: SysJarInfo, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<number>(
|
||||
{
|
||||
url: Api.JarInfo,
|
||||
params: jarInfo,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 更新jar包信息
|
||||
*/
|
||||
export async function updateSysJarInfo(jarInfo: SysJarInfo, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.put<number>(
|
||||
{
|
||||
url: Api.JarInfo,
|
||||
params: jarInfo,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询历史版本分页列表
|
||||
*/
|
||||
export async function getJarHistoryVersionPageList(
|
||||
params: { jarId: string; page?: number; pageSize?: number },
|
||||
mode: ErrorMessageMode = 'modal',
|
||||
) {
|
||||
return defHttp.get<JarHistoryVersionPageListResultModel>(
|
||||
{
|
||||
url: Api.JarHistoryPage,
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 下载jar包
|
||||
*/
|
||||
export async function downloadJar(name: string, env: string, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<Blob>(
|
||||
{
|
||||
url: Api.JarDownload+`?name=${encodeURIComponent(name)}&env=${encodeURIComponent(env)}`,
|
||||
responseType: 'blob',
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
isTransformResponse: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 发布jar包
|
||||
*/
|
||||
export async function publishJar(params: { name: string; env: string; fromEnv: string }, mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.post<number>(
|
||||
{
|
||||
url: Api.JarPublish,
|
||||
params,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取可发布的环境列表
|
||||
*/
|
||||
export async function getPublishEnvs(mode: ErrorMessageMode = 'modal') {
|
||||
return defHttp.get<PublishEnv[]>(
|
||||
{
|
||||
url: Api.PublishEnvs,
|
||||
},
|
||||
{
|
||||
errorMessageMode: mode,
|
||||
},
|
||||
);
|
||||
}
|
||||
165
src/views/system/jarInfo/components/HistoryVersionModal.vue
Normal file
165
src/views/system/jarInfo/components/HistoryVersionModal.vue
Normal file
@ -0,0 +1,165 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
@register="registerModal"
|
||||
title="历史版本"
|
||||
width="1000px"
|
||||
:canFullscreen="false"
|
||||
:showOkBtn="false"
|
||||
:showCancelBtn="false"
|
||||
>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '下载',
|
||||
onClick: handleDownload.bind(null, record)
|
||||
}
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable, TableAction, BasicColumn } from '/@/components/Table';
|
||||
import { getJarHistoryVersionPageList, downloadJar, JarHistoryVersion } from '/@/api/system/jarInfo';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { Tag } from 'ant-design-vue';
|
||||
import { h } from 'vue';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '版本',
|
||||
dataIndex: 'vs',
|
||||
width: 120,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '是否开发包',
|
||||
dataIndex: 'custom',
|
||||
width: 120,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isCustom = record.custom === 'Y';
|
||||
const color = isCustom ? 'blue' : 'default';
|
||||
const text = isCustom ? '是' : '否';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '是否boot开始',
|
||||
dataIndex: 'bootStart',
|
||||
width: 120,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isBoot = record.bootStart === 'Y';
|
||||
const color = isBoot ? 'green' : 'default';
|
||||
const text = isBoot ? '是' : '否';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '是否活跃',
|
||||
dataIndex: 'active',
|
||||
width: 100,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isActive = record.active === 'Y';
|
||||
const color = isActive ? 'green' : 'default';
|
||||
const text = isActive ? '是' : '否';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'jar库列表',
|
||||
dataIndex: 'libs',
|
||||
width: 150,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '环境',
|
||||
dataIndex: 'env',
|
||||
width: 100,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
align: 'left'
|
||||
}
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'HistoryVersionModal',
|
||||
components: { BasicModal, BasicTable, TableAction },
|
||||
emits: ['success', 'register'],
|
||||
setup() {
|
||||
const { createMessage } = useMessage();
|
||||
let currentJarId = '';
|
||||
|
||||
const [registerTable, { reload }] = useTable({
|
||||
api: getJarHistoryVersionPageList,
|
||||
rowKey: 'id',
|
||||
columns,
|
||||
useSearchForm: false,
|
||||
showTableSetting: false,
|
||||
striped: false,
|
||||
pagination: true,
|
||||
actionColumn: {
|
||||
width: 100,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' }
|
||||
}
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
currentJarId = data.jarId || '';
|
||||
setModalProps({
|
||||
confirmLoading: false,
|
||||
title: `历史版本 - ${data.jarName || ''}`
|
||||
});
|
||||
reload({
|
||||
searchInfo: { jarId: currentJarId },
|
||||
page: 1
|
||||
});
|
||||
});
|
||||
|
||||
async function handleDownload(record: JarHistoryVersion) {
|
||||
try {
|
||||
const res = await downloadJar(record.id!);
|
||||
// 创建下载链接
|
||||
const blob = new Blob([res as any]);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `${record.name}-${record.vs}.jar`;
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
createMessage.success('下载成功');
|
||||
} catch (error) {
|
||||
createMessage.error('下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
registerModal,
|
||||
registerTable,
|
||||
handleDownload
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
142
src/views/system/jarInfo/components/PublishModal.vue
Normal file
142
src/views/system/jarInfo/components/PublishModal.vue
Normal file
@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
@register="registerModal"
|
||||
title="发布jar包"
|
||||
width="600px"
|
||||
:canFullscreen="false"
|
||||
@ok="handleOk"
|
||||
:confirmLoading="confirmLoading"
|
||||
>
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form';
|
||||
import { publishJar, getPublishEnvs } from '/@/api/system/jarInfo';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PublishModal',
|
||||
components: { BasicModal, BasicForm },
|
||||
emits: ['success', 'register'],
|
||||
setup(_, { emit }) {
|
||||
const { createMessage } = useMessage();
|
||||
const confirmLoading = ref(false);
|
||||
let currentJarId = '';
|
||||
let currentJarName = '';
|
||||
let currentJarEnv = '';
|
||||
|
||||
const envs = [{ label: '测试', value: 'TEST' }, { label: '生产', value: 'PROD' }];
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
||||
labelWidth: 100,
|
||||
schemas: [
|
||||
{
|
||||
field: 'jarInfo',
|
||||
label: 'Jar包信息',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true
|
||||
},
|
||||
colProps: { span: 24 }
|
||||
},
|
||||
{
|
||||
field: 'env',
|
||||
label: '发布环境',
|
||||
component: 'Select',
|
||||
required: true,
|
||||
componentProps: {
|
||||
options: envs,
|
||||
placeholder: '请选择发布环境'
|
||||
},
|
||||
colProps: { span: 24 }
|
||||
}
|
||||
],
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 24 }
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
confirmLoading.value = false;
|
||||
currentJarId = data.id || '';
|
||||
currentJarName = data.name || '';
|
||||
currentJarEnv = data.env || 'LOCAL';
|
||||
|
||||
// 设置jar包信息
|
||||
setFieldsValue({
|
||||
jarInfo: `${currentJarName} - ${currentJarEnv}`
|
||||
});
|
||||
|
||||
// 加载环境列表
|
||||
try {
|
||||
|
||||
|
||||
setFieldsValue({
|
||||
env: undefined
|
||||
});
|
||||
// 更新环境选项
|
||||
const schemas = [
|
||||
{
|
||||
field: 'jarInfo',
|
||||
label: 'Jar包信息',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true
|
||||
},
|
||||
colProps: { span: 24 }
|
||||
},
|
||||
{
|
||||
field: 'env',
|
||||
label: '发布环境',
|
||||
component: 'Select',
|
||||
required: true,
|
||||
componentProps: {
|
||||
options: envs,
|
||||
placeholder: '请选择发布环境'
|
||||
},
|
||||
colProps: { span: 24 }
|
||||
}
|
||||
];
|
||||
// 注意:这里需要重新注册表单以更新选项,或者使用其他方式动态更新
|
||||
} catch (error) {
|
||||
createMessage.error('加载环境列表失败');
|
||||
}
|
||||
|
||||
setModalProps({ confirmLoading: false });
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
try {
|
||||
const values = await validate();
|
||||
confirmLoading.value = true;
|
||||
|
||||
await publishJar({
|
||||
name: currentJarName,
|
||||
env: values.env,
|
||||
fromEnv: currentJarEnv
|
||||
});
|
||||
|
||||
createMessage.success('发布成功');
|
||||
emit('success');
|
||||
closeModal();
|
||||
} catch (error) {
|
||||
createMessage.error('发布失败');
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
registerModal,
|
||||
registerForm,
|
||||
confirmLoading,
|
||||
handleOk
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
255
src/views/system/jarInfo/index.vue
Normal file
255
src/views/system/jarInfo/index.vue
Normal file
@ -0,0 +1,255 @@
|
||||
<template>
|
||||
<PageWrapper dense contentFullHeight fixedHeight>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<!-- 可以添加新增等按钮 -->
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '查看历史版本',
|
||||
onClick: handleViewHistory.bind(null, record)
|
||||
},
|
||||
{
|
||||
label: '下载',
|
||||
onClick: handleDownload.bind(null, record)
|
||||
},
|
||||
{
|
||||
label: '发布',
|
||||
ifShow: record.bootStart === 'Y' && record.active === 'Y',
|
||||
onClick: handlePublish.bind(null, record)
|
||||
}
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<HistoryVersionModal @register="registerHistoryModal" />
|
||||
<PublishModal @register="registerPublishModal" @success="handleSuccess" />
|
||||
</PageWrapper>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { defineComponent, h } from 'vue';
|
||||
import { BasicTable, useTable, TableAction, FormSchema, BasicColumn } from '/@/components/Table';
|
||||
import { getSysJarInfoPageList, downloadJar, SysJarInfo } from '/@/api/system/jarInfo';
|
||||
import { PageWrapper } from '/@/components/Page';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { Tag } from 'ant-design-vue';
|
||||
import HistoryVersionModal from './components/HistoryVersionModal.vue';
|
||||
import PublishModal from './components/PublishModal.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
field: 'name',
|
||||
label: '名称',
|
||||
component: 'Input',
|
||||
colProps: { lg: 6, md: 12, sm: 12 }
|
||||
},
|
||||
{
|
||||
field: 'custom',
|
||||
label: '是否开发包',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '是', value: 'Y' },
|
||||
{ label: '否', value: 'N' }
|
||||
]
|
||||
},
|
||||
colProps: { lg: 6, md: 12, sm: 12 }
|
||||
},
|
||||
{
|
||||
field: 'bootStart',
|
||||
label: '是否应用',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '是', value: 'Y' },
|
||||
{ label: '否', value: 'N' }
|
||||
]
|
||||
},
|
||||
colProps: { lg: 6, md: 12, sm: 12 }
|
||||
},
|
||||
{
|
||||
field: 'active',
|
||||
label: '是否活跃',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: [
|
||||
{ label: '是', value: 'Y' },
|
||||
{ label: '否', value: 'N' }
|
||||
]
|
||||
},
|
||||
colProps: { lg: 6, md: 12, sm: 12 }
|
||||
}
|
||||
];
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
width: 200,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '版本',
|
||||
dataIndex: 'vs',
|
||||
width: 120,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '开发包',
|
||||
dataIndex: 'custom',
|
||||
width: 120,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isCustom = record.custom === 'Y';
|
||||
const color = isCustom ? 'blue' : 'default';
|
||||
const text = isCustom ? '是' : '否';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '应用',
|
||||
dataIndex: 'bootStart',
|
||||
width: 120,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isBoot = record.bootStart === 'Y';
|
||||
const color = isBoot ? 'green' : 'default';
|
||||
const text = isBoot ? '是' : '否';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '活跃',
|
||||
dataIndex: 'active',
|
||||
width: 100,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isActive = record.active === 'Y';
|
||||
const color = isActive ? 'green' : 'default';
|
||||
const text = isActive ? '是' : '否';
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '环境',
|
||||
dataIndex: 'env',
|
||||
width: 120,
|
||||
align: 'left',
|
||||
customRender: ({ record }) => {
|
||||
const isDev = record.env == 'LOCAL';
|
||||
const color = isDev ? 'default' : 'blue';
|
||||
let text = '开发';
|
||||
if(record.env == 'TEST'){
|
||||
text = '测试';
|
||||
} else if(record.env == 'PROD'){
|
||||
text = '生产';
|
||||
}
|
||||
return h(Tag, { color: color }, () => text);
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '库列表',
|
||||
dataIndex: 'libs',
|
||||
width: 150,
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
width: 180,
|
||||
align: 'left'
|
||||
}
|
||||
];
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SysJarInfoManagement',
|
||||
components: { BasicTable, PageWrapper, TableAction, HistoryVersionModal, PublishModal },
|
||||
setup() {
|
||||
const { notification, createMessage } = useMessage();
|
||||
const [registerHistoryModal, { openModal: openHistoryModal }] = useModal();
|
||||
const [registerPublishModal, { openModal: openPublishModal }] = useModal();
|
||||
|
||||
const [registerTable, { reload }] = useTable({
|
||||
title: 'jar包信息列表',
|
||||
api: getSysJarInfoPageList,
|
||||
rowKey: 'id',
|
||||
columns,
|
||||
formConfig: {
|
||||
rowProps: {
|
||||
gutter: 16
|
||||
},
|
||||
schemas: searchFormSchema,
|
||||
showResetButton: false
|
||||
},
|
||||
useSearchForm: true,
|
||||
showTableSetting: true,
|
||||
striped: false,
|
||||
actionColumn: {
|
||||
width: 280,
|
||||
title: '操作',
|
||||
dataIndex: 'action',
|
||||
slots: { customRender: 'action' }
|
||||
},
|
||||
tableSetting: {
|
||||
size: false,
|
||||
setting: false
|
||||
}
|
||||
});
|
||||
|
||||
function handleViewHistory(record: SysJarInfo) {
|
||||
openHistoryModal(true, {
|
||||
jarId: record.id,
|
||||
jarName: record.name
|
||||
});
|
||||
}
|
||||
|
||||
async function handleDownload(record: SysJarInfo) {
|
||||
try {
|
||||
const res = await downloadJar(record.name, record.env);
|
||||
// 创建下载链接
|
||||
const blob = new Blob([res as any]);
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `${record.name}-${record.vs}.jar`;
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
createMessage.success('下载成功');
|
||||
} catch (error) {
|
||||
createMessage.error('下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
function handlePublish(record: SysJarInfo) {
|
||||
openPublishModal(true, {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
env: record.env
|
||||
});
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
reload();
|
||||
}
|
||||
|
||||
return {
|
||||
registerTable,
|
||||
registerHistoryModal,
|
||||
registerPublishModal,
|
||||
handleViewHistory,
|
||||
handleDownload,
|
||||
handlePublish,
|
||||
handleSuccess,
|
||||
t
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user