高手养成计划基础篇-Linux第一季 heatlevel

本文介绍了Linux操作系统的基础知识,包括其特点、桌面环境等,并详细列举了几种常见的Linux桌面环境,如Gnome、Xfce等,适合Linux初学者阅读。

前言
不学Linux,如何当黑客,不学Linux,永远是菜鸟,学了Linux,额,你还是菜鸟,以上都是戏言,大家看看笑笑就好了。嘿嘿,不过Linux给我们带来的是一片开源的天地,大部分的服务器都是Linux的。本篇文章看标题也知道只是初入Linux,看完本篇文章目的是在于让大家无障碍的操作Linux系统。仅此而已,后续文章将深入了解Linux系统啦。
目录
第一节 Linux简介
第二节 文件处理命令
第三节 文件搜索命令
第四节 总结
第一节 Linux简介
Linux是一款免费的操作系统,用户可以通过网络或其他途径免费获得,并可以任意修改其源代码。这是其他的操作系统所做不到的。正是由于这一点,来自全世界的无数程序员参与了Linux的修改、编写工作,程序员可以根据自己的兴趣和灵感对其进行改变,这让Linux吸收了无数程序员的精华,不断壮大。
Linux的桌面环境
相信大家都用习惯了windows,那么windows最方便支持就在于它友好的和用户交互了,所以我也先给大家介绍一下Linux的桌面环境。
什么是桌面环境?
在图形计算中,一个桌面环境(Desktop environment,有时称为桌面管理器)为计算机提供一个图形用户界面(GUI)。但严格来说窗口管理器和桌面环境是有区别的。桌面环境就是桌面图形环境,它的主要目标是为Linux/Unix操作系统提供一个更加完备 的界面以及大量各类整合工具和使用 程序,其基本 易用性吸引着大量的新用户。桌面环境名称来自桌面比拟,对应于早期的文字命令行界面(CLI)。一个典型的桌面环境提供图标,视窗,工具栏,文件夹,壁纸以及像拖放这样的能力。整体而言,桌面环境在设计和功能上的特性,赋予了它与众不同的外观和感觉。
Linux桌面环境有哪些?
1、gnome
即GNU网络对象模型环境 (The GNU Network Object Model Environment),GNU计划的一部分,开放源码运动的一个重要组成部分。是一种让使用者容易操作和设定电脑环境的工具。
目标是基于自由软件,为Unix或者类Unix**操作系统**构造一个功能完善、操作简单以及界面友好的桌面环境,他是GNU计划的正式桌面。
图片描述
2、Xfce
即XForms Common Environment,创建于2007年7月,类似于商业图形环境CDE,是一个运行在各类Unix下的轻量级桌面环境。原作者Olivier Fourdan最先设计XFce是基于XForms三维图形库。Xfce设计目的是用来提高系统的效率,在节省系统资源的同时,能够快速加载和执行应用程序。
3、Fluxbox
Fluxbox是一个基于GNU/Linux的轻量级图形操作界面,它虽然没有GNOME和KDE那样精致 ,但由于它的运行对系统资源和配置要求极低,所以它被安装到很多较旧的或是对性能要求较高的机器上,其菜单和有关 配置被保存于用户根目录下的.fluxbox目录里,这样使得它的配置极为便利。
4、Enlightenment
是一个功能强大的窗口管理器,它的目标是运用 户轻而易举地配置所见即所得的桌面图形界面。现在Enlightenment的界面已经相当豪华,它拥有像AfterStep一样的可视化时钟以及其它浮华的界面效果,用户不仅可以任意选择边框和动感的声音效果,最有吸引力的是由于它开放的设计思想,每一个用户可以根据自己的爱好,任意地配置窗口的边框、菜单以及屏幕上其它各个部分,而不须要 接触源代码,也不须要 编译任何程序。
…………………………………………………….略
想要查看详细信息,请点点击http://bbs.ichunqiu.com/thread-11828-1-1.html?from=csdn

