feat: 系统消息如果是一个链接则直接跳转
This commit is contained in:
@@ -32,6 +32,7 @@ import { Https } from "@/tool/https";
|
|||||||
import { useRouter,useRoute } from 'vue-router'
|
import { useRouter,useRoute } from 'vue-router'
|
||||||
import { useStore } from "vuex";
|
import { useStore } from "vuex";
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { isValidUrl } from '@/tool/util';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components:{
|
components:{
|
||||||
},
|
},
|
||||||
@@ -70,7 +71,13 @@ export default defineComponent({
|
|||||||
accountMessage.isNoData = true
|
accountMessage.isNoData = true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let setRead = (item:any)=>{
|
let setRead = (item: any) => {
|
||||||
|
const content = item.content.content
|
||||||
|
console.log('111', isValidUrl(content));
|
||||||
|
if (isValidUrl(content)) {
|
||||||
|
window.open(content, '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
prop.setReadStatus(item).then((rv:any)=>{
|
prop.setReadStatus(item).then((rv:any)=>{
|
||||||
item.isRead = 1
|
item.isRead = 1
|
||||||
}).catch((err:any)=>{
|
}).catch((err:any)=>{
|
||||||
|
|||||||
@@ -672,6 +672,17 @@ function sketchToMask(sketchImage) {
|
|||||||
img.src = sketchImage;
|
img.src = sketchImage;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidUrl(string) {
|
||||||
|
try {
|
||||||
|
const url = new URL(string)
|
||||||
|
// 通常我们只需要 http 或 https 协议
|
||||||
|
return url.protocol === "http:" || url.protocol === "https:"
|
||||||
|
} catch (err) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
isEmail,
|
isEmail,
|
||||||
getUploadUrl,
|
getUploadUrl,
|
||||||
@@ -695,5 +706,6 @@ export {
|
|||||||
calculateGradientCoordinate,
|
calculateGradientCoordinate,
|
||||||
segmentImage,
|
segmentImage,
|
||||||
UrlToFile,
|
UrlToFile,
|
||||||
sketchToMask
|
sketchToMask,
|
||||||
|
isValidUrl
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user