Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -45,7 +45,8 @@
|
||||
"vue": "^3.3.4",
|
||||
"vue-devui": "^1.6.31",
|
||||
"vue-router": "^4.2.2",
|
||||
"yaml": "^2.4.1"
|
||||
"yaml": "^2.4.1",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/eslint-patch": "^1.2.0",
|
||||
@@ -61,7 +62,7 @@
|
||||
"@vue/eslint-config-typescript": "^11.0.3",
|
||||
"@vue/tsconfig": "^0.4.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"eslint": "^9.22.0",
|
||||
|
||||
"eslint-plugin-vue": "^9.11.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss": "^8.4.27",
|
||||
|
||||
@@ -20,11 +20,6 @@ export function releasePage(data): Promise<any> {
|
||||
});
|
||||
}
|
||||
|
||||
// 导出校验结果
|
||||
export function exportVerifyResult() {
|
||||
|
||||
}
|
||||
|
||||
// 获取邀请列表
|
||||
export function getInviteListData(): catchRt<any> {
|
||||
return reqCatchV2(() =>
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
</d-row>
|
||||
<d-row :gutter="16">
|
||||
<d-col :span="8">
|
||||
<d-form-item field="interestTag" label="兴趣标签">
|
||||
<d-input placeholder="请输入兴趣标签" v-model="formData.interestTag" />
|
||||
<d-form-item field="interestTag" label="属性标签">
|
||||
<d-input placeholder="请输入属性标签" v-model="formData.interestTag" />
|
||||
</d-form-item>
|
||||
</d-col>
|
||||
<d-col :span="8">
|
||||
|
||||
@@ -47,9 +47,9 @@
|
||||
<!-- </a>-->
|
||||
<!-- <Create />-->
|
||||
<!-- <SearchAiHistory />-->
|
||||
<d-popover content="提示!" trigger="hover" style="background-color: #7693f5; color: #fff">
|
||||
<!-- <d-popover content="提示!" trigger="hover" style="background-color: #7693f5; color: #fff">
|
||||
<d-icon style="font-size: 16px" name="icon-helping" />
|
||||
</d-popover>
|
||||
</d-popover> -->
|
||||
<Notice />
|
||||
<UserAvatar />
|
||||
</template>
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { ref } from 'vue';
|
||||
import type { Ref } from 'vue';
|
||||
import { repoPathRegExp, repoPathSuffix, repoPathMatch, repoNameRegExp, tagNameHyphenRegExp, tagNamePrefixHeadsRegExp, tagNamePrefixRemotesRegExp, tagNameSuffixLockRegExp, tagNameRegExp } from '@/utils/regex';
|
||||
import {
|
||||
repoPathRegExp,
|
||||
repoPathSuffix,
|
||||
repoPathMatch,
|
||||
repoNameRegExp,
|
||||
tagNameHyphenRegExp,
|
||||
tagNamePrefixHeadsRegExp,
|
||||
tagNamePrefixRemotesRegExp,
|
||||
tagNameSuffixLockRegExp,
|
||||
tagNameRegExp
|
||||
} from '@/utils/regex';
|
||||
import { checkRepoName } from '@/api/repo';
|
||||
import { reqCatch } from '@/utils/catch';
|
||||
function asyncDebounce(fn:Function, wait:number) { // 异步函数版debounce,直接使用lodash的有问题
|
||||
let timerId:any = null;
|
||||
return function(this:any, ...params:any[]) {
|
||||
function asyncDebounce(fn: Function, wait: number) {
|
||||
// 异步函数版debounce,直接使用lodash的有问题
|
||||
let timerId: any = null;
|
||||
return function (this: any, ...params: any[]) {
|
||||
return new Promise((resolve, reject) => {
|
||||
clearTimeout(timerId);
|
||||
timerId = setTimeout(async() => {
|
||||
timerId = setTimeout(async () => {
|
||||
try {
|
||||
const res = await fn.apply(this, params);
|
||||
resolve(res);
|
||||
@@ -19,14 +30,14 @@ function asyncDebounce(fn:Function, wait:number) { // 异步函数版debounce,
|
||||
});
|
||||
};
|
||||
}
|
||||
interface DynamicValidator{
|
||||
(validateRules:Record<string, any[]>):{
|
||||
expected:number, // 期望值
|
||||
validVector:Ref<number> // 当前根据验证情况获取的值
|
||||
}
|
||||
interface DynamicValidator {
|
||||
(validateRules: Record<string, any[]>): {
|
||||
expected: number; // 期望值
|
||||
validVector: Ref<number>; // 当前根据验证情况获取的值
|
||||
};
|
||||
}
|
||||
// 动态的表单验证,能实时监控表单的验证情况,每个字段规则不能超过32条
|
||||
export const useDynamicValidator:DynamicValidator = (validateRules, initValue?) => {
|
||||
export const useDynamicValidator: DynamicValidator = (validateRules, initValue?) => {
|
||||
const keyBitMap = new Map();
|
||||
const validVector = ref(0);
|
||||
// hack:监听校验情况按钮置灰
|
||||
@@ -40,7 +51,8 @@ export const useDynamicValidator:DynamicValidator = (validateRules, initValue?)
|
||||
if (typeof keySeq !== 'undefined') validVector.value &= ~keySeq;
|
||||
return callback();
|
||||
};
|
||||
let index = 0; let expected = 0;
|
||||
let index = 0;
|
||||
let expected = 0;
|
||||
for (const name in validateRules) {
|
||||
const arr = validateRules[name];
|
||||
keyBitMap.set(name, 1 << index);
|
||||
@@ -49,7 +61,7 @@ export const useDynamicValidator:DynamicValidator = (validateRules, initValue?)
|
||||
arr.unshift({ validator: prefix });
|
||||
arr.push({ validator: suffix });
|
||||
}
|
||||
!initValue ? validVector.value = expected : '';// 初始化不置灰
|
||||
!initValue ? (validVector.value = expected) : ''; // 初始化不置灰
|
||||
return {
|
||||
expected,
|
||||
validateRules,
|
||||
@@ -59,62 +71,77 @@ export const useDynamicValidator:DynamicValidator = (validateRules, initValue?)
|
||||
// 项目名称的校验
|
||||
export const repoNameValidator = () => [
|
||||
{ required: true, message: '项目名称不能为空' },
|
||||
{ pattern: repoNameRegExp, message: '项目名称应当由中文、字母、数字、下划线(_)、点(.)和连字符(-)组成,必须以字母、数字、中文、点(.)或下划线(_)开头,且长度不得超过 100 个字符。' },
|
||||
{
|
||||
pattern: repoNameRegExp,
|
||||
message:
|
||||
'项目名称应当由中文、字母、数字、下划线(_)、点(.)和连字符(-)组成,必须以字母、数字、中文、点(.)或下划线(_)开头,且长度不得超过 100 个字符。'
|
||||
},
|
||||
{ pattern: repoPathSuffix, message: '项目名称不能以.wiki,.git,.atom结尾' }
|
||||
];
|
||||
interface RepoPathParams{
|
||||
repoData:any,
|
||||
id:string|undefined,
|
||||
[propName: string]: any,
|
||||
interface RepoPathParams {
|
||||
repoData: any;
|
||||
id: string | undefined;
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
|
||||
export const repoNamePathValidator = ({ repoData, id: selfId, repoId }:RepoPathParams) => {
|
||||
export const repoNamePathValidator = ({ repoData, id: selfId, repoId }: RepoPathParams) => {
|
||||
const { namepath } = repoData;
|
||||
const emptyCheck = (rule: object, value: string, callback: Function) =>
|
||||
callback(namepath.id && namepath.repoPath ? undefined : new Error('项目路径不能为空'));
|
||||
|
||||
const repoPathValidate = async (rule: object, value: object) => {
|
||||
|
||||
const { repoPath, id } = value;
|
||||
|
||||
if(!repoPathRegExp.test(repoPath)){
|
||||
return Promise.reject(new Error('Path的长度必须在1到100个字符之间,只能包含字母(a-z,A-Z)、数字(0-9)、连字符(-)、下划线(_)和点(.),不区分大小写,不能以连字符和(.)开头'));
|
||||
if (!repoPathRegExp.test(repoPath)) {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
'Path的长度必须在1到100个字符之间,只能包含字母(a-z,A-Z)、数字(0-9)、连字符(-)、下划线(_)和点(.),不区分大小写,不能以连字符和(.)开头'
|
||||
)
|
||||
);
|
||||
}
|
||||
if(!repoPathSuffix.test(repoPath)){
|
||||
if (!repoPathSuffix.test(repoPath)) {
|
||||
return Promise.reject(new Error('Path不能以.wiki,.git,.atom结尾'));
|
||||
}
|
||||
if(!repoPathMatch.test(repoPath)){
|
||||
return Promise.reject(new Error('Path不能包含如下关键字:codehub,dashboard,users,profile,merge_requests,issues,milestones,settings,wiki,home,tree,chart,blob,issues-create,review,release,tags,branches,commits,compare,newmergefrom,network,memberlist,labels,setting,files'))
|
||||
if (!repoPathMatch.test(repoPath)) {
|
||||
return Promise.reject(
|
||||
new Error(
|
||||
'Path不能包含如下关键字:codehub,dashboard,users,profile,merge_requests,issues,milestones,settings,wiki,home,tree,chart,blob,issues-create,review,release,tags,branches,commits,compare,newmergefrom,network,memberlist,labels,setting,files'
|
||||
)
|
||||
);
|
||||
}
|
||||
return Promise.resolve('');
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return [
|
||||
{ required: true, validator: emptyCheck },
|
||||
{ asyncValidator: asyncDebounce(repoPathValidate, 200) }
|
||||
];
|
||||
return [{ required: true, validator: emptyCheck }, { asyncValidator: asyncDebounce(repoPathValidate, 200) }];
|
||||
};
|
||||
|
||||
// 项目路径的校验
|
||||
export const repoPathValidator = ({ repoData, id }:RepoPathParams) => {
|
||||
export const repoPathValidator = ({ repoData, id }: RepoPathParams) => {
|
||||
const emptyCheck = (rule: object, value: string, callback: Function) =>
|
||||
callback(repoData.namespace.id && repoData.repoPath ? undefined : new Error('项目路径不能为空'));
|
||||
async function isPathUsed(rule:any, value:string) { // 项目路径是否重复验证
|
||||
async function isPathUsed(rule: any, value: string) {
|
||||
// 项目路径是否重复验证
|
||||
const { namespace } = repoData;
|
||||
const params = {
|
||||
name: value,
|
||||
namespace_id: namespace.id === id ? null : namespace.id
|
||||
};
|
||||
const { data } = await reqCatch(checkRepoName, params);
|
||||
return (data && data.data.status) ? Promise.resolve('') : Promise.reject('path已被使用,请重新输入!');
|
||||
return data && data.data.status ? Promise.resolve('') : Promise.reject('path已被使用,请重新输入!');
|
||||
}
|
||||
return [
|
||||
{ required: true, validator: emptyCheck },
|
||||
{ pattern: repoPathRegExp, message: 'Path的长度必须在1到100个字符之间,只能包含字母(a-z,A-Z)、数字(0-9)、连字符(-)、下划线(_)和点(.),不区分大小写,不能以连字符和(.)开头' },
|
||||
{
|
||||
pattern: repoPathRegExp,
|
||||
message:
|
||||
'Path的长度必须在1到100个字符之间,只能包含字母(a-z,A-Z)、数字(0-9)、连字符(-)、下划线(_)和点(.),不区分大小写,不能以连字符和(.)开头'
|
||||
},
|
||||
{ pattern: repoPathSuffix, message: 'Path不能以.wiki,.git,.atom结尾' },
|
||||
{ pattern: repoPathMatch, message: 'Path不能包含如下关键字:codehub,dashboard,users,profile,merge_requests,issues,milestones,settings,wiki,home,tree,chart,blob,issues-create,review,release,tags,branches,commits,compare,newmergefrom,network,memberlist,labels,setting,files' },
|
||||
{
|
||||
pattern: repoPathMatch,
|
||||
message:
|
||||
'Path不能包含如下关键字:codehub,dashboard,users,profile,merge_requests,issues,milestones,settings,wiki,home,tree,chart,blob,issues-create,review,release,tags,branches,commits,compare,newmergefrom,network,memberlist,labels,setting,files'
|
||||
},
|
||||
{ asyncValidator: asyncDebounce(isPathUsed, 100) }
|
||||
];
|
||||
};
|
||||
@@ -128,3 +155,27 @@ export const tagNameValidator = () => [
|
||||
{ pattern: tagNameRegExp, message: '格式错误,名称由中文、字母、数字_.-和/组成;且/不能连续,最多可以包含 50 个字符' }
|
||||
];
|
||||
|
||||
// 邮箱校验
|
||||
export const checkEmailValidator = (rule: any, value: any, callback: any) => {
|
||||
if (!value) {
|
||||
return callback(new Error('邮箱不能为空'));
|
||||
}
|
||||
// 根据 value 正则校验邮箱格式,成功返回回调callback
|
||||
const reg = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
|
||||
if (!reg.test(value)) {
|
||||
return callback(new Error('邮箱根式不正确'));
|
||||
}
|
||||
callback();
|
||||
};
|
||||
// 手机电话校验
|
||||
export const checkPhoneValidator = (rule: any, value: any, callback: any) => {
|
||||
if (!value) {
|
||||
return callback(new Error('电话不能为空'));
|
||||
}
|
||||
// 根据 value 正则校验手机或者电话格式,成功返回回调callback
|
||||
const reg = /^1[3-9]\d{9}$/;
|
||||
if (!reg.test(value)) {
|
||||
return callback(new Error('电话根式不正确'));
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
<d-button color="primary" variant="solid" @click="search">搜索</d-button>
|
||||
</div>
|
||||
<d-button v-if="isLogin" @click="check" ref="origin" icon="share" class="batch-btn">批量校验</d-button>
|
||||
<div class="home-information">
|
||||
<div class="home-information" v-if="infoList.length > 0">
|
||||
<div class="info-title">
|
||||
<div class="sub-title">
|
||||
<img src="@/assets/imgs/home/informIcon@2x.png" />
|
||||
@@ -140,7 +140,7 @@ const infoList = ref([]);
|
||||
const warningModalVisable = ref(false);
|
||||
const currentWarning = ref();
|
||||
|
||||
const { isLogin } = useDiscussGetUserInfo()
|
||||
const { isLogin } = useDiscussGetUserInfo();
|
||||
const homeSearch = ref(null);
|
||||
const dropdownWidth = ref(0);
|
||||
const selectedCate = ref('软件');
|
||||
@@ -285,7 +285,7 @@ getNoticeList();
|
||||
|
||||
.home-content {
|
||||
font-size: 14px;
|
||||
height: 80%;
|
||||
height: 50%;
|
||||
width: 50%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -16,20 +16,12 @@
|
||||
</d-form-item>
|
||||
</d-col>
|
||||
<d-col span="8">
|
||||
<d-form-item
|
||||
field="email"
|
||||
label="邮件"
|
||||
:rules="[{ required: true, message: '请填写邮件', trigger: 'blur' }]"
|
||||
>
|
||||
<d-form-item field="email" label="邮件" :rules="[{ validator: checkEmailValidator, trigger: 'blur' }]">
|
||||
<d-input v-model="forms.email" />
|
||||
</d-form-item>
|
||||
</d-col>
|
||||
<d-col span="8">
|
||||
<d-form-item
|
||||
field="mobile"
|
||||
label="电话"
|
||||
:rules="[{ required: true, message: '请填写电话', trigger: 'blur' }]"
|
||||
>
|
||||
<d-form-item field="mobile" label="电话" :rules="[{ validator: checkPhoneValidator, trigger: 'blur' }]">
|
||||
<d-input v-model="forms.mobile" />
|
||||
</d-form-item>
|
||||
</d-col>
|
||||
@@ -62,6 +54,7 @@ import { getUserInfo } from '@/api/user';
|
||||
import { onMounted, reactive, ref, shallowRef } from 'vue';
|
||||
import { Message } from 'vue-devui';
|
||||
import { useAccountStore } from '@/stores/user';
|
||||
import { checkEmailValidator, checkPhoneValidator } from '@/utils/validator';
|
||||
|
||||
const loading = ref(false);
|
||||
|
||||
|
||||
@@ -6,17 +6,7 @@
|
||||
accept=".xlsx"
|
||||
:onFileUpload="handleFileUpload"
|
||||
/>
|
||||
<d-input
|
||||
style="width: 400px"
|
||||
v-model="formData.title"
|
||||
placeholder="请输入软件名称"
|
||||
maxLength="50"
|
||||
minLength="2"
|
||||
>
|
||||
<template #prefix>
|
||||
<d-icon name="search" style="font-size: inherit;"></d-icon>
|
||||
</template>
|
||||
</d-input>
|
||||
<d-search class="mt-0 mb-2" style="width: 400px" :delay="1000" @search="onSearch($event)" placeholder="请输入软件名称"></d-search>
|
||||
<div class="tjsj">
|
||||
<span style="height: 14px" class="split"></span>
|
||||
<span>可使用:</span>
|
||||
@@ -120,13 +110,6 @@
|
||||
<NoData v-else :small="false"></NoData>
|
||||
</div>
|
||||
|
||||
<div class="mt-20 mb-20 flex justify-end">
|
||||
<d-pagination size="md" :page-size-options="[10, 20, 50]" :total="pager.total"
|
||||
v-model:pageSize="pager.pageSize" v-model:pageIndex="pager.pageIndex" :max-items="5"
|
||||
:can-change-page-size="true" :can-view-total="true" total-item-text="总计" @page-index-change="changeIndex()"
|
||||
@page-size-change="changeSize()" />
|
||||
</div>
|
||||
|
||||
<!-- 删除组件 -->
|
||||
<GModal v-model="deletevModels" ref="deleteModal" title="删除?" @confirm="confirmDelete" showWarnIcon
|
||||
confirmColor="danger">
|
||||
@@ -150,8 +133,9 @@ import { useAccountStore } from '@/stores/user';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import TableSetting from '@/components/TableSetting/index.vue';
|
||||
import FileUploadButton from '@/components/FileUploadButton/index.vue';
|
||||
import { releasePage, repoImport, exportVerifyResult } from '@/api/jyh';
|
||||
import { releasePage, repoImport } from '@/api/jyh';
|
||||
import NoData from "@/components/NoData/NoData.vue";
|
||||
import * as XLSX from "xlsx"
|
||||
|
||||
const useNum = computed(() => {
|
||||
if (tableData.value.length>0) {
|
||||
@@ -183,8 +167,9 @@ const handleFileUpload = async (file) => {
|
||||
|
||||
const { data, error } = await repoImport({file});
|
||||
if (!error && data) {
|
||||
tableData.value = data.data.data;
|
||||
pager.value.total = data.data.data.length;
|
||||
currentReusltFilter.value = null;
|
||||
allTableData.value = data.data.data
|
||||
tableData.value = [...allTableData.value];
|
||||
}
|
||||
|
||||
// 模拟文件上传逻辑
|
||||
@@ -212,12 +197,18 @@ const columns = ref([
|
||||
{ key: 'primaryLanguage', label: '编程语言', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'codeLines', label: '代码量', visible: true, filterable: false, sortable: false },
|
||||
]);
|
||||
const validStatusMap = {
|
||||
0 : '未治理',
|
||||
1 : '可使用',
|
||||
2 : '有风险'
|
||||
}
|
||||
const formData = ref({ title: '',type: '', useType: '',formData:'',select: '',time1:null,name:'',versionCode:'',pulishTime:'' });
|
||||
const typeOptions = reactive(['主软件', '依赖软件']);
|
||||
const riskOptions = reactive(['低', '中', '高']);
|
||||
const useTypeOptions = reactive(['软件', '文档', '文档+软件']);
|
||||
const isUseOptions = reactive(['是', '否']);
|
||||
const currentReusltFilter = ref(null);
|
||||
const searchStr = ref('');
|
||||
// 定义 tableKey,用于强制刷新表格
|
||||
const tableKey = ref(0);
|
||||
const pager = ref({
|
||||
@@ -259,15 +250,28 @@ onMounted(async() => {
|
||||
// getReleaseList();
|
||||
});
|
||||
|
||||
const filterTable = () => {
|
||||
tableData.value = allTableData.value.filter(item => {
|
||||
if (currentReusltFilter.value !== null) {
|
||||
return item.softwareName.trim().toLowerCase().includes(searchStr.value.trim().toLowerCase()) && item.validStatus === currentReusltFilter.value;
|
||||
} else {
|
||||
return item.softwareName.trim().toLowerCase().includes(searchStr.value.trim().toLowerCase());
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const filterVerifyResult = (type) => {
|
||||
if (currentReusltFilter.value === type) {
|
||||
currentReusltFilter.value = null;
|
||||
tableData.value = [...allTableData.value]
|
||||
} else {
|
||||
tableData.value = allTableData.value.filter(row => row.result === type);
|
||||
currentReusltFilter.value = type;
|
||||
}
|
||||
filterTable();
|
||||
}
|
||||
|
||||
const onSearch = (str: string) => {
|
||||
searchStr.value = str;
|
||||
filterTable();
|
||||
}
|
||||
|
||||
const router = useRouter();
|
||||
@@ -289,8 +293,43 @@ const handleBatchImport = async() => { // 多个项目导入
|
||||
loadingStatus.batchMigrating = false;
|
||||
};
|
||||
|
||||
const exportResult = async() => {
|
||||
const exportResult = () => {
|
||||
|
||||
if (!allTableData.value.length) {
|
||||
Message.info('暂无结果');
|
||||
return;
|
||||
}
|
||||
|
||||
const exportData = allTableData.value.map(item => {
|
||||
let res = {}
|
||||
columns.value.forEach(col => {
|
||||
|
||||
if (col.key === 'validStatus') {
|
||||
res[col.label] = validStatusMap[item[col.key]] ? validStatusMap[item[col.key]] : '';
|
||||
} else {
|
||||
res[col.label] = item[col.key] ? item[col.key] : '';
|
||||
}
|
||||
})
|
||||
return res
|
||||
})
|
||||
|
||||
try {
|
||||
const workSheet = XLSX.utils.json_to_sheet(exportData);
|
||||
const workBook: any = { Sheets: { '校验结果': workSheet}, SheetNames: ['校验结果']};
|
||||
const excelBuffer = XLSX.write(workBook, { bookType: 'xlsx', type: 'array'});
|
||||
|
||||
const link = document.createElement('a');
|
||||
const blob = new Blob([excelBuffer]);
|
||||
link.setAttribute('href', window.URL.createObjectURL(blob));
|
||||
link.setAttribute('download', '软件存在及可信校验结果.xlsx');
|
||||
link.style.visibility = 'hidden';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
Message.success('导出成功')
|
||||
} catch {
|
||||
Message.error('导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转
|
||||
|
||||
Reference in New Issue
Block a user