当前位置: 首页 > news >正文

个人网站开发意义利尔化学股票最新消息

个人网站开发意义,利尔化学股票最新消息,网站顶部小图标怎么做,石家庄做网站的公司有哪些项目环境搭建 使用create-vue初始化项目 npm init vuelatest准备utils模块 业务背景:大屏项目属于后台项目的一个子项目,用户的token是共享的 后台项目 - token - cookie 大屏项目要以同样的方式把token获取到,然后拼接到axios的请求头中…

项目环境搭建

使用create-vue初始化项目

npm init vue@latest

准备utils模块

业务背景:大屏项目属于后台项目的一个子项目,用户的token是共享的

后台项目 - token - cookie

大屏项目要以同样的方式把token获取到,然后拼接到axios的请求头中

1. 封装cookies存取模块

npm i js-cookie

utils/cookie.js

import Cookies from 'js-cookie'const KEY = 'token_key'export function getCookie () {return Cookies.get(KEY)
}export function setCookie (value) {Cookies.set(KEY, value)
}export function removeCookie () {Cookies.remove(KEY)
}

2. 封装request请求模块

npm i axios

utils/request.js

import axios from 'axios'
import { getCookie } from './cookie'
const service = axios.create({baseURL: 'https://api-hmzs.itheima.net/v1',timeout: 5000 // request timeout
})// 请求拦截器
service.interceptors.request.use(config => {const token = getCookie()if (token) {config.headers.Authorization = token}return config},error => {return Promise.reject(error)}
)// 响应拦截器
service.interceptors.response.use(response => {return response.data},error => {return Promise.reject(error)}
)export default service

路由搭建

1- 创建路由组件

<script setup></script><template><div>我是大屏显示组件</div>
</template>

2- 绑定路由

// createRouter: 创建路由实例对象
// createWebHistory: 创建history模式的路由(hash / history)import { createRouter, createWebHistory } from 'vue-router'// 导入路由级别的组件
import HomeView from '../views/HomeView.vue'
import BigScreenView from '../views/BigScreenView.vue'const router = createRouter({// 类似于mode:history 指定路由为history模式history: createWebHistory(import.meta.env.BASE_URL),// 配置路由path和component对应关系routes: [{path: '/',redirect: '/big-screen',name: 'home',component: HomeView,},{path: '/big-screen',name: 'big-screen',component: BigScreenView}]
})export default router

初始化样式

1.备初始化文件

styles/common.scss

html,
body,
#app {height: 100vh;overflow: hidden;
}* {margin: 0;padding: 0;box-sizing: border-box;
}

2. 安装sass

create-vue创建的项目默认不支持scss语法,需要我们手动安装sass

npm i sass

2D可视化

cookie共享问题

  1. 前提 cookie / ls / session 本身会有跨域问题 不同域下的cookie信息是不共享的
  2. 在主域名一致的情况下,可以让cookie信息实现共享
  3. 把后台项目启动起来登录一下,把token存入本地

1. 准备静态模版

2. 封装接口并请求数据

3. 渲染图表

1- 安装echarts

npm install echarts

2- 封装初始化方法并在mounted中执行

三步走()

import * as echarts from 'echarts'
// 渲染年度收入分析图表
const initBarChart = () => {// 1. 解构图表数据const { parkIncome } = parkInfo.value// 2. 准备options数据const barOptions = {tooltip: {trigger: 'axis',axisPointer: {type: 'shadow',},},grid: {// 让图表占满容器top: '10px',left: '0px',right: '0px',bottom: '0px',containLabel: true,},xAxis: [{type: 'category',axisTick: {alignWithLabel: true,show: false,},data: parkIncome.xMonth,},],yAxis: [{type: 'value',splitLine: {show: false,},},],series: [{name: '园区年度收入',type: 'bar',barWidth: '10px',data: parkIncome.yIncome.map((item, index) => {const color =index % 2 === 0? new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0.23, color: '#74c0f8' },{ offset: 1, color: 'rgba(116,192,248,0.00)' },]): new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0.23, color: '#ff7152' },{ offset: 1, color: 'rgba(255,113,82,0.00)' },])return { value: item, itemStyle: { color } }}),},],textStyle: {color: '#B4C0CC',},}// 3. 渲染图表const myBarChart = echarts.init(barChart.value)myBarChart.setOption(barOptions)
}

