' + '' + '
Baidu
map
'; var blob = new Blob([html], { type: 'text/html;charset=utf-8' }); var blobUrl = URL.createObjectURL(blob); var opened = window.open(blobUrl, '_blank', 'noopener,noreferrer'); if (!opened) { URL.revokeObjectURL(blobUrl); window.open(url, '_blank', 'noopener,noreferrer'); return; } setTimeout(function() { URL.revokeObjectURL(blobUrl); }, 120000); }, buildAttachmentFilename: function(link, hrefForPath) { var pathOnly = (hrefForPath || '').split(/[?#]/)[0]; var ext = this.getExtensionFromPath(pathOnly.toLowerCase()); var rawDl = (link.getAttribute('download') || '').trim(); if (rawDl && rawDl !== 'true') { return this.sanitizeAttachmentFileName(rawDl); } var candidates = [ (link.getAttribute('title') || '').trim(), this.normalizeAttachmentLinkText(link.textContent || '') ]; for (var i = 0; i < candidates.length; i++) { var c = candidates[i]; if (!c) continue; var base = this.sanitizeAttachmentFileName(this.stripKnownAttachmentExtension(c)); if (!base) continue; if (ext && base.toLowerCase().lastIndexOf(ext) !== base.length - ext.length) { return base + ext; } return base; } var segs = pathOnly.split('/'); return this.sanitizeAttachmentFileName(segs[segs.length - 1] || ('file' + ext)); }, loadArticleDetail: function(id) { var self = this; self.dynamicLoading = true; var url = '/ms/cms/content/get.do?id=' + encodeURIComponent(id); if (self.categoryId) { url += '&categoryId=' + encodeURIComponent(self.categoryId); } http.get(url) .then(function(res) { if (res && res.result && res.data) { self.articleDetail = res.data; if (res.data.contentTitle) { document.title = res.data.contentTitle; } self.articleCategoryId = String( res.data.categoryId || res.data.typeid || res.data.typeId || res.data.columnId || res.data.columnTypeId || self.categoryId || '' ); var contentId = res.data.id || id; var script = document.createElement('script'); script.src = '/cms/content/' + contentId + '/hit.do'; document.body.appendChild(script); self.loadOrganUidByContentId(contentId); self.$nextTick(function() { self.processArticleContent(); }); } else { self.$message.error(res.msg || '文章加载失败'); } self.dynamicLoading = false; }) .catch(function(err) { self.$message.error('文章加载失败'); self.dynamicLoading = false; }); }, fixArticleContentOverflow: function(contentEl) { if (!contentEl) return; contentEl.style.overflowX = 'hidden'; contentEl.style.maxWidth = '100%'; contentEl.querySelectorAll('.article-contact-grid').forEach(function(grid) { grid.style.width = '100%'; grid.style.maxWidth = '100%'; grid.style.gridTemplateColumns = '4em auto minmax(0, 1fr)'; grid.style.boxSizing = 'border-box'; }); contentEl.querySelectorAll('.article-contact-value').forEach(function(el) { el.style.whiteSpace = 'normal'; el.style.wordBreak = 'break-word'; el.style.overflowWrap = 'anywhere'; el.style.minWidth = '0'; el.style.maxWidth = '100%'; }); contentEl.querySelectorAll('table').forEach(function(table) { table.style.tableLayout = 'fixed'; table.style.width = '100%'; table.style.maxWidth = '100%'; table.style.overflowX = 'hidden'; }); contentEl.querySelectorAll('[style*="nowrap"]').forEach(function(el) { el.style.whiteSpace = 'normal'; el.style.wordBreak = 'break-word'; el.style.overflowWrap = 'anywhere'; el.style.maxWidth = '100%'; }); }, /** 正文首行若为「各有关单位 / 各相关单位 / 各…单位」称呼,仅去掉该段首行缩进 */ clearSalutationFirstIndent: function(contentEl) { if (!contentEl) return; var salutationRe = /^各[\u4e00-\u9fa5()()、,,\s]{0,40}单位/; var skipTags = { SCRIPT: 1, STYLE: 1, TABLE: 1, FIGURE: 1, IMG: 1 }; function normalizeText(el) { return (el.innerText || el.textContent || '') .replace(/^[\u00A0\u3000\s\u200B\uFEFF]+/, '') .replace(/\s+/g, ''); } // 按文档顺序找第一个有字的块级节点;若外层包了整篇正文,再向下找第一段 function findSalutationEl(root) { var nodes = root.querySelectorAll('p, div, section, h1, h2, h3, h4, h5, h6'); for (var i = 0; i < nodes.length; i++) { var el = nodes[i]; if (skipTags[el.tagName]) continue; // 跳过仍含有子段落的大容器,避免误伤整篇 if (el.querySelector('p, div')) continue; var text = normalizeText(el); if (!text) continue; return salutationRe.test(text) ? el : null; } return null; } var target = findSalutationEl(contentEl); if (!target) return; target.style.setProperty('text-indent', '0', 'important'); target.classList.add('no-first-indent'); }, processArticleContent: function() { var self = this; var contentEl = document.querySelector('.article-content'); if (!contentEl) return; self.fixArticleContentOverflow(contentEl); self.clearSalutationFirstIndent(contentEl); var icons = contentEl.querySelectorAll('img[src*="ttbz.org.cn"]'); icons.forEach(function(img) { img.style.display = 'none'; }); var fileIcons = contentEl.querySelectorAll('img[src*="/upload/image/"]'); fileIcons.forEach(function(img) { var alt = (img.getAttribute('alt') || '').toLowerCase(); var title = (img.getAttribute('title') || '').toLowerCase(); if (alt.indexOf('icon_') === 0 || title.indexOf('icon_') === 0) { img.remove(); } }); var fileLinks = contentEl.querySelectorAll('a[href*="/upload/"]'); fileLinks.forEach(function(link) { var extReg = /\.(pdf|doc|docx|xls|xlsx|ppt|pptx|zip|rar|txt|csv)$/i; var hrefForType = (link.getAttribute('href') || '').split('?')[0].toLowerCase(); var isPdfPreview = hrefForType.endsWith('.pdf'); var isImgPreview = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(hrefForType); var niceFileName = self.buildAttachmentFilename(link, link.href); link.setAttribute('data-ttbz-dl-name', niceFileName); if (isPdfPreview || isImgPreview) { link.removeAttribute('download'); link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); } else { link.setAttribute('download', niceFileName); } link.style.fontSize = 'inherit'; var parentP = link.closest('p') || link.parentElement; if (parentP) { parentP.classList.add('attachment-item'); parentP.style.fontSize = 'inherit'; parentP.style.lineHeight = '1.8'; parentP.style.textIndent = '0'; parentP.style.paddingLeft = '2em'; parentP.style.boxSizing = 'border-box'; parentP.querySelectorAll('img').forEach(function(img) { img.style.float = 'none'; img.style.verticalAlign = 'middle'; }); } if (link.getAttribute('title')) { link.setAttribute('title', link.getAttribute('title').replace(extReg, '')); } var spans = link.querySelectorAll('span'); if (spans.length > 0) { spans.forEach(function(span) { span.style.fontSize = 'inherit'; span.textContent = span.textContent.replace(extReg, ''); }); } else { link.childNodes.forEach(function(node) { if (node.nodeType === 3) { node.textContent = node.textContent.replace(extReg, ''); } }); } }); if (!contentEl.__ttbzArticleClickBound) { contentEl.__ttbzArticleClickBound = true; contentEl.addEventListener('click', function(e) { var link = e.target.closest('a[href]'); if (!link || !contentEl.contains(link)) return; var raw = link.getAttribute('href') || ''; if (!raw || /^javascript:/i.test(raw)) return; var pathOnly = raw.split('?')[0].toLowerCase(); var isPdf = pathOnly.endsWith('.pdf'); var isImage = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(pathOnly); var niceName = link.getAttribute('data-ttbz-dl-name') || ''; if (isPdf) { e.preventDefault(); self.openPdfInBrowser(link.href, niceName || 'PDF'); return; } if (isImage) { e.preventDefault(); fetch(link.href, { credentials: 'same-origin' }) .then(function(r) { return r.blob(); }) .then(function(blob) { var u = URL.createObjectURL(blob); var w = window.open(u, '_blank', 'noopener,noreferrer'); if (w && niceName) { try { w.document.title = niceName; } catch (err) { /* ignore */ } } setTimeout(function() { URL.revokeObjectURL(u); }, 120000); }) .catch(function() { window.open(link.href, '_blank', 'noopener,noreferrer'); }); return; } if (link.hasAttribute('download')) { e.preventDefault(); var a = document.createElement('a'); a.href = link.href; a.download = niceName || link.getAttribute('download') || ''; document.body.appendChild(a); a.click(); document.body.removeChild(a); } }); } }, } });
Baidu
map