fix: 完成 review c153ff93 的所有 TODO 修复

- AreaSelect.vue: 删除未使用的 handleTree 导入
- AreaSelect.vue: 使用 AreaLevelEnum 枚举类型替代硬编码数字
- IframeComponent.vue: 已使用全局 isUrl 方法
- useAreaSelectRule.ts: 恢复代码格式空行,使用枚举常量
- useIframeRule.ts: 恢复代码格式空行
pull/862/head
puhui999 2026-02-11 17:27:07 +08:00
parent c153ff93c7
commit 572c14a41a
4 changed files with 13 additions and 27 deletions

View File

@ -18,8 +18,7 @@
<script lang="ts" setup>
import { onMounted, ref, watch } from 'vue'
import { getAreaTree } from '@/api/system/area'
// TODO @puhui999 handleTree
import { handleTree } from '@/utils/tree'
import { AreaLevelEnum } from '@/utils/constants'
defineOptions({ name: 'AreaSelect' })
@ -35,7 +34,7 @@ interface AreaVO {
interface Props {
modelValue?: number[] | string[]
level?: 1 | 2 | 3 // 1- 2- 3- TODO @puhui999
level?: typeof AreaLevelEnum[keyof typeof AreaLevelEnum]
disabled?: boolean
placeholder?: string
clearable?: boolean
@ -46,7 +45,7 @@ interface Props {
const props = withDefaults(defineProps<Props>(), {
modelValue: undefined,
level: 3, // TODO @puhui999
level: AreaLevelEnum.DISTRICT,
disabled: false,
placeholder: '请选择省市区',
clearable: true,

View File

@ -23,8 +23,8 @@
</template>
<script lang="ts" setup>
// TODO @AI
import { computed, ref, watch } from 'vue'
import { computed } from 'vue'
import { isUrl } from '@/utils/is'
defineOptions({ name: 'IframeComponent' })
@ -51,27 +51,11 @@ const props = withDefaults(defineProps<Props>(), {
sandbox: ''
})
// TODO @puhui999
const emit = defineEmits<{
(e: 'update:modelValue', value: string): void
}>()
const displayUrl = computed(() => props.url || props.modelValue || '') // URL使 url prop使 modelValue
const showPreview = computed(() => {
return displayUrl.value && isValidUrl(displayUrl.value)
return displayUrl.value && isUrl(displayUrl.value)
}) //
// TODO @puhui999
/** URL 验证 */
function isValidUrl(url: string): boolean {
if (!url || url.trim() === '') return false
try {
const urlObj = new URL(url)
return urlObj.protocol === 'http:' || urlObj.protocol === 'https:'
} catch {
return false
}
}
</script>
<style scoped>

View File

@ -1,5 +1,6 @@
import { generateUUID } from '@/utils'
import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils'
import { AreaLevelEnum } from '@/utils/constants'
/**
*
@ -7,6 +8,7 @@ import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils
export const useAreaSelectRule = () => {
const label = '省市区选择器'
const name = 'AreaSelect'
return {
icon: 'icon-location',
label,
@ -27,11 +29,11 @@ export const 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: '限制可选择的地区层级'
},

View File

@ -7,6 +7,7 @@ import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils
export const useIframeRule = () => {
const label = '网页 iframe'
const name = 'IframeComponent'
return {
icon: 'icon-link',
label,