feat(文件管理): 存储库部分接口

This commit is contained in:
baiqi 2023-11-06 18:08:29 +08:00 committed by 刘瑞斌
parent 51ac88e681
commit 6b2e192481
11 changed files with 241 additions and 351 deletions

View File

@ -1,8 +1,10 @@
import MSR from '@/api/http/index'; import MSR from '@/api/http/index';
import { import {
AddModuleUrl, AddModuleUrl,
AddRepositoryUrl,
BatchDownloadFileUrl, BatchDownloadFileUrl,
BatchMoveFileUrl, BatchMoveFileUrl,
ConnectRepositoryUrl,
DeleteFileUrl, DeleteFileUrl,
DeleteModuleUrl, DeleteModuleUrl,
DownloadFileUrl, DownloadFileUrl,
@ -11,17 +13,21 @@ import {
GetFileTypesUrl, GetFileTypesUrl,
GetModuleCountUrl, GetModuleCountUrl,
GetModuleUrl, GetModuleUrl,
GetRepositoryFileTypesUrl,
GetRepositoryFileUrl,
MoveModuleUrl, MoveModuleUrl,
ReuploadFileUrl, ReuploadFileUrl,
ToggleJarFileUrl, ToggleJarFileUrl,
UpdateFileUrl, UpdateFileUrl,
UpdateModuleUrl, UpdateModuleUrl,
UpdateRepositoryUrl,
UploadFileUrl, UploadFileUrl,
} from '@/api/requrls/project-management/fileManagement'; } from '@/api/requrls/project-management/fileManagement';
import type { CommonList } from '@/models/common'; import type { CommonList } from '@/models/common';
import type { import type {
AddModuleParams, AddModuleParams,
AddRepositoryParams,
BatchFileApiParams, BatchFileApiParams,
FileDetail, FileDetail,
FileItem, FileItem,
@ -29,9 +35,12 @@ import type {
ModuleCount, ModuleCount,
ModuleTreeNode, ModuleTreeNode,
MoveModuleParams, MoveModuleParams,
Repository,
ReuploadFileParams, ReuploadFileParams,
TestRepositoryConnectParams,
UpdateFileParams, UpdateFileParams,
UpdateModuleParams, UpdateModuleParams,
UpdateRepositoryParams,
UploadFileParams, UploadFileParams,
} from '@/models/projectManagement/file'; } from '@/models/projectManagement/file';
@ -100,7 +109,7 @@ export function deleteModule(id: string) {
return MSR.get({ url: DeleteModuleUrl, params: id }); return MSR.get({ url: DeleteModuleUrl, params: id });
} }
// 获取文件类型集合 // 获取模块文件类型集合
export function getFileTypes(id: string) { export function getFileTypes(id: string) {
return MSR.get<string[]>({ url: GetFileTypesUrl, params: id }); return MSR.get<string[]>({ url: GetFileTypesUrl, params: id });
} }
@ -119,3 +128,28 @@ export function toggleJarFileStatus(id: string, status: boolean) {
export function batchMoveFile(data: BatchFileApiParams) { export function batchMoveFile(data: BatchFileApiParams) {
return MSR.post({ url: BatchMoveFileUrl, data }); return MSR.post({ url: BatchMoveFileUrl, data });
} }
// 查找存储库
export function getRepositories(id: string) {
return MSR.get<Repository[]>({ url: GetRepositoryFileUrl, params: id });
}
// 获取存储库文件类型集合
export function getRepositoryFileTypes(id: string) {
return MSR.get<string[]>({ url: GetRepositoryFileTypesUrl, params: id });
}
// 添加存储库
export function addRepository(data: AddRepositoryParams) {
return MSR.post({ url: AddRepositoryUrl, data });
}
// 测试存储库连接
export function connectRepository(data: TestRepositoryConnectParams) {
return MSR.post({ url: ConnectRepositoryUrl, data });
}
// 修改存储库信息
export function updateRepository(data: UpdateRepositoryParams) {
return MSR.post({ url: UpdateRepositoryUrl, data });
}

View File

@ -13,7 +13,12 @@ export const DeleteModuleUrl = '/project/file-module/delete'; // 删除模块
export const GetModuleCountUrl = '/project/file/module/count'; // 模块统计文件数量 export const GetModuleCountUrl = '/project/file/module/count'; // 模块统计文件数量
export const OriginImgUrl = '/file/preview/original'; // 预览图片文件接口-原图 export const OriginImgUrl = '/file/preview/original'; // 预览图片文件接口-原图
export const CompressImgUrl = '/file/preview/compressed'; // 预览图片文件接口-缩略图 export const CompressImgUrl = '/file/preview/compressed'; // 预览图片文件接口-缩略图
export const GetFileTypesUrl = '/project/file/type'; // 获取文件类型集合 export const GetFileTypesUrl = '/project/file/type'; // 获取模块文件类型集合
export const GetFileDetailUrl = '/project/file/get'; // 查看文件详情 export const GetFileDetailUrl = '/project/file/get'; // 查看文件详情
export const ToggleJarFileUrl = '/project/file/jar-file-status'; // jar 文件启用禁用 export const ToggleJarFileUrl = '/project/file/jar-file-status'; // jar 文件启用禁用
export const BatchMoveFileUrl = '/project/file/batch-move'; // jar 文件启用禁用 export const BatchMoveFileUrl = '/project/file/batch-move'; // jar 文件启用禁用
export const GetRepositoryFileUrl = '/project/file/repository/list'; // 存储库列表
export const GetRepositoryFileTypesUrl = '/project/file/repository/file-type'; // 存储库文件类型列表
export const UpdateRepositoryUrl = '/project/file/repository/update-repository'; // 修改存储库信息
export const ConnectRepositoryUrl = '/project/file/repository/connect'; // 测试存储库连接
export const AddRepositoryUrl = '/project/file/repository/add-repository'; // 添加存储库

View File

@ -37,6 +37,7 @@ export interface UploadFileParams {
request: { request: {
projectId: string; projectId: string;
moduleId: string; // 模块ID moduleId: string; // 模块ID
enable: boolean; // jar文件启用禁用
}; };
file: File; file: File;
} }
@ -52,6 +53,7 @@ export interface UpdateFileParams {
export interface ReuploadFileParams { export interface ReuploadFileParams {
request: { request: {
fileId: string; fileId: string;
enable: boolean; // jar文件启用禁用
}; };
file: File; file: File;
} }
@ -86,3 +88,35 @@ export interface ModuleTreeNode {
type: string; type: string;
children: ModuleTreeNode[]; children: ModuleTreeNode[];
} }
// 存储库列表
export interface Repository {
id: string;
name: string;
type: string;
parentId: string;
children: string[];
attachInfo: Record<string, any>; // 附加信息
count: number;
}
// 存储库公共信息
export interface RepositoryCommon {
name: string;
platform: string;
token: string;
userName: string;
}
// 添加存储库信息入参
export interface AddRepositoryParams extends RepositoryCommon {
projectId: string;
url: string;
}
// 更新存储库信息入参
export interface UpdateRepositoryParams extends RepositoryCommon {
id: string;
}
// 测试存储库连接
export interface TestRepositoryConnectParams {
url: string;
token: string;
userName: string;
}

View File

@ -182,7 +182,7 @@ const useAsyncTaskStore = defineStore('asyncTask', {
try { try {
if (this.uploadFileTask.uploadFunc) { if (this.uploadFileTask.uploadFunc) {
await this.uploadFileTask.uploadFunc({ await this.uploadFileTask.uploadFunc({
request: { ...this.uploadFileTask.requestParams }, request: { ...this.uploadFileTask.requestParams, enable: unref(fileItem)?.enable },
file: unref(fileItem)?.file, file: unref(fileItem)?.file,
}); });
} else { } else {

View File

@ -359,6 +359,7 @@
await reuploadFile({ await reuploadFile({
request: { request: {
fileId: props.fileId, fileId: props.fileId,
enable: false,
}, },
file: data, file: data,
}); });

View File

@ -83,7 +83,7 @@
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { mapTree } from '@/utils'; import { mapTree } from '@/utils';
import { FileListQueryParams, ModuleTreeNode } from '@/models/projectManagement/file'; import { ModuleTreeNode } from '@/models/projectManagement/file';
const props = defineProps<{ const props = defineProps<{
isExpandAll: boolean; isExpandAll: boolean;
@ -91,6 +91,7 @@
selectedKeys?: Array<string | number>; // key selectedKeys?: Array<string | number>; // key
isModal?: boolean; // isModal?: boolean; //
modulesCount?: Record<string, number>; // modulesCount?: Record<string, number>; //
showType?: string; //
}>(); }>();
const emit = defineEmits(['update:selectedKeys', 'init', 'folderNodeSelect']); const emit = defineEmits(['update:selectedKeys', 'init', 'folderNodeSelect']);
@ -283,9 +284,17 @@
} }
} }
onBeforeMount(() => { watch(
initModules(); () => props.showType,
}); (val) => {
if (val === 'Module') {
initModules();
}
},
{
immediate: true,
}
);
/** /**
* 初始化模块文件数量 * 初始化模块文件数量

View File

@ -298,6 +298,7 @@
downloadFile, downloadFile,
getFileList, getFileList,
getFileTypes, getFileTypes,
getRepositoryFileTypes,
toggleJarFileStatus, toggleJarFileStatus,
uploadFile, uploadFile,
} from '@/api/modules/project-management/fileManagement'; } from '@/api/modules/project-management/fileManagement';
@ -339,7 +340,7 @@
const keyword = ref(''); const keyword = ref('');
const loading = ref(false); const loading = ref(false);
const tableFileType = ref(''); const tableFileType = ref(''); //
const tableFileTypeOptions = ref<string[]>([]); const tableFileTypeOptions = ref<string[]>([]);
const fileTypeLoading = ref(false); const fileTypeLoading = ref(false);
@ -349,7 +350,12 @@
async function initFileTypes() { async function initFileTypes() {
try { try {
fileTypeLoading.value = true; fileTypeLoading.value = true;
const res = await getFileTypes(appStore.currentProjectId); let res = null;
if (fileType.value === 'storage') {
res = await getRepositoryFileTypes(appStore.currentProjectId);
} else {
res = await getFileTypes(appStore.currentProjectId);
}
tableFileTypeOptions.value = res; tableFileTypeOptions.value = res;
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@ -359,6 +365,16 @@
} }
} }
watch(
() => props.activeFolderType,
() => {
initFileTypes();
},
{
immediate: true,
}
);
const showType = ref<'list' | 'card'>('list'); // const showType = ref<'list' | 'card'>('list'); //
function getCardClass(type: 'none' | 'jar') { function getCardClass(type: 'none' | 'jar') {
@ -704,9 +720,13 @@
function setTableParams() { function setTableParams() {
if (props.activeFolder === 'my') { if (props.activeFolder === 'my') {
combine.value.createUser = userStore.id; combine.value.createUser = userStore.id;
} else {
combine.value.createUser = '';
} }
if (fileType.value === 'storage') { if (fileType.value === 'storage') {
combine.value.storage = 'git'; combine.value.storage = 'git';
} else {
combine.value.storage = 'module';
} }
let moduleIds: string[] = [props.activeFolder, ...props.offspringIds]; let moduleIds: string[] = [props.activeFolder, ...props.offspringIds];
if (['all', 'my'].includes(props.activeFolder)) { if (['all', 'my'].includes(props.activeFolder)) {
@ -721,7 +741,11 @@
}); });
} }
/**
* 更改文件展示类型模块/存储库
*/
function changeFileType() { function changeFileType() {
initFileTypes();
setTableParams(); setTableParams();
loadList(); loadList();
} }
@ -960,7 +984,6 @@
type RouteQueryPosition = 'uploadDrawer' | null; type RouteQueryPosition = 'uploadDrawer' | null;
onBeforeMount(() => { onBeforeMount(() => {
initFileTypes();
if (route.query.position) { if (route.query.position) {
switch ( switch (
route.query.position as RouteQueryPosition // route.query.position as RouteQueryPosition //

View File

@ -5,41 +5,43 @@
allow-clear allow-clear
class="mb-[8px]" class="mb-[8px]"
></a-input> ></a-input>
<MsList <a-spin class="h-full w-full" :loading="loading">
v-model:focus-item-key="focusItemKey" <MsList
:virtual-list-props="{ v-model:focus-item-key="focusItemKey"
height: 'calc(100vh - 310px)', :virtual-list-props="{
}" height: 'calc(100vh - 310px)',
:data="storageList" }"
:bordered="false" :data="storageList"
:split="false" :bordered="false"
:item-more-actions="folderMoreActions" :split="false"
:empty-text="t('project.fileManagement.noStorage')" :item-more-actions="folderMoreActions"
class="mr-[-6px]" :empty-text="t('project.fileManagement.noStorage')"
@more-action-select="handleMoreSelect" class="mr-[-6px]"
@more-actions-close="moreActionsClose" @more-action-select="handleMoreSelect"
> @more-actions-close="moreActionsClose"
<template #title="{ item, index }"> >
<div :key="index" class="storage" @click="setActiveFolder(item.key)"> <template #title="{ item, index }">
<div :class="props.activeFolder === item.key ? 'storage-text storage-text--active' : 'storage-text'"> <div :key="index" class="storage" @click="setActiveFolder(item.key)">
<MsIcon type="icon-icon_git" class="storage-icon" /> <div :class="props.activeFolder === item.key ? 'storage-text storage-text--active' : 'storage-text'">
<div class="storage-name">{{ item.title }}</div> <MsIcon type="icon-icon_git" class="storage-icon" />
<div class="storage-count">({{ item.count }})</div> <div class="storage-name">{{ item.title }}</div>
<div class="storage-count">({{ item.count }})</div>
</div>
</div> </div>
</div> </template>
</template> <template #itemAction="{ item }">
<template #itemAction="{ item }"> <popConfirm
<popConfirm mode="rename"
mode="rename" :parent-id="item.key"
:parent-id="item.key" :field-config="{ field: renameStorageTitle }"
:field-config="{ field: renameStorageTitle }" :all-names="[]"
:all-names="[]" @close="resetFocusItemKey"
@close="resetFocusItemKey" >
> <span :id="`renameSpan${item.key}`" class="relative"></span>
<span :id="`renameSpan${item.key}`" class="relative"></span> </popConfirm>
</popConfirm> </template>
</template> </MsList>
</MsList> </a-spin>
<MsDrawer <MsDrawer
v-model:visible="showDrawer" v-model:visible="showDrawer"
:title="t(isEdit ? 'project.fileManagement.updateStorageTitle' : 'project.fileManagement.addStorage')" :title="t(isEdit ? 'project.fileManagement.updateStorageTitle' : 'project.fileManagement.addStorage')"
@ -112,12 +114,12 @@
</a-form-item> </a-form-item>
<a-form-item <a-form-item
:label="t('project.fileManagement.storageUsername')" :label="t('project.fileManagement.storageUsername')"
field="username" field="userName"
asterisk-position="end" asterisk-position="end"
:rules="usernameRules" :rules="usernameRules"
> >
<a-input <a-input
v-model:model-value="activeStorageForm.username" v-model:model-value="activeStorageForm.userName"
:max-length="250" :max-length="250"
:placeholder="t('project.fileManagement.storageUsernamePlaceholder')" :placeholder="t('project.fileManagement.storageUsernamePlaceholder')"
allow-clear allow-clear
@ -144,20 +146,25 @@
import MsFormItemSub from '@/components/business/ms-form-item-sub/index.vue'; import MsFormItemSub from '@/components/business/ms-form-item-sub/index.vue';
import popConfirm from './popConfirm.vue'; import popConfirm from './popConfirm.vue';
import { addRepository, connectRepository, getRepositories } from '@/api/modules/project-management/fileManagement';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal'; import useModal from '@/hooks/useModal';
import useAppStore from '@/store/modules/app';
import { validateGitUrl } from '@/utils/validate'; import { validateGitUrl } from '@/utils/validate';
import { Repository } from '@/models/projectManagement/file';
import { GitPlatformEnum } from '@/enums/commonEnum'; import { GitPlatformEnum } from '@/enums/commonEnum';
const props = defineProps<{ const props = defineProps<{
activeFolder: string | number; activeFolder: string | number;
drawerVisible: boolean; drawerVisible: boolean;
showType: string;
}>(); }>();
const emit = defineEmits(['update:drawerVisible', 'itemClick']); const emit = defineEmits(['update:drawerVisible', 'itemClick']);
const { t } = useI18n(); const { t } = useI18n();
const { openModal } = useModal(); const { openModal } = useModal();
const appStore = useAppStore();
const folderMoreActions: ActionsItem[] = [ const folderMoreActions: ActionsItem[] = [
{ {
@ -176,309 +183,49 @@
]; ];
const storageKeyword = ref(''); const storageKeyword = ref('');
const originStorageList = ref([ const originStorageList = ref<Repository[]>([]);
{
title: 'storage1',
key: '1',
count: 129,
},
{
title: 'storage2',
key: '2',
count: 129,
},
{
title: 'storage3',
key: '3',
count: 129,
},
{
title: 'storage3',
key: '3sss',
count: 129,
},
{
title: 'storage3',
key: '3asa',
count: 129,
},
{
title: 'storage3',
key: '3sda',
count: 129,
},
{
title: 'storage3',
key: '3ads',
count: 129,
},
{
title: 'storage3',
key: '3asdd',
count: 129,
},
{
title: 'storage3',
key: '3sdfsdf',
count: 129,
},
{
title: 'storage3',
key: '3dgsg',
count: 129,
},
{
title: 'storage3',
key: '3asd',
count: 129,
},
{
title: 'storage3',
key: '3fwcdw',
count: 129,
},
{
title: 'storage3',
key: '3wef',
count: 129,
},
{
title: 'storage3',
key: '3f2ed',
count: 129,
},
{
title: 'storage3',
key: '3fe2fe',
count: 129,
},
{
title: 'storage3',
key: '3fe2feg2',
count: 129,
},
{
title: 'storage3',
key: '32s22',
count: 129,
},
{
title: 'storage3',
key: '323ff22f',
count: 129,
},
{
title: 'storage3',
key: '33f3f',
count: 129,
},
{
title: 'storage1',
key: '1f2f',
count: 129,
},
{
title: 'storage2',
key: '2ef2ef',
count: 129,
},
{
title: 'storage3',
key: '3sd2fd',
count: 129,
},
{
title: 'storage3',
key: '32ef2ef',
count: 129,
},
{
title: 'storage3',
key: '3f32v',
count: 129,
},
{
title: 'storage3',
key: '323fgt2',
count: 129,
},
{
title: 'storage3',
key: '324g23r',
count: 129,
},
{
title: 'storage3',
key: '3233d2',
count: 129,
},
{
title: 'storage3',
key: '32gftr3',
count: 129,
},
{
title: 'storage3',
key: '323f2dd',
count: 129,
},
{
title: 'storage3',
key: '32fgede',
count: 129,
},
{
title: 'storage3',
key: '32efsad',
count: 129,
},
{
title: 'storage3',
key: '3fsdgsd',
count: 129,
},
{
title: 'storage3',
key: '3sdgvsdxcs',
count: 129,
},
{
title: 'storage3',
key: '3asxc',
count: 129,
},
{
title: 'storage3',
key: '3csdcdg',
count: 129,
},
{
title: 'storage3',
key: '3gsg3f3',
count: 129,
},
{
title: 'storage3',
key: '3d3dxcsd',
count: 129,
},
{
title: 'storage3',
key: '3c3wervvb',
count: 129,
},
{
title: 'storage1',
key: '13vf33',
count: 129,
},
{
title: 'storage2',
key: '234444',
count: 129,
},
{
title: 'storage3',
key: '32323d',
count: 129,
},
{
title: 'storage3',
key: '323ffef',
count: 129,
},
{
title: 'storage3',
key: 'f23f23f3',
count: 129,
},
{
title: 'storage3',
key: '3f2f2f',
count: 129,
},
{
title: 'storage3',
key: '3rf4f2',
count: 129,
},
{
title: 'storage3',
key: '3dsewd',
count: 129,
},
{
title: 'storage3',
key: '3x2ef23f',
count: 129,
},
{
title: 'storage3',
key: '3f3f43',
count: 129,
},
{
title: 'storage3',
key: '3h4hgp',
count: 129,
},
{
title: 'storage3',
key: '3yu6n',
count: 129,
},
{
title: 'storage3',
key: '3nyuk',
count: 129,
},
{
title: 'storage3',
key: '3hn6',
count: 129,
},
{
title: 'storage3',
key: '3nyguhnmm6',
count: 129,
},
{
title: 'storage3',
key: '36n6n',
count: 129,
},
{
title: 'storage3',
key: '3yukyuk',
count: 129,
},
{
title: 'storage3',
key: '3yhnn',
count: 129,
},
{
title: 'storage3',
key: '3gntnty',
count: 129,
},
]);
const storageList = ref(originStorageList.value); const storageList = ref(originStorageList.value);
const loading = ref(false);
const searchStorage = debounce(() => { const searchStorage = debounce(() => {
storageList.value = originStorageList.value.filter((item) => item.title.includes(storageKeyword.value)); storageList.value = originStorageList.value.filter((item) => item.name.includes(storageKeyword.value));
}, 300); }, 300);
watch( watch(
() => storageKeyword.value, () => storageKeyword.value,
() => { () => {
if (storageKeyword.value === '') { if (storageKeyword.value === '') {
storageList.value = originStorageList.value; storageList.value = [...originStorageList.value];
} }
searchStorage(); searchStorage();
} }
); );
/**
* 初始化存储库列表
*/
async function initRepositories() {
try {
loading.value = true;
const res = await getRepositories(appStore.currentProjectId);
originStorageList.value = res;
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
loading.value = false;
}
}
watch(
() => props.showType,
(val) => {
if (val === 'Storage') {
initRepositories();
}
}
);
const focusItemKey = ref(''); const focusItemKey = ref('');
function setActiveFolder(id: string) { function setActiveFolder(id: string) {
@ -505,6 +252,7 @@
try { try {
Message.success(t('project.fileManagement.deleteSuccess')); Message.success(t('project.fileManagement.deleteSuccess'));
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console
console.log(error); console.log(error);
} }
}, },
@ -549,7 +297,7 @@
platform: GitPlatformEnum.GITHUB, platform: GitPlatformEnum.GITHUB,
url: '', url: '',
token: '', token: '',
username: '', userName: '',
}); });
const storageFormRef = ref<FormInstance>(); const storageFormRef = ref<FormInstance>();
const gitPlatformTypes = Object.values(GitPlatformEnum); const gitPlatformTypes = Object.values(GitPlatformEnum);
@ -562,9 +310,10 @@
platform: GitPlatformEnum.GITHUB, platform: GitPlatformEnum.GITHUB,
url: 'xxxxxxx', url: 'xxxxxxx',
token: 'sxsxsx', token: 'sxsxsx',
username: 'ddwdwdwwd', userName: 'ddwdwdwwd',
}; };
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console
console.log(error); console.log(error);
} finally { } finally {
drawerLoading.value = false; drawerLoading.value = false;
@ -605,7 +354,7 @@
}); });
function platformChange() { function platformChange() {
storageFormRef.value?.resetFields('username'); storageFormRef.value?.resetFields('userName');
} }
const exampleUrl = 'http://github.com/xxxxx/xxxxxx.git'; const exampleUrl = 'http://github.com/xxxxx/xxxxxx.git';
@ -620,7 +369,35 @@
} }
} }
// async function saveStorage(isContinue: boolean) {} function handleDrawerCancel() {
showDrawer.value = false;
storageFormRef.value?.resetFields();
isEdit.value = false;
}
/**
* 保存存储库
* @param isContinue 是否继续添加
*/
async function saveStorage(isContinue: boolean) {
try {
drawerLoading.value = true;
await addRepository({
...activeStorageForm.value,
projectId: appStore.currentProjectId,
});
if (!isContinue) {
handleDrawerCancel();
}
Message.success(t('common.addSuccess'));
initRepositories();
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
drawerLoading.value = false;
}
}
/** /**
* 处理抽屉确认 * 处理抽屉确认
@ -629,25 +406,29 @@
function handleDrawerConfirm(isContinue: boolean) { function handleDrawerConfirm(isContinue: boolean) {
storageFormRef.value?.validate(async (errors: Record<string, ValidatedError> | undefined) => { storageFormRef.value?.validate(async (errors: Record<string, ValidatedError> | undefined) => {
if (!errors) { if (!errors) {
// saveStorage(isContinue); saveStorage(isContinue);
} }
}); });
} }
function handleDrawerCancel() {
showDrawer.value = false;
storageFormRef.value?.resetFields();
}
const testLoading = ref(false); const testLoading = ref(false);
function testLink() { function testLink() {
storageFormRef.value?.validate(async (errors: Record<string, ValidatedError> | undefined) => { storageFormRef.value?.validate(async (errors: Record<string, ValidatedError> | undefined) => {
if (!errors) { if (!errors) {
testLoading.value = true; try {
setTimeout(() => { testLoading.value = true;
await connectRepository({
url: activeStorageForm.value.url,
userName: activeStorageForm.value.userName,
token: activeStorageForm.value.token,
});
Message.success(t('project.fileManagement.testLinkSuccess'));
} catch (error) {
// eslint-disable-next-line no-console
console.log(error);
} finally {
testLoading.value = false; testLoading.value = false;
}, 2000); }
} }
}); });
} }

View File

@ -58,6 +58,7 @@
v-model:selected-keys="selectedKeys" v-model:selected-keys="selectedKeys"
:is-expand-all="isExpandAll" :is-expand-all="isExpandAll"
:modules-count="modulesCount" :modules-count="modulesCount"
:show-type="showType"
@init="setRootModules" @init="setRootModules"
@folder-node-select="folderNodeSelect" @folder-node-select="folderNodeSelect"
/> />
@ -66,6 +67,7 @@
<StorageList <StorageList
v-model:drawer-visible="storageDrawerVisible" v-model:drawer-visible="storageDrawerVisible"
:active-folder="activeFolder" :active-folder="activeFolder"
:show-type="showType"
@item-click="storageItemSelect" @item-click="storageItemSelect"
/> />
</div> </div>
@ -100,9 +102,8 @@
import { getModulesCount } from '@/api/modules/project-management/fileManagement'; import { getModulesCount } from '@/api/modules/project-management/fileManagement';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { mapTree } from '@/utils';
import { FileListQueryParams, ModuleTreeNode } from '@/models/projectManagement/file'; import { FileListQueryParams } from '@/models/projectManagement/file';
const { t } = useI18n(); const { t } = useI18n();

View File

@ -34,6 +34,7 @@ export default {
'project.fileManagement.edit': 'Edit', 'project.fileManagement.edit': 'Edit',
'project.fileManagement.cancel': 'Cancel', 'project.fileManagement.cancel': 'Cancel',
'project.fileManagement.testLink': 'Test connection', 'project.fileManagement.testLink': 'Test connection',
'project.fileManagement.testLinkSuccess': 'Connection successful',
'project.fileManagement.storageName': 'Repository name', 'project.fileManagement.storageName': 'Repository name',
'project.fileManagement.storageNamePlaceholder': 'Please enter a repository name', 'project.fileManagement.storageNamePlaceholder': 'Please enter a repository name',
'project.fileManagement.storageNameNotNull': 'Repository name cannot be empty', 'project.fileManagement.storageNameNotNull': 'Repository name cannot be empty',

View File

@ -32,6 +32,7 @@ export default {
'project.fileManagement.edit': '编辑', 'project.fileManagement.edit': '编辑',
'project.fileManagement.cancel': '取消', 'project.fileManagement.cancel': '取消',
'project.fileManagement.testLink': '测试连接', 'project.fileManagement.testLink': '测试连接',
'project.fileManagement.testLinkSuccess': '连接成功',
'project.fileManagement.storageName': '存储库名称', 'project.fileManagement.storageName': '存储库名称',
'project.fileManagement.storageNamePlaceholder': '请输入存储库名称', 'project.fileManagement.storageNamePlaceholder': '请输入存储库名称',
'project.fileManagement.storageNameNotNull': '存储库名称不能为空', 'project.fileManagement.storageNameNotNull': '存储库名称不能为空',