拆分优化对比

  1. 基于组件拆分

    1. 解决什么问题:复用 + 增加可维护性
    2. 拆分的是什么:.vue = HTML + JS + CSS
    3. 带来问题:一旦组件从一个变成了多个 必定形成嵌套关系 增加通信成本
  2. 基于逻辑拆分

    1. 解决什么问题:复用(逻辑) + 增加可维护性
    2. 拆分的是什么: 拆分的只有js
    3. 带来的问题:对原生js函数的理解要求高了
  3. 基于逻辑的通用拆分思想

    1. 找到组件中属于同一个业务逻辑的所有代码(响应式数据 + 修改数据的方法)
    2. 定义一个以 use 打头的方法,把第一步所有的业务逻辑代码都放入
    3. 在use函数内部,把组件中要用到的数据或者方法以对象的方式导出
    4. 在组件的setup语法糖中,通过调用函数配合解构赋值把函数内部的数据和方法在组件中可用

3D可视化

3D可视化的搭建流程说明

在这里插入图片描述

前端加载3D模型

需求:在浏览器中渲染出来3D模型

在这里插入图片描述

1. 下载模型解析包

说明:模型解析包和制作3D的软件是配套的

npm i @splinetool/runtime

2. 拉取模型并渲染

说明:spline实例既可以拉取模型同时拉取完毕之后会在canvas节点上渲染画布

<script setup>
// 导入模型解析构造函数
import { Application } from '@splinetool/runtime'
import { onMounted, ref } from 'vue'// 初始化3d模型
const ref3d = ref(null)
const publicPath = 'https://fe-hmzs.itheima.net'
const init3dModel = () => {// 实例化解析器实例let spline = new Application(ref3d.value)// 拉取模型spline.load(`${publicPath}/scene.splinecode`).then(() => {console.log('3D模型加载并渲染完毕')})
}
// dom节点渲染完毕再加载
onMounted(() => {init3dModel()
})</script><template><div class="model-container"><!-- 准备3D渲染节点 --><canvas class="canvas-3d" ref="ref3d" /></div>
</template><style scoped lang="scss">
.model-container {height: 100%;background-color: black;width: 100%;flex-shrink: 0;
}
</style>

3. 添加进入条

在这里插入图片描述

纯展示类组件,只需要设计一个参数,显示隐藏

loading prop true 显示 false 隐藏

1- 封装组件

LoadingComponent.vue

