提交 674e82f2 authored 作者: 汪雄's avatar 汪雄

feat: 大屏适配

上级 8cf145ba
......@@ -8,50 +8,72 @@
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>UE大屏项目</title>
<script>
"object" != typeof ue || "object" != typeof ue.interface ? ("object" != typeof ue && (ue = {}), ue.interface = {},
ue.interface.broadcast = function (e, t) {
if ("string" == typeof e) {
var o = [e, ""];
void 0 !== t && (o[1] = t);
var n = encodeURIComponent(JSON.stringify(o));
"object" == typeof history && "function" == typeof history.pushState ? (history.pushState({},
"", "#" + n), history.pushState({},
"", "#" + encodeURIComponent("[]"))) : (document.location.hash = n, document.location.hash = encodeURIComponent("[]"))
}
}) : function (e) {
ue.interface = {},
ue.interface.broadcast = function (t, o) {
"string" == typeof t && (void 0 !== o ? e.broadcast(t, JSON.stringify(o)) : e.broadcast(t, ""))
}
}(ue.interface),
(window.ue5 = ue.interface.broadcast);
</script>
<!-- <script>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link
rel="stylesheet"
href="https://unpkg.com/element-plus/dist/index.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>UE大屏项目</title>
<script>
("object" != typeof ue || "object" != typeof ue.interface
? ("object" != typeof ue && (ue = {}),
(ue.interface = {}),
(ue.interface.broadcast = function (e, t) {
if ("string" == typeof e) {
var o = [e, ""];
void 0 !== t && (o[1] = t);
var n = encodeURIComponent(JSON.stringify(o));
"object" == typeof history &&
"function" == typeof history.pushState
? (history.pushState({}, "", "#" + n),
history.pushState({}, "", "#" + encodeURIComponent("[]")))
: ((document.location.hash = n),
(document.location.hash = encodeURIComponent("[]")));
}
}))
: (function (e) {
((ue.interface = {}),
(ue.interface.broadcast = function (t, o) {
"string" == typeof t &&
(void 0 !== o
? e.broadcast(t, JSON.stringify(o))
: e.broadcast(t, ""));
}));
})(ue.interface),
(window.ue5 = ue.interface.broadcast));
</script>
<!-- <script>
ue.interface.receiveLoginInfo = function (data) {
window.receiveLoginInfo(data);
};
</script> -->
</head>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<style>
body,
#app {
/* background-color: transparent !important; */
}
</style>
<script>
function setRem() {
const baseSize = 16; // 基准
const designWidth = 1920; // 设计稿宽度(你项目很可能是1920大屏)
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<style>
body,
#app {
background-color: transparent !important;
}
</style>
const scale = document.documentElement.clientWidth / designWidth;
document.documentElement.style.fontSize = baseSize * scale + "px";
document.documentElement.style.setProperty("--scale", scale);
window._myscale = scale
}
</html>
\ No newline at end of file
setRem();
window.addEventListener("resize", setRem);
</script>
</html>
......@@ -20,6 +20,7 @@
"jsencrypt": "3.3.2",
"nprogress": "0.2.0",
"pinia": "2.1.7",
"postcss-pxtorem": "^6.1.0",
"qs": "^6.13.1",
"vue": "^3.5.13",
"vue-element-plus-x": "^1.3.98",
......@@ -7261,6 +7262,14 @@
"postcss": ">4 <9"
}
},
"node_modules/postcss-pxtorem": {
"version": "6.1.0",
"resolved": "https://registry.npmmirror.com/postcss-pxtorem/-/postcss-pxtorem-6.1.0.tgz",
"integrity": "sha512-ROODSNci9ADal3zUcPHOF/K83TiCgNSPXQFSbwyPHNV8ioHIE4SaC+FPOufd8jsr5jV2uIz29v1Uqy1c4ov42g==",
"peerDependencies": {
"postcss": "^8.0.0"
}
},
"node_modules/posthtml": {
"version": "0.9.2",
"resolved": "https://registry.npmmirror.com/posthtml/-/posthtml-0.9.2.tgz",
......
......@@ -34,6 +34,7 @@
"jsencrypt": "3.3.2",
"nprogress": "0.2.0",
"pinia": "2.1.7",
"postcss-pxtorem": "^6.1.0",
"qs": "^6.13.1",
"vue": "^3.5.13",
"vue-element-plus-x": "^1.3.98",
......
差异被折叠。
//pxtorem
// export function px2rem2px(val, base = 16) {
// if (typeof val === 'number') return (val / base) * window._myscale
// // + 'rem'
// if (typeof val === 'string' && val.includes('px')) {
// return parseFloat(val) / base * window._myscale
// }
// return val
// }
export function pxScale(val) {
let log = val;
if (typeof val === "number") {
log = val * window._myscale;
}
if (typeof val === "string" && val.includes("px")) {
log = parseFloat(val) * window._myscale;
}
console.log("log 数据", log);
return log;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论