diff --git a/apps/web-antd/src/components/form-create/components/area-select.vue b/apps/web-antd/src/components/form-create/components/area-select.vue
index dd6203cac..9a025ed3e 100644
--- a/apps/web-antd/src/components/form-create/components/area-select.vue
+++ b/apps/web-antd/src/components/form-create/components/area-select.vue
@@ -2,18 +2,17 @@
@@ -104,4 +92,3 @@ function isValidUrl(url: string): boolean {
background-color: #fafafa;
}
-
diff --git a/apps/web-antd/src/components/form-create/rules/use-area-select-rule.ts b/apps/web-antd/src/components/form-create/rules/use-area-select-rule.ts
index 64aeeab4d..f42e08207 100644
--- a/apps/web-antd/src/components/form-create/rules/use-area-select-rule.ts
+++ b/apps/web-antd/src/components/form-create/rules/use-area-select-rule.ts
@@ -1,9 +1,8 @@
-import { cloneDeep } from '@vben/utils';
-
import {
localeProps,
makeRequiredRule,
} from '#/components/form-create/helpers';
+import { AreaLevelEnum } from '@vben/constants';
/** 省市区选择器规则 */
export function useAreaSelectRule() {
@@ -31,11 +30,11 @@ export function useAreaSelectRule() {
type: 'select',
field: 'level',
title: '选择层级',
- value: 3,
+ value: AreaLevelEnum.DISTRICT,
options: [
- { label: '省', value: 1 },
- { label: '省/市', value: 2 },
- { label: '省/市/区', value: 3 },
+ { label: '省', value: AreaLevelEnum.PROVINCE },
+ { label: '省/市', value: AreaLevelEnum.CITY },
+ { label: '省/市/区', value: AreaLevelEnum.DISTRICT },
],
info: '限制可选择的地区层级',
},
diff --git a/apps/web-antd/src/utils/index.ts b/apps/web-antd/src/utils/index.ts
index 5877010a3..287c2c738 100644
--- a/apps/web-antd/src/utils/index.ts
+++ b/apps/web-antd/src/utils/index.ts
@@ -27,3 +27,16 @@ export const findIndex = >(
});
return index;
};
+
+/**
+ * URL 验证
+ * @param path URL 路径
+ */
+export const isUrl = (path: string): boolean => {
+ // fix:修复hash路由无法跳转的问题
+ /* eslint-disable regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-useless-quantifier */
+ const reg =
+ /(((^https?:(?:\/\/)?)(?:[-:&=+$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%#/.\w-]*)?\??[-+=&%@.\w]*(?:#\w*)?)?)$/;
+ return reg.test(path);
+ /* eslint-enable regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-useless-quantifier */
+};
diff --git a/apps/web-ele/src/components/form-create/components/area-select.vue b/apps/web-ele/src/components/form-create/components/area-select.vue
index 1687fe145..cd7345261 100644
--- a/apps/web-ele/src/components/form-create/components/area-select.vue
+++ b/apps/web-ele/src/components/form-create/components/area-select.vue
@@ -2,17 +2,16 @@
diff --git a/apps/web-ele/src/components/form-create/rules/use-area-select-rule.ts b/apps/web-ele/src/components/form-create/rules/use-area-select-rule.ts
index 1db16dcb7..922e894e0 100644
--- a/apps/web-ele/src/components/form-create/rules/use-area-select-rule.ts
+++ b/apps/web-ele/src/components/form-create/rules/use-area-select-rule.ts
@@ -1,9 +1,8 @@
-import { cloneDeep } from '@vben/utils';
-
import {
localeProps,
makeRequiredRule,
} from '#/components/form-create/helpers';
+import { AreaLevelEnum } from '@vben/constants';
/** 省市区选择器规则 */
export function useAreaSelectRule() {
@@ -31,11 +30,11 @@ export function useAreaSelectRule() {
type: 'select',
field: 'level',
title: '选择层级',
- value: 3,
+ value: AreaLevelEnum.DISTRICT,
options: [
- { label: '省', value: 1 },
- { label: '省/市', value: 2 },
- { label: '省/市/区', value: 3 },
+ { label: '省', value: AreaLevelEnum.PROVINCE },
+ { label: '省/市', value: AreaLevelEnum.CITY },
+ { label: '省/市/区', value: AreaLevelEnum.DISTRICT },
],
info: '限制可选择的地区层级',
},
diff --git a/apps/web-ele/src/utils/index.ts b/apps/web-ele/src/utils/index.ts
index e64084b6c..fc9d735de 100644
--- a/apps/web-ele/src/utils/index.ts
+++ b/apps/web-ele/src/utils/index.ts
@@ -28,3 +28,16 @@ export const findIndex = >(
});
return index;
};
+
+/**
+ * URL 验证
+ * @param path URL 路径
+ */
+export const isUrl = (path: string): boolean => {
+ // fix:修复hash路由无法跳转的问题
+ /* eslint-disable regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-useless-quantifier */
+ const reg =
+ /(((^https?:(?:\/\/)?)(?:[-:&=+$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%#/.\w-]*)?\??[-+=&%@.\w]*(?:#\w*)?)?)$/;
+ return reg.test(path);
+ /* eslint-enable regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-useless-quantifier */
+};
diff --git a/packages/constants/src/biz-system-enum.ts b/packages/constants/src/biz-system-enum.ts
index f60b61fc2..93fb207b7 100644
--- a/packages/constants/src/biz-system-enum.ts
+++ b/packages/constants/src/biz-system-enum.ts
@@ -57,3 +57,12 @@ export const SystemUserSocialTypeEnum = {
img: 'https://s1.ax1x.com/2022/05/22/OzMrzn.png',
},
};
+
+/**
+ * 地区选择器层级枚举
+ */
+export const AreaLevelEnum = {
+ PROVINCE: 1, // 省
+ CITY: 2, // 市
+ DISTRICT: 3, // 区
+} as const;