// pages/plan/plan.js import bleUtils from "../../utils/ble" import { submitRecord } from "../../service/api" Page({ data: { money: 0, bleStatus: { isConnect: wx.getStorageSync('isConnectionBluetooth'), bluetoothText: '已连接', }, timer: null, totalTime: 5 * 60, // 总秒数 remainingTime: 5 * 60, // 剩余秒数 formattedTime: '05:00', // 格式化后的时间 tabCurrentIndex: 1, modelTabList: ['', '模式01', '模式02', '模式03', '模式04'], powerValue: 0, hotModelList: ['关', '弱', '中', '强'], hotTabCurrentIndex: 0, rateModelList: [30, 50, 1000, 5000], rateTabCurrentIndex: null, rateValue: '', baseInfo: { therapyMode: '', duration: null, startTime: null, //理疗开始时间 endTime: null, //理疗结束时间 dataInfo: [] }, //保存理疗数据 physioDataInfo: { deviceMac: '', //设备mac地址 planType: '', //方案类型 info: [] },//保存理疗数据 canvasContext: null, canvasWidth: 0, canvasHeight: 0, _countdownStart: 0, // 新增字段存储计时基准时间 _countdownTotal: 0, // 存储总时长 isStop: true, // 是否暂停 isCountdownStarted: false, // 倒计时是否启动 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { // 设置屏幕常亮 wx.setKeepScreenOn({ keepScreenOn: true }) bleUtils.bleTool.onDiscoveryData = this.handleDiscoveryData.bind(this); // bleUtils.bleTool.onDeviceStatus = this.handleDeviceStatus.bind(this); // bleUtils.bleTool.writeBLECharacteristicValue({ "Orde": "ReadStatus" }); if(!this.data.isCountdownStarted) { this.sendStartCommands([{ "SetTime": this.data.remainingTime }, { "SetMode": this.data.tabCurrentIndex}]) } this.initCanvas(); }, onShow() { // 倒计时未开始, 直接return if (!this.data.isCountdownStarted) return; const saved = wx.getStorageSync('countdownState'); if (saved) { const now = Date.now() const remaining = Math.max(0, saved.total - (now - saved.start) / 1000); // 仅在实际剩余时间变化超过1秒时更新显示 if (remaining > 0) { this.setData({ remainingTime: remaining, formattedTime: this.formatTime(Math.floor(remaining)), _countdownStart: saved.start, _countdownTotal: saved.total, }) // 始终更新进度条以保证流畅性 this.drawProgress((remaining / saved.total) * 100); this.clearTimer(); this.updateCountdown() } else { this.handleCountdownEnd() } } }, // 页面隐藏时保存状态 onHide() { const { remainingTime, isStop, isCountdownStarted } = this.data; if (remainingTime > 0 && !isStop && isCountdownStarted) { wx.setStorageSync('countdownState', { start: this.data._countdownStart, total: this.data._countdownTotal }); } }, onUnload() { // 页面卸载时清除计时器 this.clearCanvas(); this.clearTimer(); // bleUtils.bleTool.onDeviceStatus = null; }, // 设备返回数据的回调 handleDiscoveryData(res) { console.log(res); const newDataPoint = { inten: this.data.planInfo.intensity, heat: this.data.planInfo.heatLevel, electric: res.CurrentLev, receiveDataTime: new Date().getTime(), xAxis: this.formatTime(this.data._countdownTotal - this.data.remainingTime), } this.data.baseInfo.dataInfo.push(newDataPoint); this.setData({ 'baseInfo.dataInfo': this.data.baseInfo.dataInfo }) }, // 全部理疗完成时的重置 resetAllData() { this.resetCurrentSessionData(); this.setData({ 'physioDataInfo.info': [] }); }, // 重置当前部位接收设备返回的数据 resetCurrentSessionData() { this.setData({ baseInfo: { duration: null, therapyMode: '', startTime: null, //理疗开始时间 endTime: null, //理疗结束时间 dataInfo: [] } }) }, // 初始化画布 initCanvas() { const query = wx.createSelectorQuery(); query.select('#myCanvasId') .fields({ node: true, size: true }) .exec(async (res) => { const canvas = res[0].node; const canvasContext = canvas.getContext('2d'); // 适配高清屏 const dpr = wx.getWindowInfo().pixelRatio; canvas.width = res[0].width * dpr; canvas.height = res[0].height * dpr; canvasContext.scale(dpr, dpr); this.setData({ canvasContext, canvasWidth: res[0].width, canvasHeight: res[0].height }); this.drawProgress(100); // 初始绘制满圆环 }); }, // 绘制进度(百分比) drawProgress(progress) { const { canvasContext, canvasWidth, canvasHeight } = this.data; if (!canvasContext) return; const centerX = canvasWidth / 2; const centerY = canvasHeight - 25; // 圆心放在底部 const radius = 125; // 使用线性插值实现平滑过渡 const currentProgress = Math.min(100, Math.max(0, progress)) // 清空画布 canvasContext.clearRect(0, 0, canvasWidth, canvasHeight); // 绘制底层灰色圆环 canvasContext.beginPath(); canvasContext.arc(centerX, centerY, radius, -Math.PI, 0); canvasContext.strokeStyle = '#F7F8FA'; canvasContext.lineWidth = 15; canvasContext.stroke(); // 绘制进度圆环(逆时针方向) if (currentProgress > 0) { const startAngle = -Math.PI; const endAngle = startAngle + (Math.PI * currentProgress) / 100; canvasContext.beginPath(); canvasContext.arc(centerX, centerY, radius, startAngle, endAngle); canvasContext.strokeStyle = '#009DDC'; canvasContext.lineWidth = 15; canvasContext.lineCap = 'round'; canvasContext.stroke(); } }, // 开始倒计时 startCountdown() { this.sendStartCommands([{ "SetWork": "Run" }, { "SuccessiveData": "ON" }]) const now = Date.now(); const tempTime = this.data.remainingTime; const startTimestamp = now - (this.data.totalTime - tempTime) * 1000; this.setData({ isCountdownStarted: true, remainingTime: tempTime, formattedTime: this.formatTime(tempTime), _countdownStart: startTimestamp, // 新增字段存储计时基准时间 _countdownTotal: this.data.totalTime, // 存储总时长 }); // 清除旧计时器 this.clearTimer(); // 启动新计时器 this.updateCountdown(); }, // 倒计时更新逻辑 updateCountdown() { const now = Date.now(); const elapsed = (now - this.data._countdownStart) / 1000; const remaining = Math.max(0, this.data._countdownTotal - elapsed); if (remaining <= 0) { this.handleCountdownEnd(); return; } // 更新显示(仅在变化时更新) if (remaining !== this.data.remainingTime) { this.setData({ remainingTime: Math.floor(remaining), formattedTime: this.formatTime(Math.floor(remaining)) }); const progress = (remaining / this.data._countdownTotal) * 100; this.drawProgress(progress); } this.data.timer = setTimeout(() => this.updateCountdown(), 10); }, // 处理倒计时结束 handleCountdownEnd() { this.clearTimer(); this.setData({ 'baseInfo.endTime': new Date().getTime(), remainingTime: 0, formattedTime: this.formatTime(0), isCountdownStarted: false, }); this.drawProgress(0); // 原有后续逻辑 this.sendStartCommands([{ "SuccessiveData": "OFF" }]); const baseInfo = { ...this.data.baseInfo }; this.data.physioDataInfo.info.push(baseInfo); this.setData({ 'physioDataInfo.info': [...this.data.physioDataInfo.info] }); //理疗结束 this.handleAllComplete(); }, // 全部完成的处理 handleAllComplete() { wx.showModal({ title: '提示', content: '时间到,理疗结束!', showCancel: false, complete: (res) => { if (res.confirm) { submitRecord(this.data.physioDataInfo).then(res => { if (res.code == 0) { wx.removeStorageSync('countdownState'); this.resetAllData(); wx.switchTab({ url: '/pages/index/index' }); } }); } } }) }, //模式改变 changeTabHandle(E) { const { index } = E.currentTarget.dataset this.setData({ tabCurrentIndex: index }); this.sendStartCommands([{"SetMode": index}]) if(this.data.powerValue) { this.sendStartCommands([{"SetInten": this.data.powerValue}]) } }, //电流强度 powerChange(E) { const { value } = E.detail; const tempValue = Number(value); if (tempValue <= 0 || tempValue > 99) { wx.showToast({ title: `电流强度${ tempValue <= 0 ? '不得低于0档' : '不得超过99档' }`, icon: 'none' }) return false; } this.setData({ powerValue: tempValue }); this.sendStartCommands([{"SetInten": this.data.powerValue}]) }, decOrAddValue(E) { const { type } = E.currentTarget.dataset; if (type === 'dec' && this.data.powerValue == 0) { wx.showToast({ title: '电流强度不得低于0档', icon: 'none' }); return false } else if (type === 'add' && this.data.powerValue >= 99) { wx.showToast({ title: '电流强度不得超过99档', icon: 'none' }) return false; } this.setData({ powerValue: type === 'add' ? this.data.powerValue + 1 : this.data.powerValue - 1 }) this.sendStartCommands([{"SetInten": this.data.powerValue}]) }, //加热强度 changeHotTabHandle(E) { const { index } = E.currentTarget.dataset this.setData({ hotTabCurrentIndex: index }); this.sendStartCommands([{"SetHeat": index}]) }, // 理疗频率 changeRateTabHandle(E) { if(!this.data.tabCurrentIndex) { return wx.showToast({ title: '请选择理疗模式', icon: 'none' }) } const { index } = E.currentTarget.dataset; this.setData({ rateTabCurrentIndex: index, rateValue: this.data.rateModelList[index] }) this.sendStartCommands([{"SetCustMode": this.setCustMode(this.data.tabCurrentIndex, this.data.rateValue)}]) if(this.data.powerValue) { this.sendStartCommands([{"SetInten": this.data.powerValue}]) } }, rateChange(E) { if(!this.data.tabCurrentIndex) return wx.showToast({ title: '请选择理疗模式', icon: 'none' }); const { value } = E.detail; const tempValue = Number(value); if (tempValue < 10 || tempValue > 5000) { wx.showToast({ title: `理疗频率${ tempValue < 10 ? '不得小于10HZ' : '不得超过5000HZ' }`, icon: 'none' }) return false; } this.setData({ rateValue: tempValue }); const index = this.data.rateModelList.findIndex(item => item == this.data.rateValue); if(index != -1) { this.setData({ rateTabCurrentIndex: index }) } else { this.setData({ rateTabCurrentIndex: null }) } this.sendStartCommands([{"SetCustMode": this.setCustMode(this.data.tabCurrentIndex, this.data.rateValue)}]) if(this.data.powerValue) { this.sendStartCommands([{"SetInten": this.data.powerValue}]) } }, rateInput(E) { const { value } = E.detail; if(value != '') this.setData({ rateTabCurrentIndex: null }) }, decOrAddRateValue(E) { if(!this.data.tabCurrentIndex) return wx.showToast({ title: '请选择理疗模式', icon: 'none' }); const { type } = E.currentTarget.dataset; if ((type === 'dec' && this.data.rateValue <= 10) || (type === 'add' && this.data.rateValue >= 5000)) { wx.showToast({ title: `理疗频率${ type == 'dec' ? '不得小于10HZ' : '不得超过5000HZ' }`, icon: 'none' }); return false } this.setData({ rateValue: type === 'add' ? this.data.rateValue + 10 : this.data.rateValue - 10 }) const index = this.data.rateModelList.findIndex(item => item == this.data.rateValue); if(index != -1) { this.setData({ rateTabCurrentIndex: index }) } else { this.setData({ rateTabCurrentIndex: null }) } this.sendStartCommands([{"SetCustMode": this.setCustMode(this.data.tabCurrentIndex, this.data.rateValue)}]) if(this.data.powerValue) { this.sendStartCommands([{"SetInten": this.data.powerValue}]) } }, // 开始理疗 startHandle() { if(!wx.getStorageSync('token')) return this.isLogin(); if(this.data.isStop && !this.data.isCountdownStarted) this.setData({'baseInfo.startTime': new Date().getTime()}); this.startCountdown(); this.setData({ isStop: false }) }, // 暂停理疗 stopHandle() { this.clearTimer(); this.setData({ isStop: true }); this.sendStartCommands([{ "SetWork": "Stop" }, { "SuccessiveData": "OFF" }]); }, // 格式化时间为 MM:SS formatTime(seconds) { const mins = Math.floor(seconds / 60).toString().padStart(2, '0'); const secs = (seconds % 60).toString().padStart(2, '0'); return `${mins}:${secs}`; }, // 清空canvas clearCanvas() { this.setData({ canvasContext: null }) }, // 清理计时器 clearTimer() { if (this.data.timer) { clearTimeout(this.data.timer); this.setData({ timer: null }); } }, // 根据模式设置频率 setCustMode(typeMode, rate) { let mode = { "adj_num": 250, "frequency": rate, "timer_cont": 10, "max_cont": 10, "amp_num": 30 }; if(typeMode == 2) { mode["adj_num"] = 200; mode["timer_cont"] = 6; } return mode }, // 批量发送多个指令给设备 sendStartCommands(initCommands) { bleUtils.bleTool.sendCommands(initCommands, function() { console.log('sendStartCommands') }) }, // 是否登录 isLogin() { wx.showModal({ content: '此功能需登陆后才可使用', complete: (res) => { if (res.confirm) wx.redirectTo({ url: '/pages/login/login' }); } }) }, })优化我的代码
09-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值