mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2025-01-18 16:54:00 +08:00
add parseType util file
This commit is contained in:
parent
4fc48f6570
commit
84748086e6
@ -1,4 +1,3 @@
|
||||
import { Version } from '../../core/typings/version';
|
||||
import { apiService } from './api-service';
|
||||
|
||||
export function mountUtilMethods() {
|
||||
@ -16,20 +15,3 @@ export function mountUtilMethods() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// parse component Type
|
||||
export function parseType(v: string) {
|
||||
const TYPE_REG = /^([a-zA-Z0-9_\d]+\/[a-zA-Z0-9_\d]+)\/([a-zA-Z0-9_\d]+)$/;
|
||||
function isValidType(v: string): boolean {
|
||||
return TYPE_REG.test(v);
|
||||
}
|
||||
if (!isValidType(v)) {
|
||||
throw new Error(`Invalid type string: "${v}"`);
|
||||
}
|
||||
|
||||
const [, version, name] = v.match(TYPE_REG)!;
|
||||
return {
|
||||
version,
|
||||
name,
|
||||
};
|
||||
}
|
||||
|
16
packages/runtime/src/utils/parseType.ts
Normal file
16
packages/runtime/src/utils/parseType.ts
Normal file
@ -0,0 +1,16 @@
|
||||
// parse component Type
|
||||
export function parseType(v: string) {
|
||||
const TYPE_REG = /^([a-zA-Z0-9_\d]+\/[a-zA-Z0-9_\d]+)\/([a-zA-Z0-9_\d]+)$/;
|
||||
function isValidType(v: string): boolean {
|
||||
return TYPE_REG.test(v);
|
||||
}
|
||||
if (!isValidType(v)) {
|
||||
throw new Error(`Invalid type string: "${v}"`);
|
||||
}
|
||||
|
||||
const [, version, name] = v.match(TYPE_REG)!;
|
||||
return {
|
||||
version,
|
||||
name,
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user