gaoluyang
2026-06-24 bfdc0e0e6d5e47aa501f9b6fadd143d9c97cf00a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script lang="ts" setup>
import { ref, watch } from 'vue';
 
import { Button, Input } from 'ant-design-vue';
 
import AppLinkSelectDialog from './select-dialog.vue';
 
/** APP 链接输入框 */
defineOptions({ name: 'AppLinkInput' });
 
/** 定义属性 */
const props = defineProps({
  modelValue: {
    type: String,
    default: '',
  }, // 当前选中的链接
});
 
const emit = defineEmits<{
  'update:modelValue': [link: string];
}>();
 
const dialogRef = ref(); // 选择对话框
 
const appLink = ref(''); // 当前的链接
 
/** 处理打开对话框 */
function handleOpenDialog() {
  return dialogRef.value?.open(appLink.value);
}
 
/** 处理 APP 链接选中 */
function handleLinkSelected(link: string) {
  appLink.value = link;
}
 
watch(
  () => props.modelValue,
  () => (appLink.value = props.modelValue),
  { immediate: true },
);
 
watch(
  () => appLink.value,
  () => emit('update:modelValue', appLink.value),
);
</script>
<template>
  <Input v-model:value="appLink" placeholder="输入或选择链接">
    <template #addonAfter>
      <Button
        @click="handleOpenDialog"
        class="!border-none !bg-transparent !p-0"
      >
        选择
      </Button>
    </template>
  </Input>
 
  <AppLinkSelectDialog ref="dialogRef" @change="handleLinkSelected" />
</template>