尧图网站建设 尧图网络
  • 首页
  • 关于我们
  • 服务项目
  • 案例展示
  • 建站流程
  • 资讯中心
  • 联系我们
首页/资讯中心/详情

大屏开发

大屏开发
📅 发布时间:2026/6/18 19:25:55

项目

image

  src / utils / useDraw.ts

import { ref } from 'vue'export default function useDraw() {// * 指向最外层容器const appRef = ref()// * 定时函数const timer = ref(0)// * 默认缩放值const scale = {width: '1',height: '1',}// * 设计稿尺寸(px)const baseWidth = 1920const baseHeight = 1080// * 需保持的比例(默认1.77778)const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5))const calcRate = () => {// 当前宽高比const currentRate = parseFloat((window.innerWidth / window.innerHeight).toFixed(5))if (appRef.value) {if (currentRate > baseProportion) {// 表示更宽scale.width = ((window.innerHeight * baseProportion) / baseWidth).toFixed(5)scale.height = (window.innerHeight / baseHeight).toFixed(5)appRef.value.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`} else {// 表示更高scale.height = ((window.innerWidth / baseProportion) / baseHeight).toFixed(5)scale.width = (window.innerWidth / baseWidth).toFixed(5)appRef.value.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)`}}}const resize = () => {clearTimeout(timer.value)timer.value = setTimeout(() => {calcRate()}, 200)}// 改变窗口大小重新绘制const windowDraw = () => {window.addEventListener('resize', resize)}// 改变窗口大小重新绘制const unWindowDraw = () => {window.removeEventListener('resize', resize)}return {appRef,calcRate,windowDraw,unWindowDraw}
}

页面使用src/views/index/index.vue