<script setup>
defineProps({loading: {type: Boolean,default: false}
})
</script><template><div v-if="loading" class="loading"><p class="text">园区资源加载中…</p><div class="loading-process"><div class="process-wrapper"></div></div></div>
</template><style lang="scss">
.loading {position: absolute;left: 66%;top: 40%;transform: translateX(-50%);text-align: center;.text {font-size: 14px;color: #909399;margin-bottom: 16px;}.loading-process {width: 280px;height: 4px;background: rgba(255, 255, 255, 0.16);border-radius: 20px;overflow: hidden;}.process-wrapper {height: 100%;width: 5%;background: linear-gradient(90deg, #48ffff 0%, #3656ff 100%);animation-duration: 1000s;animation-name: loading;}@keyframes loading {0% {transform: scaleX(1);}1% {transform: scaleX(38);}100% {transform: scaleX(40);}}
}
</style>

2- 导入loading根据状态控制显示

<script setup>
import { onMounted, ref } from 'vue'
// 导入模型解析构造函数
import { Application } from '@splinetool/runtime'
// 导入loading组件
import LoadingComponent from '@/components/LoadingComponent.vue'// 调用接口拉取3d模型 渲染视图中
const publisPath = 'https://fe-hmzs.itheima.net'
const ref3d = ref(null)
const showLoading = ref(false)
const init3dModel = () => {// 开启loading showLoading.value = true// 1. 实例解析器对象(传入模型将来渲染的节点对象)const spline = new Application(ref3d.value)// 2. 使用对象load方法去拉取3大模型资源spline.load(`${publisPath}/scene.splinecode`).then(() => {showLoading.value = false// 模型渲染完毕之后后续的逻辑操作// 3. 拉取资源之后.then方法中可以做后续的逻辑操作})
}onMounted(async () => {// 获取原生的dom对象// 这个方法执行的时候 虽然在mounted中执行的 但是不能保证依赖的数据已经通过接口返回了// 解决方案:等到数据返回之后才进行初始化操作await getParkInfo()initBarChart()initPieChart()init3dModel()
})</script><template><!-- 3d模型渲染节点 --><div class="model-container"><!-- 进度条 --><LoadingComponent :loading="showLoading" /><!-- 准备3D渲染节点 --><canvas class="canvas-3d" ref="ref3d" /></div>
</template>

大屏适配

适配方案说明

缩放方案:接入难度非常小 效果中上

GitHub - Alfred-Skyblue/v-scale-screen: Vue large screen adaptive component vue大屏自适应组件

使用组件

1.安装组件

npm i v-scale-screen

2. 使用组件并制定宽高

注:以 1920 * 1080 为标准尺寸比

<v-scale-screen width="1920" height="1080">主体内容盒子
</v-scale-screen>

=“showLoading” />

```

大屏适配

适配方案说明

缩放方案:接入难度非常小 效果中上

GitHub - Alfred-Skyblue/v-scale-screen: Vue large screen adaptive component vue大屏自适应组件

使用组件

1.安装组件

npm i v-scale-screen

2. 使用组件并制定宽高

注:以 1920 * 1080 为标准尺寸比

<v-scale-screen width="1920" height="1080">主体内容盒子
</v-scale-screen>
http://www.mnyf.cn/news/51673.html

相关文章:

  • 零基础搭建网站百度广告推广怎么收费
  • 宁海有做网站的吗发布新闻
  • .net 购物网站开发源代码网站seo推广哪家值得信赖
  • 南昌网站seo技术域名注册新网
  • 安平网站建设百度seo是什么
  • 做网站大约要多少钱百度推广关键词怎么设置好
  • wordpress 更换谷歌厦门百度关键词seo收费
  • 手机软件大全seo课培训
  • 网站开发功能描述要怎么写策划方案模板
  • 建立门户网站多少钱seo怎么刷排名
  • 兼职做网站这样的网站网络营销的市场背景
  • 电信做网站吗网站发布与推广
  • edm营销网站注册网站在哪里注册
  • 优质的常州网站建设链友咨询
  • 两学一做网站专栏怎么设置网站seo排名公司
  • 网站的主要功能上海seo优化公司 kinglink
  • 360网站图标怎么做2345软件为什么没人管
  • 中国检察教育培训网络学院安卓手机优化软件排名
  • 廊坊手机网站潍坊seo建站
  • 重庆网站备案系统关键词推广操作
  • 销售成功案例分享广州seo推广运营专员
  • 上海集酷网站seo营销
  • 做网站要需要多少钱奇零seo赚钱培训
  • 网站做简介临沂网站建设
  • 我的世界充钱网站怎么做江西seo推广软件
  • 建设网站制作流程怎么去推广自己的公司
  • 长沙门户网站十大跨境电商erp排名
  • 白银网站模板软文300字案例
  • 阜阳微商城网站建设株洲发布最新通告
  • 重庆网站设计制作网站今日重大新闻事件