|
|
|
@@ -31,7 +31,7 @@ export function parseJsonText(text?: string | null): any | null { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否为对象 |
|
|
|
// 判断是否为一般对象 |
|
|
|
function isPlainObject(value: any) { |
|
|
|
if (value === null || typeof value !== 'object') return false; |
|
|
|
let proto = Object.getPrototypeOf(value); |
|
|
|
@@ -160,13 +160,13 @@ export function changePropertyName(obj: Record<string, any>, mapping: Record<str |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 计算显示的字符串 |
|
|
|
* @param tr 要裁剪的字符串 |
|
|
|
* @param maxWidth 最大宽度 |
|
|
|
* @param fontSize 字体大小 |
|
|
|
* @return 处理后的字符串 |
|
|
|
* 计算能显示的字符串 |
|
|
|
* @param {string} str 要裁剪的字符串 |
|
|
|
* @param {number} maxWidth 最大宽度 |
|
|
|
* @param {number} fontSize 字体大小 |
|
|
|
* @return {string} 处理后的字符串 |
|
|
|
*/ |
|
|
|
export const fittingString = (str: string, maxWidth: number, fontSize: number) => { |
|
|
|
export const fittingString = (str: string, maxWidth: number, fontSize: number): string => { |
|
|
|
if (!str) { |
|
|
|
return ''; |
|
|
|
} |
|
|
|
@@ -200,3 +200,24 @@ export const fittingString = (str: string, maxWidth: number, fontSize: number) = |
|
|
|
export const isEmptyString = (str: any): boolean => { |
|
|
|
return str === '' || str === undefined || str === null; |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取 git 仓库的 url |
|
|
|
* |
|
|
|
* @param {string} url - the url of the git repository |
|
|
|
* @param {string} branch - the branch of the repository |
|
|
|
* @return {string} the url of the repository |
|
|
|
* |
|
|
|
* If `branch` is given, the url will be in the format of 'http://gitlab.com/user/repo/tree/branch'. |
|
|
|
* Otherwise, the url will be in the format of 'http://gitlab.com/user/repo'. |
|
|
|
*/ |
|
|
|
export const getGitUrl = (url: string, branch: string): string => { |
|
|
|
if (!url) { |
|
|
|
return ''; |
|
|
|
} |
|
|
|
const gitUrl = url.replace(/\.git$/, ''); |
|
|
|
if (branch) { |
|
|
|
return `${gitUrl}/tree/${branch}`; |
|
|
|
} |
|
|
|
return gitUrl; |
|
|
|
}; |