feat: 文字组件添加链接功能

This commit is contained in:
wuyuting1 2022-09-21 17:27:50 +08:00
parent ae77a32c87
commit 662c2fd4dd
3 changed files with 13 additions and 10 deletions

View File

@ -15,6 +15,7 @@ export const WritingModeObject = {
export const option = { export const option = {
link:'', link:'',
linkHead:'http://',
dataset: '我是文本', dataset: '我是文本',
fontSize: 20, fontSize: 20,
fontColor: '#ffffff', fontColor: '#ffffff',

View File

@ -7,7 +7,7 @@
</setting-item-box> </setting-item-box>
<setting-item-box name="链接" :alone="true"> <setting-item-box name="链接" :alone="true">
<setting-item> <setting-item>
<n-space><n-input v-model:value="optionData.link" size="small"></n-input><n-button secondary size="small" @click="handleLinkClick" ></n-button></n-space> <n-input-group><n-select v-model:value="optionData.linkHead" size="small" :style="{ width: '33%' }" :options="linkHeadOptions" /><n-input v-model:value="optionData.link" size="small"></n-input><n-button :disabled="!optionData.link" secondary size="small" @click="handleLinkClick" ></n-button></n-input-group>
</setting-item> </setting-item>
</setting-item-box> </setting-item-box>
</collapse-item> </collapse-item>
@ -74,7 +74,6 @@ import {
SettingItemBox, SettingItemBox,
SettingItem SettingItem
} from '@/components/Pages/ChartItemSetting' } from '@/components/Pages/ChartItemSetting'
import { useMessage } from 'naive-ui'
const props = defineProps({ const props = defineProps({
optionData: { optionData: {
type: Object as PropType<typeof option>, type: Object as PropType<typeof option>,
@ -89,13 +88,15 @@ const verticalOptions = [{
label: WritingModeEnum.VERTICAL, label: WritingModeEnum.VERTICAL,
value: WritingModeObject[WritingModeEnum.VERTICAL] value: WritingModeObject[WritingModeEnum.VERTICAL]
}] }]
const message = useMessage()
const handleLinkClick = ()=>{ const handleLinkClick = ()=>{
window.open(props.optionData.linkHead+props.optionData.link)
if(props.optionData.link){
window.open(props.optionData.link)
}else{
message.info("链接未输入")
}
} }
const linkHeadOptions = [{
label: 'http://',
value: 'http://'
},
{
label: 'https://',
value: 'https://'
}]
</script> </script>

View File

@ -38,6 +38,7 @@ const props = defineProps({
const { w, h } = toRefs(props.chartConfig.attr) const { w, h } = toRefs(props.chartConfig.attr)
const { const {
linkHead,
link, link,
dataset, dataset,
fontColor, fontColor,
@ -75,7 +76,7 @@ useChartDataFetch(props.chartConfig, useChartEditStore, (newData: string) => {
// //
const click = () => { const click = () => {
window.open(link.value) window.open(linkHead.value+link.value)
} }
</script> </script>