<template><div id="index" ref="appRef"><div class="bg"><dv-loading v-if="loading">Loading...</dv-loading><div v-else class="host-body"><div class="d-flex jc-center"><dv-decoration-10 class="dv-dec-10" /><div class="d-flex jc-center"><dv-decoration-8 class="dv-dec-8" :color="['#568aea', '#000000']" /><div class="title"><span class="title-text">{{ title }}</span><dv-decoration-6class="dv-dec-6":reverse="true":color="['#50e3c2', '#67a1e5']"/></div><dv-decoration-8class="dv-dec-8":reverse="true":color="['#568aea', '#000000']"/></div><dv-decoration-10 class="dv-dec-10-s" /></div><!-- 第二行 --><div class="d-flex jc-between px-2"><div class="d-flex aside-width"><div class="react-left ml-4 react-l-s"><span class="react-before"></span><span class="text">{{ subtitle[0] }}</span></div><div class="react-left ml-3"><span class="text">{{ subtitle[1] }}</span></div></div><div class="d-flex aside-width"><div class="react-right bg-color-blue mr-3"><span class="text fw-b">{{ subtitle[2] }}</span></div><div class="react-right mr-4 react-l-s"><span class="react-after"></span><span class="text">{{ timeInfo.dateYear }} {{ timeInfo.dateWeek }}{{ timeInfo.dateDay }}</span></div></div></div><div class="body-box"><!-- 第三行数据 --><div class="content-box"><div><dv-border-box-12><center-left1 /></dv-border-box-12></div><div><dv-border-box-12><center-left2 /></dv-border-box-12></div><!-- 中间 --><div><center /></div><!-- 中间 --><div><center-right1 /></div><div><dv-border-box-13><center-right2 /></dv-border-box-13></div></div><!-- 第四行数据 --><div class="bototm-box"><dv-border-box-13><bottom-left /></dv-border-box-13><dv-border-box-12><bottom-right /></dv-border-box-12></div></div></div></div></div>
</template><script lang="ts">
import {defineComponent,ref,reactive,onMounted,onBeforeUnmount,
} from 'vue'
import { formatTime } from '@/utils/index'
import { WEEK } from '@/constant/index'
import useDraw from '@/utils/useDraw'
import { title, subtitle, moduleInfo } from '@/constant/index'
import CenterLeft1 from '../centerLeft1/index.vue'
import CenterLeft2 from '../centerLeft2/index.vue'
import Center from '../center/index.vue'
import CenterRight1 from '../centerRight1/index.vue'
import CenterRight2 from '../centerRight2/index.vue'
import BottomLeft from '../bottomLeft/index.vue'
import BottomRight from '../bottomRight/index.vue'export default defineComponent({components: {CenterLeft1,CenterLeft2,Center,CenterRight1,CenterRight2,BottomLeft,BottomRight},setup() {// * 加载标识
    const loading = ref<boolean>(true)// * 时间内容
    const timeInfo = reactive({setInterval: 0,dateDay: '',dateYear: '',dateWeek: ''})// * 适配处理
    const { appRef, calcRate, windowDraw, unWindowDraw } = useDraw()// 生命周期
    onMounted(() => {cancelLoading()handleTime()// todo 屏幕适应
      windowDraw()calcRate()})onBeforeUnmount(() => {unWindowDraw()clearInterval(timeInfo.setInterval)})// methods// todo 处理 loading 展示
    const cancelLoading = () => {setTimeout(() => {loading.value = false}, 500)}// todo 处理时间监听
    const handleTime = () => {timeInfo.setInterval = setInterval(() => {const date = new Date()timeInfo.dateDay = formatTime(date, 'HH: mm: ss')timeInfo.dateYear = formatTime(date, 'yyyy-MM-dd')timeInfo.dateWeek = WEEK[date.getDay()]}, 1000)}// returnreturn {loading,timeInfo,appRef,title,subtitle,moduleInfo}}
})
</script><style lang="scss" scoped>
@import '@/assets/scss/index.scss';
</style>

 

相关新闻

  • [node] Linux 环境安装 nvm 并通过 nvm 控制 node 版本
  • Gitee崛起:中国开发者为何纷纷转向本土代码托管平台
  • Vue.js:大屏开发实战

最新新闻

  • 如何在5分钟内掌握半导体设备通信的Python实现方案
  • 2026市面上最好的高速线切割厂家排行榜 - 品牌排行榜
  • 2026黔南防水补漏靠谱服务商盘点:屋面/厨卫/外墙/地下室渗水维修机构详解,适配喀斯特山区多雨雾甄选指南 - 宅安选房屋修缮
  • Waifu2x-Extension-GUI实战指南:从低清到高清的图像视频处理性能提升
  • MCP607x运放:高精度、低功耗、轨到轨的嵌入式传感器信号调理方案
  • 如何利用Mobaxterm中文版打造专业级远程服务器管理环境?

日新闻

  • 5分钟掌握Python进化算法:Geatpy高性能优化工具完全指南
  • Microchip 24AA044 EEPROM选型与应用全指南:从参数解析到实战编程
  • 华为的鸿蒙到底有多牛?为什么称作遥遥领先?

周新闻

  • 3步解锁iOS设备:applera1n激活锁绕过完全指南
  • 39 2026 人工智能证书终极盘点,普通人选 AI 证书可以从这些方向入手
  • Redis 暴露公网有多危险?从端口检查到补救步骤

月新闻

  • 【总结】入门篇:50句话让你记住架构核心概念
  • WeChatMsg技术方案解析:实现Mac微信数据自主管理的完整解决方案
  • WeChatMsg:革新性微信数据备份方案,打造你的专属数字记忆库

关于尧图

  • 公司简介
  • 团队介绍
  • 企业文化
  • 荣誉资质

服务项目

  • 定制开发
  • 电商建站
  • UI 设计
  • 运维服务

快速链接

  • 案例展示
  • 建站流程
  • 常见问题
  • 资讯中心

联系方式

  • 📍北京市朝阳区互联网产业园 A 座 10 层
  • 📞400-888-8888
  • ✉️contact@rkmt.cn
  • 🕐周一至周日 9:00-21:00

© 2024 北京尧图网络科技有限公司 版权所有 | 京 ICP 备 XXXXXXXX 号