hookehuyr

fix: 修复标题空值报错,更新代理配置并补充ElMessage配置

补充ElMessage的ESLint全局声明与自动导入类型定义,解决编辑器无提示和lint校验错误
更新.env文件中的代理目标地址为https://juelin.onwall.cn/
为页面标题赋值添加空值保护,避免因undefined导致的异常
重构info.vue的详情处理逻辑,统一页面标题设置流程
......@@ -2,9 +2,10 @@
VITE_PORT = 8006
# 反向代理服务器地址
VITE_PROXY_TARGET = https://oa-dev.onwall.cn
# VITE_PROXY_TARGET = https://oa-dev.onwall.cn
# VITE_PROXY_TARGET = https://bm.jiqun.com
# VITE_PROXY_TARGET = https://oa.onwall.cn
VITE_PROXY_TARGET = https://juelin.onwall.cn/
# API请求前缀
VITE_PROXY_PREFIX = /srv/
......
{
"globals": {
"EffectScope": true,
"ElMessage": true,
"computed": true,
"createApp": true,
"customRef": true,
......
......@@ -2,6 +2,7 @@
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const ElMessage: typeof import('element-plus/es')['ElMessage']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
......
......@@ -116,11 +116,23 @@ const props = defineProps({
const page_details = ref({});
const syncDocumentTitle = () => {
if (page_details.value?.name) {
document.title = page_details.value.name;
}
}
const applyPageDetails = (details, extra = {}) => {
if (!details) return;
page_details.value = { ...details, ...extra };
syncDocumentTitle();
}
watch(
() => props.info,
(v) => {
if (v.details.length) {
page_details.value = { ...v.details[0], position: v.position, path: v.path };
if (v?.details?.length) {
applyPageDetails(v.details[0], { position: v.position, path: v.path });
// 获取浏览器可视范围的高度
$('.info-page').height(props.height + 'px');
}
......@@ -191,14 +203,17 @@ const scrollTop = ref(0);
onMounted(async () => {
// 通过ID查询到标记点详情
if (!props.info) {
if (!props.info?.details?.length) {
let id = $route.query.id;
const { data } = await mapAPI({ i: id });
const raw_list = data.list[0].list; // 获取标记点列表
const marker_id = $route.query.marker_id;
const current_marker = raw_list.filter(item => item.id == marker_id)[0];
//
page_details.value = { ...current_marker.details[0], position: current_marker.position, path: current_marker.path };
applyPageDetails(current_marker.details[0], {
position: current_marker.position,
path: current_marker.path
});
// 富文本转义, 分割线样式转换
page_details.value.introduction = page_details.value.introduction?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>')
page_details.value.story = page_details.value.story?.replace(/\<hr\>/g, '<div class="van-hairline--bottom" style="margin: 1rem 0;"></div>')
......@@ -253,7 +268,7 @@ onMounted(async () => {
}, 500);
}
// 地图标题
document.title = page_details.value.name;
syncDocumentTitle();
// 微信分享
const shareData = {
title: page_details.value.name, // 分享标题
......
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-08-08 14:51:23
* @LastEditTime: 2026-05-27 17:24:49
* @FilePath: /map-demo/src/views/by/map.vue
* @Description: 公众地图主体页面
-->
......@@ -325,10 +325,10 @@ export default {
}
}
// 地图标题
document.title = data.map.map_title;
document.title = data.map.map_title ?? '';
// 微信分享
const shareData = {
title: data.map.map_title, // 分享标题
title: data.map.map_title ?? '', // 分享标题
desc: '别院地图', // 分享描述
link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
imgUrl: '', // 分享图标
......@@ -360,7 +360,7 @@ export default {
// 设置贴片地图
this.setTitleLayer();
// 地图标题
document.title = data.map.map_title;
document.title = data.map.map_title ?? '';
//
// setTimeout(() => {
// this.info_height = (0.5 * window.innerHeight);
......