ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts" setup>
import { useGo } from '@jnpf/hooks';
import { encryptByBase64 } from '@jnpf/utils';
 
import { linkProps } from './props';
 
defineOptions({ inheritAttrs: false, name: 'JnpfLink' });
const props = defineProps(linkProps);
const emit = defineEmits(['click']);
const go = useGo();
 
function onClick(e) {
  emit('click', e);
  if (!props.href) return;
  if (props.target === '_self') {
    go(`/externalLink?href=${encryptByBase64(props.href)}`);
  } else if (props.target === '_blank') {
    window.open(props.href, props.target);
  }
}
</script>
 
<template>
  <p :style="textStyle" class="jnpf-link">
    <span class="jnpf-link--inner" @click="onClick">{{ content }}</span>
  </p>
</template>
<style lang="scss" scoped>
.jnpf-link {
  margin: 0;
  font-size: 14px;
  line-height: 32px;
  color: var(--primary-color);
 
  & &--inner {
    word-break: break-all;
    cursor: pointer;
  }
}
</style>