Files
MES_Manage_View_V20/static/pdf-compatibility.js
MESWORK 885e70b9fc init: MES_Manage_View_V20 v1.1.0 项目初始化
- Vue 2.7 + Element UI + Webpack 5 前端
- SQL Server 数据库脚本 (script.sql)
- 4份技术文档 (技术分析/功能映射/使用说明书/用户操作手册)
- 存储过程修复 (fix_生产管理_外协报表_查询.sql)
2026-05-21 09:31:44 +08:00

66 lines
2.1 KiB
JavaScript

// pdf-compatibility.js
(function() {
'use strict';
// 修复 url.parse
if (typeof window.URL === 'undefined' || typeof window.URL.parse !== 'function') {
window.URL = window.URL || {};
window.URL.parse = function(url) {
try {
// 使用 DOM 方式解析 URL
const a = document.createElement('a');
a.href = url;
return {
protocol: a.protocol,
hostname: a.hostname,
port: a.port,
pathname: a.pathname,
search: a.search,
hash: a.hash,
host: a.host,
href: a.href,
origin: a.origin
};
} catch (e) {
// 简单的字符串解析
const match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/);
return {
protocol: match[2] || '',
hostname: match[4] || '',
pathname: match[5] || '',
search: match[6] || '',
hash: match[8] || '',
href: url
};
}
};
}
// 修复 Promise.withResolvers
if (typeof Promise.withResolvers !== 'function') {
Promise.withResolvers = function() {
var resolve, reject;
var promise = new Promise(function(res, rej) {
resolve = res;
reject = rej;
});
return { promise: promise, resolve: resolve, reject: reject };
};
}
// 修复 Object.values
if (typeof Object.values !== 'function') {
Object.values = function(obj) {
var values = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
values.push(obj[key]);
}
}
return values;
};
}
console.log('PDF 兼容性修复已加载');
})();