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

腾讯云 小程序 SDK对象存储 COS使用记录,原生小程序写法。

最近做了一个项目,需求是上传文档,文档类型多种,图片,视频,文件,doc,xls,zip,txt 等等,而且文档类型可能是大文件,可能得上百兆,甚至超过1G。

腾讯云文档地址:https://cloud.tencent.com/document/product/436/31953 腾讯云可以支持5G 的文件,还是很厉害的。
这里只要是讲一下使用这个SDK的流程,因为第一次看文档的时候,文档介绍很简洁,甚至有点笼统。我当时都是很懵的,无从下手。
这个是小程序小程序直传实践的实现步骤,同样使用于对象存储。,我们一开始研究SDK对象储存觉得很难,然后想简单点,搞个对象储存,不这么麻烦。最后是借鉴了这里的步骤思路。
1、登录后台创建桶,地域
2、获取秘钥
3、小程序配置白名单
在这里插入图片描述
核心代码就这么点,选择文件,将后缀传给服务器,服务器根据后缀,生成一个cos文件路径,计算对应的签名,返回URL和签名信息给前端。
在这里插入图片描述
在这里插入图片描述

最终效果
在这里插入图片描述

* 文件名称: * 备注: * 文件: 去上传文件 文件列表 {{item}} × 保 存

wxcs
page{
font-size: 28rpx;
color: #333;
}
.content-row {
display: flex;
height: 48px;
color: #333;
padding-left: 20rpx;
line-height: 48px;
border-bottom: 1rpx solid #ddd;
}

.content-rows {
display: flex;
color: #333;
padding-left: 20rpx;
line-height: 48px;
}

.content-title {
width: 190rpx;
color: #666;
}
.click-btn{
background-color: #E1B368;
}
.click-btn-hover{
background-color: #b98633;
}

/index.wxss/
.title {
display:block;
box-sizing: border-box;
padding: 0 5px;
width: 100%;
height: 30px;
line-height: 30px;
border-top: 1px solid #ccc;
margin:auto;
font-size:14px;
color:#333;
text-align: left;
font-weight: bold;
}

.list-panel{
width: 100%;
}

.sub-title{
display:block;
box-sizing: border-box;
padding: 0 5px;
width: 100%;
height: 30px;
line-height: 30px;
font-size:12px;
color:#333;
text-align: left;
font-weight: bold;
}

.list {
margin-top: 10px;
padding-bottom: 10px;
width: 100%;
}

.button {
font-weight: 500;
float: left;
width: 710rpx;
margin: 0 3px 3px 0;
text-align: center;
font-size: 14px;
height: 60rpx;
padding-top: 6px;
}
.click-btn2 {
background-color: #eee;
}

.click-btn-hover2 {
background-color: #d3d3d3;
}

wxjs
在这里插入图片描述
Js部分引入了两个文件,cos-wx-sdk-v5.js 文件可以在github上下载https://github.com/tencentyun/cos-wx-sdk-v5/tree/master/demo
github上右demo吗,我通过demo自己稍微改造了一下。
和config,其中config就是配置的一些内容
在这里插入图片描述

var COS = require(‘…/…/lib/cos-wx-sdk-v5’);
const app = getApp()
var config = require(‘…/…/config’)

//这里是获取签名授权
var getAuthorization = function (options, callback) {
wx.request({
method: ‘POST’,
url: config.stsUrl, // 服务端签名,参考 server 目录下的两个签名例子
dataType: ‘json’,
data: {
uid: wx.getStorageSync(‘uid’),
token: wx.getStorageSync(‘token’)
},
header: {
‘content-type’: ‘application/x-www-form-urlencoded’
},
success: function (result) {
var data = result.data.data;
var credentials = data && data.credentials;
// if (!data || !credentials) return console.error(‘credentials invalid’);
console.log(credentials)
callback({
TmpSecretId: credentials.tmpSecretId,
TmpSecretKey: credentials.tmpSecretKey,
SecurityToken: credentials.sessionToken,
StartTime: data.startTime, // 时间戳,单位秒,如:1580000000,建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
ExpiredTime: data.expiredTime, // 时间戳,单位秒,如:1580000900
});
},
});
};
var cos = new COS({
getAuthorization: getAuthorization,
});

Page({

/**

  • 页面的初始数据
    */
    data: {
    itemname: ‘’,
    id: ‘’,
    beizhu: ‘’,
    img: [],
    pdfFile: ‘’,
    fileType: ‘’,
    filekeyname: ‘’,
    jindu: ‘’,
    speed: ‘’,
    datalist:[],
    realimg:[]
    },
    onLoad(options) {
    if (options.id) {
    this.setData({
    id: options.id
    })
    }

},
handleItem(e) {
this.setData({
itemname: e.detail.value
})
},
handlebeizhu(e) {
this.setData({
beizhu: e.detail.value
})
},
//核心代码
postUpload() {
let that = this
wx.chooseMessageFile({
count: 1,
type: ‘all’,
success: function (res) {
let data = res.tempFiles[0]
console.log(data.name)
let testarr = []
testarr.push(data.name.replace(/,/g, ‘’))
that.setData({
realimg:that.data.realimg.concat(testarr)
})
wx.showLoading({
title: ‘上传中…’,
})
var lastDotIndex = data.name.lastIndexOf(“.”); // 查找最后一个"."的索引
var secondPart = data.name.slice(lastDotIndex + 1);
console.log(secondPart)
cos.uploadFile({
Bucket: config.Bucket,
Region: config.Region,
Key: Date.now() + Math.floor(Math.random() * 1000) + ‘.’+secondPart,
FilePath: data.path,
FileSize: data.size,
SliceSize: 1024 * 1024 * 5, // 文件大于5mb自动使用分块上传
onTaskReady: function (taskId) {
TaskId = taskId;
},
onProgress: function (info) {
var percent = parseInt(info.percent * 10000) / 100;
var speed = parseInt((info.speed / 1024 / 1024) * 100) / 100;
console.log(that, ‘进度:’ + percent + ‘%; 速度:’ + speed + ‘Mb/s;’);
that.setData({
jindu: percent,
speed: speed
})
},
onFileFinish: function (err, data, options) {
if(!err){
console.log(that.data.realimg)
let arr = []
arr.push(options.Key)
that.setData({
img: that.data.img.concat(arr) //我们自己稍微改造了一下,上传到腾讯云的文件名是在时间戳+3位的随机数,但是显示在本地的文件名是自己原本给文件的命名。(因为大家的文件命名不规范,长长短短,啥都有。统一命名,在腾讯云后台看起来不会奇奇怪怪。)
})
}else{
that.setData({
realimg:that.data.realimg.pop()
})
}

          wx.hideLoading()console.log(options.Key + '上传' + (err ? '失败' : '完成'));},},function (err, data) {console.log(err || data);},);},
});

},

DelImg(e){
console.log(e)
let i = e.currentTarget.dataset.index
let that = this
wx.showModal({
title: ‘提示’,
content: ‘确定要删除吗?’,
cancelText: ‘取消’,
confirmText: ‘确定’,
success: res => {
if (res.confirm) {
that.data.realimg.splice(i, 1);
that.data.img.splice(i, 1);
that.setData({
realimg:that.data.realimg,
img:that.data.img,
})
}
}
})
},
handlesave() {
let that = this
if (!this.data.itemname) {
wx.showToast({
title: ‘请填写文件名称’,
icon: ‘error’,
duration: 2000
})
return
}
if (this.data.realimg.length <1) {
wx.showToast({
title: ‘请上传文件’,
icon: ‘error’,
duration: 2000
})
return
}
wx.showLoading({
title: ‘保存中…’,
})
// console.log(this.data.fileList1)
// var img = [];
// var realimg = [];

// this.data.fileList1.forEach(function (item) {
//   var index = 12
//   // 分割字符串,取前十位  
//   var firstPart = item.slice(0, 13);
//   // 提取下标12之后的内容  
//   var index = 12;
//   var secondPart = item.slice(index + 1);
//   // 提取最后一个"."之后的内容  
//   var lastDotIndex = item.lastIndexOf(".");
//   var thirdPart = item.slice(lastDotIndex + 1);
//   img.push(firstPart + "." + thirdPart);
//   realimg.push(secondPart);
// });
// console.log(img, realimg)
// return
wx.request({url: app.globalData.siteurlh5 + '/fileadd.php',data: {id: this.data.id,beizhu: this.data.beizhu,uid: wx.getStorageSync('uid'),token: wx.getStorageSync('token'),title: this.data.itemname,img: this.data.img, // 时间戳命名文件realimg: this.data.realimg  //文件真实名称},header: {'content-type': 'application/x-www-form-urlencoded'},method: 'POST',success(res) {console.log(res, )if (res.data.bs == 'success') {wx.showToast({title: res.data.errmsg,duration: 2000,icon: 'success'})setTimeout(() => {wx.navigateBack({delta: 1,})}, 2000);} else if (res.data.bs == 'failed') {wx.showToast({title: res.data.errmsg,duration: 2000,icon: 'error'})} else if (res.data.bs == 'error') {wx.showToast({title: res.data.errmsg,duration: 2000,icon: 'error'})} else if (res.data.bs == 'guoqi') {wx.removeStorageSync('userInfo'); //清除缓存wx.removeStorageSync('uid')wx.removeStorageSync('token')wx.redirectTo({url: '../index/index',})}},fail(err) {console.log(err)wx},complete() {// wx.hideLoading()}
})

},
})

在这里插入图片描述
上传完成这个文件后缀名就是我们的文件了。但是它不是完整的路径,完整的路径是在腾讯云上面就可以预览了。如果前端要下载文件,那就再让你的后台把完整的路径传回来。
在这里插入图片描述

以下是一个简单的上传多种文件类型的方案:
我们最初是指考虑了简单的上传文件,并没有考虑大的文件,所以超过20M 的文件,这里是不支持的。
![在这里插入图片描述](https
😕/img-blog.csdnimg.cn/c1ecbd1f015f43fdb7422f425223ffac.png)
wxml





项目名称:






备注:





*
文件:



    <view class="bg-img" wx:for="{{imgList1}}" wx:key="index" style="position: relative;"><image src="{{item}}" mode="aspectFill" data-url="{{item}}" bindtap='previewImage' data-src="{{item}}" style="width:140rpx;height:140rpx;margin: 10rpx 10rpx 10rpx 0 ;"></image><view bindtap="DelImg" data-index="{{index}}"><view style="z-index: 9; margin:10rpx 17rpx 10rpx 0;width: 40rpx;height: 30rpx;background-color: #555;color: white;position: absolute;right: -16rpx;top: -10rpx;text-align: center;line-height: 30rpx;border-radius: 6rpx;">×</view></view></view><view class="bg-img" wx:for="{{videoList1}}" wx:key="index" style="position: relative;"><video src="{{item}}" bindtap="previewVideo" data-url="{{item}}" style="width:140rpx;height:140rpx;margin: 10rpx 10rpx 20rpx 0 ;" autoplay="{{isPlay}}" loop="{{false}}" show-center-play-btn='{{true}}' show-play-btn="{{true}}" controls picture-in-picture-mode="{{['push', 'pop']}}"></video><view bindtap="DelImg2" data-index="{{index}}"><view style="z-index: 9; margin:10rpx 17rpx 10rpx 0;width: 40rpx;height: 30rpx;background-color: #555;color: white;position: absolute;right: -16rpx;top: -10rpx;text-align: center;line-height: 30rpx;border-radius: 6rpx;">×</view></view></view><view class="bg-img" wx:for="{{fileList1}}" wx:key="index" style="position: relative;"><input placeholder="查看附件" class="click-btn2" hover-class="click-btn-hover2" disabled bindtap="handledownload" data-img="{{item}}"  placeholder-style="color:#888" name="input" style="padding: 0px 10px;width:640rpx;font-size: 28rpx;color: #888;height: 70rpx;line-height: 70rpx;margin-top: 10rpx;"></input><view bindtap="DelImg3" data-index="{{index}}"><view style="z-index: 9; margin:10rpx 17rpx 10rpx 0;width: 40rpx;height: 30rpx;background-color: #555;color: white;position: absolute;right: -16rpx;top: -10rpx;text-align: center;line-height: 30rpx;border-radius: 6rpx;">×</view></view></view><view bindtap="uploadFileTap" data-id="1" ><view style="width:140rpx;height:140rpx;border:1px dashed #ddd;text-align:center;background:white;position: relative;margin:10rpx 0;"><image src="/images/upload.png" style="width:45rpx;height:37rpx;margin-top: 35rpx;"></image><view style="font-size: 20rpx;color: #333;">文件</view></view></view></view>
</view>
保 存 wxss page{ font-size: 28rpx; color: #333; } .content-row { display: flex; height: 48px; color: #333; padding-left: 20rpx; line-height: 48px; border-bottom: 1rpx solid #ddd; }

.content-rows {
display: flex;
color: #333;
padding-left: 20rpx;
line-height: 48px;
}

.content-title {
width: 190rpx;
color: #666;
}
.click-btn{
background-color: #ff5a28;
}
.click-btn-hover{
background-color: #d44215;
}

/index.wxss/
.title {
display:block;
box-sizing: border-box;
padding: 0 5px;
width: 100%;
height: 30px;
line-height: 30px;
border-top: 1px solid #ccc;
margin:auto;
font-size:14px;
color:#333;
text-align: left;
font-weight: bold;
}

.list-panel{
width: 100%;
}

.sub-title{
display:block;
box-sizing: border-box;
padding: 0 5px;
width: 100%;
height: 30px;
line-height: 30px;
font-size:12px;
color:#333;
text-align: left;
font-weight: bold;
}

.list {
margin-top: 10px;
padding-bottom: 10px;
width: 100%;
}

.button {
float: left;
margin: 0 3px 3px 0;
text-align: left;
font-size: 14px;
height: 28px;
line-height:28px;
padding:0 10px;
}
.click-btn2 {
background-color: #eee;
}

.click-btn-hover2 {
background-color: #d3d3d3;
}

wxjs
const app = getApp()
Page({

/**

  • 页面的初始数据
    */
    data: {
    itemname: ‘’,
    id: ‘’,
    beizhu: ‘’,
    imgList1: [],
    fileList1:[],
    videoList1:[],
    pdfFile: ‘’,
    fileType:‘’
    },

handledownload(e) {
console.log(e)
let img = e.currentTarget.dataset.img
wx.downloadFile({
url: img,
success: function (res) {
// console.log(res)
// return
var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
wx.openDocument({
filePath: Path,
fileType: Path.split(“.”)[Path.split(“.”).length - 1],
showMenu: true,
success: function (a) {},
fail: function (a) {
console.log(a)
wx.showToast({
title: ‘文件打开失败’,
icon: ‘none’,
duration: 2000,
})
}
})
}
})
},
DelImg(e){
console.log(e)
let i = e.currentTarget.dataset.index
let that = this
wx.showModal({
title: ‘提示’,
content: ‘确定要删除吗?’,
cancelText: ‘取消’,
confirmText: ‘确定’,
success: res => {
if (res.confirm) {
that.data.imgList1.splice(i, 1);
that.setData({
imgList1:that.data.imgList1,
pdfFile:‘’
})
}
}
})
},
DelImg2(e){
console.log(e)
let i = e.currentTarget.dataset.index
let that = this
wx.showModal({
title: ‘提示’,
content: ‘确定要删除吗?’,
cancelText: ‘取消’,
confirmText: ‘确定’,
success: res => {
if (res.confirm) {
that.data.videoList1.splice(i, 1);
that.setData({
videoList1:that.data.videoList1,
pdfFile:‘’
})
}
}
})
},
DelImg3(e){
console.log(e)
let i = e.currentTarget.dataset.index
let that = this
wx.showModal({
title: ‘提示’,
content: ‘确定要删除吗?’,
cancelText: ‘取消’,
confirmText: ‘确定’,
success: res => {
if (res.confirm) {
that.data.fileList1.splice(i, 1);
that.setData({
fileList1:that.data.fileList1,
pdfFile:‘’
})
}
}
})
},
previewImage(e){
console.log(e)
const current = e.currentTarget.dataset.url //获取当前点击的 图片 url
let arr = []
arr.push(current)
wx.previewImage({
current: current,
urls: arr
})
},
previewImg() {
let img = this.pdfFile
wx.downloadFile({
url: img,
success: function(res) {
var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
wx.openDocument({
filePath: Path,
showMenu: true,
success: function(a) {},
fail: function(a) {
wx.showToast({
title: ‘文件打开失败’,
icon: ‘none’,
duration: 2000,
})
}
})
}
})
},
uploadDIY(filePaths, successUp, failUp, i, length) {
wx.showLoading({
title: ‘上传中…’,
})
console.log(filePaths[i])
let that = this
wx.uploadFile({
url: ‘https://www.xxxxx.com/mnp/oaapi/fileupload.php’,
filePath: filePaths[i].path,
name: ‘file’,
formData: {
‘uid’: wx.getStorageSync(‘uid’),
‘token’: wx.getStorageSync(‘token’),
},
success: (res) => {
const data = JSON.parse(res.data.replace(‘\uFEFF’,‘’))
console.log(data)
if (data.bs == ‘success’) {
wx.showToast({
title: data.errmsg,
duration: 2000,
icon: ‘success’
})
successUp++;
// let arr = []
// arr.push(‘https://xxxxx.oss-cn-shenzhen.aliyuncs.com/zhuangshi/zspdf.png’)
let fileType = data.img.split(“.”)[data.img.split(“.”).length - 1]
console.log(fileType,data.img)
if(fileType == ‘pdf’|| fileType == ‘txt’|| fileType == ‘zip’|| fileType == ‘doc’|| fileType == ‘docx’ || fileType == ‘ppt’ || fileType == ‘pptx’ || fileType == ‘xls’ || fileType == ‘xlsx’ ){
that.data.fileList1.push(data.img)
that.setData({
pdfFile:data.img,
fileList1: that.data.fileList1
})
}else if(fileType == ‘jpg’|| fileType == ‘jpeg’ || fileType == ‘png’){
that.data.imgList1.push(data.img)
that.setData({
pdfFile:data.img,
imgList1: that.data.imgList1
})
}else if(fileType == ‘mp4’){
that.data.videoList1.push(data.img)
that.setData({
pdfFile:data.img,
videoList1: that.data.videoList1
})
}
return
that.data.imgList1.push(data.img)
that.setData({
pdfFile:data.img,
imgList1: that.data.imgList1
})
that.data.pdfFile = data.img
// console.log(‘上传图片成功:’, JSON.parse(res.data));
// var data = JSON.parse(res.data);
// console.log(data)
// 把获取到的路径存入imagesurl字符串中
// that.infolist[e].imglist.push(data.img)
// console.log(this.data.imagesurl)
} else if (data.bs == ‘guoqi’) {
wx.showToast({
title: data.errmsg,
duration: 2000,
icon: ‘error’
})
setTimeout(function() {
wx.redirectTo({
url: ‘…/…/pagesD/login/login’
})
}, 500)
} else {
wx.showToast({
title: data.errmsg,
duration: 2000,
icon: ‘error’
})
}

  },fail: (res) => {failUp++;},complete: () => {i++;if (i == length) {// Toast('总共' + successUp + '张上传成功,' + failUp + '张上传失败!');} else { //递归调用uploadDIY函数that.uploadDIY(filePaths, successUp, failUp, i, length);}},
});

},
uploadFileTap(e) {
let that = this;
wx.chooseMessageFile({
count: 10,
type: ‘all’,
success(res) {
console.log(res)
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFiles
// let fileType = tempFilePaths[0].type
// that.setData({
// fileType:fileType
// })
that.uploadDIY( res.tempFiles, 0, 0, 0, res.tempFiles.length,e);
return
wx.uploadFile({
url: ‘https://www.xxx.com/mnp/oaapi/fileupload.php’,
filePath: tempFilePaths[0].path,
name: ‘file’,
formData: {
‘uid’: wx.getStorageSync(‘uid’),
‘token’: wx.getStorageSync(‘token’),
},
success(res) {
const data = JSON.parse(res.data.replace(‘\uFEFF’,
‘’))
console.log(data)
if (data.bs == ‘success’) {
wx.showToast({
title: data.errmsg,
duration: 2000,
icon: ‘success’
})
let arr = []
arr.push(‘https://xxxxx.oss-cn-shenzhen.aliyuncs.com/zhuangshi/zspdf.png’)
that.setData({
pdfFile:data.img,
imgList1:arr
})
that.data.pdfFile = data.img

        } else if (data.bs == 'guoqi') {wx.showToast({title: data.errmsg,duration: 2000,icon: 'error'})setTimeout(function () {// wx.removeStorageSync('userInfo'); //清除缓存// wx.removeStorageSync('uid')// wx.removeStorageSync('token')wx.redirectTo({url: '../index/index',})}, 500)} else {wx.showToast({title: data.errmsg,duration: 2000,icon: 'error'})}}})}
})

},
/**

  • 生命周期函数–监听页面加载
    */
    onLoad(options) {
    // console.log(cos)
    if (options.id) {
    this.setData({
    id: options.id
    })
    }
    },
    handleItem(e) {
    this.setData({
    itemname: e.detail.value
    })
    },
    handlebeizhu(e) {
    this.setData({
    beizhu: e.detail.value
    })
    },
    handlesave() {
    let that = this
    if (!this.data.itemname) {
    wx.showToast({
    title: ‘请填写项目名称’,
    icon: ‘error’,
    duration: 2000
    })
    return
    }
    wx.showLoading({
    title: ‘保存中…’,
    })
wx.request({url: app.globalData.siteurlh5 + '/fileadd.php',data: {id:this.data.id,beizhu:this.data.beizhu,uid: wx.getStorageSync('uid'),token: wx.getStorageSync('token'),title: this.data.itemname,img: this.data.videoList1.concat(this.data.fileList1, this.data.imgList1)},header: {'content-type': 'application/x-www-form-urlencoded'},method: 'POST',success(res) {console.log(res, )if (res.data.bs == 'success') {wx.showToast({title: res.data.errmsg,duration: 2000,icon: 'success'})setTimeout(() => {wx.navigateBack({delta: 1,})}, 2000);} else if (res.data.bs == 'failed') {wx.showToast({title: res.data.errmsg,duration: 2000,icon: 'error'})} else if (res.data.bs == 'error') {wx.showToast({title: res.data.errmsg,duration: 2000,icon: 'error'})} else if (res.data.bs == 'guoqi') {wx.removeStorageSync('userInfo'); //清除缓存wx.removeStorageSync('uid')wx.removeStorageSync('token')wx.redirectTo({url: '../index/index',})}},fail(err) {console.log(err)wx},complete() {// wx.hideLoading()}
})

},

/**

  • 用户点击右上角分享
    */
    onShareAppMessage() {

}
})

相关文章:

腾讯云 小程序 SDK对象存储 COS使用记录,原生小程序写法。

最近做了一个项目&#xff0c;需求是上传文档&#xff0c;文档类型多种&#xff0c;图片&#xff0c;视频&#xff0c;文件&#xff0c;doc,xls,zip,txt 等等,而且文档类型可能是大文件&#xff0c;可能得上百兆&#xff0c;甚至超过1G。 腾讯云文档地址&#xff1a;https://c…...

【uniapp】本地资源图片无法通过 WXSS 获取,可以使用网络图片,或者 base64,或者使用image标签

uniapp开发 微信小程序 本地资源图片无法通过 WXSS 获取&#xff0c;可以使用网络图片&#xff0c;或者 base64&#xff0c;或者使用image标签。_uniapp 中的本地资源图片无法通过 wxss 获取,可以使用网络图片,或者 base64,或者_芒果大胖砸的博客-CSDN博客...

深入了解Spring Cloud中的分布式事务解决方案

引言 介绍分布式系统中事务管理的重要性&#xff0c;以及在云计算环境下分布式事务所面临的挑战。 传统事务和分布式事务 解释本地事务与分布式事务的区别&#xff0c;以及为什么在分布式环境中需要特殊的事务管理机制。 分布式事务的挑战 探讨在分布式系统中实现事务一致性所…...

安装compiler version 5

这个compiler version5 在我的资源里面可以免费下载&#xff1b; 另外这个东西还需要安装&#xff0c;安装教程在这里&#xff1a;Keil最新版保姆教程&#xff08;解决缺少V5编译器问题&#xff09; - 哔哩哔哩 (bilibili.com) 看吧安装好了year...

关闭vscode打开的本地服务器端口

vscode开了本地的一个端口“8443”当本地服务器端口&#xff0c;然后随手把VScode一关&#xff0c;后来继续做发现8443端口已经被占用了。   原来&#xff0c;即便关闭了编译器VScode&#xff0c;服务器依然是被node.exe运行着的。那这个端口怎么才能关掉呢&#xff1f;   …...

VUE3+Springboot实现SM2完整步骤

一.VUE3代码实现 1.安装依赖 npm install --save sm-crypto 2.导入sm2 const sm2 require(sm-crypto).sm2 3.定义公钥私钥 var privateKey "私钥";//解密使用 var publicKey "公钥";//加密使用 4.设置加密模式 //cipherMode [加密模式 C1C3C2:1,…...

CSS-背景属性篇

属性名&#xff1a;background-color 功能&#xff1a;设置背景颜色 属性值&#xff1a;符合CSS中颜色规范的值 默认背景颜色是 transparent body{ background-color: blue; } 属性名&#xff1a;background-image 功能&#xff1a;设置背景图片 属性值&#xff1a;url(图片的…...

KyLin离线安装OceanBase

去OceanBase下载若干文件 1 首先安装ob-deploy-2.3.1-2.el7.x86_64.rpm rpm -ivh ob-deploy-2.3.1-2.el7.x86_64.rpm# 运行此命令的时候他会报错 RPM should not be used directly install RPM packages, use Alien instead! 这个需要用Alien去转换为deb的包&#xff0c;不…...

插件预热 | 且看安全小白如何轻松利用Goby插件快速上分

001 前言 各位师傅们好&#xff0c;首先强调一遍我可没做坏事&#xff0c;我只是想学技术&#xff0c;我有什么坏心思呢 回到正题&#xff0c;作为一个初学者&#xff0c;我想和大家分享一下我是如何利用 Goby 进行刷分的经历。大家都知道&#xff0c;刚开始学习的时候&…...

pytorch下载离线包的网址

下载地址&#xff1a;https://download.pytorch.org/whl/torch_stable.html 安装GPU版本需要安装&#xff1a;torch、torchvision、 注意版本需要对应上 格式&#xff1a;适用cuda版本&#xff0c;torch版本 或者 orchvision版本&#xff0c;cp38就是适用python 3.8版本 下…...

【docker下安装jenkins】(一)

目的&#xff1a;在Linux操作系统&#xff08;x86_64)下&#xff0c;使用docker部署jenkins&#xff0c;python使用压缩包安装 安装jenkins的步骤 &#xff11;、编排jenkins的docker-compose.yml文件 说明&#xff1a;这里遇到部署jenkins后&#xff0c;占用内存8G,所以重新…...

【前端】必学知识ES6 1小时学会

1.ES6概述 2.let和const的认识 3.let、const、var的区别 4.模板字符串 5.函数默认参数 6.箭头函数【重点】 ​编辑7.对象初始化简写以及案例分析 【重点】 8.对象解构 8.对象传播操作符 9.对象传播操作符案例分析 ​编辑 10.数组Map 11.数组Reduce 12.NodeJS小结 …...

【学生成绩管理】数据库示例数据(MySQL代码)

【学生成绩管理】数据库示例数据&#xff08;MySQL代码&#xff09; 目录 【学生成绩管理】数据库示例数据&#xff08;MySQL代码&#xff09;一、创建数据库二、创建dept&#xff08;学院&#xff09;表1、创建表结构2、添加示例数据3、查看表中数据 三、创建stu&#xff08;学…...

【电子通识】什么是物料清单BOM(Bill of Material))

BOM (Bill of Materials)是我们常说的物料清单。BOM是制造业管理的重点之一&#xff0c;用于记载产品组成所需要的全部物料&#xff08;Items&#xff09;。物料需求的计算是从最终产品开始&#xff0c;层层往下推算出部件&#xff0c;组件&#xff0c;零件和原材料的需求量。这…...

接口自动化测试难点:数据库验证解决方案!

接口自动化中的数据库验证&#xff1a;确保数据的一致性和准确性 接口自动化测试是现代软件开发中不可或缺的一环&#xff0c;而数据库验证则是确保接口返回数据与数据库中的数据一致性的重要步骤。本文将介绍接口自动化中的数据库验证的原理、步骤以及示例代码&#xff0c;帮…...

淘宝、1688代购系统;微信代购小程序,代购系统源代码,PHP前端源码演示

电商价格数据监测接口、品牌商品控价接口、商品数据分析接口和比价搜索API接口都是非常实用的电商接口服务&#xff0c;下面我将为您详细介绍这些接口的用途和使用方式。 1.电商价格数据监测接口&#xff08;注册获取请求调用key&#xff09; taobao.item_get-获得淘宝商品详…...

LED驱动控制专用电路

一、基本概述 TM1628是一种带键盘扫描接口的LED&#xff08;发光二极管显示器&#xff09;驱动控制专用IC,内部集成有MCU 数 字接口、数据锁存器、LED 驱动、键盘扫描等电路。本产品质量可靠、稳定性好、抗干扰能力强。 主要适用于家电设备(智能热水器、微波炉、洗衣机、空调…...

为什么 Flink 抛弃了 Scala

曾经红遍一时的Scala 想当初Spark横空出世之后&#xff0c;Scala简直就是语言界的一颗璀璨新星&#xff0c;惹得大家纷纷侧目&#xff0c;连Kafka这类技术框架也选择用Scala语言进行开发重构。 可如今&#xff0c;Flink竟然公开宣布弃用Scala 在Flink1.18的官方文档里&#x…...

scala 实现表达式解析

表达式解析 import org.junit.Testimport scala.collection.mutableclass ExprTestCase {private val orderSource "source_1"private val saleChannel "saleChannel"val datas new mutable.HashMap[String, String]();// p1, source1, sale1, source…...

分布式事务seata的AT模式介绍

分布式事务seata的AT模式介绍 seata是阿里开源的一款分布式事务解决方案&#xff0c;致力于提供高性能和简单易用的分布式事务服务。Seata 将为用户提供了 AT、TCC、SAGA 和 XA 事务模式&#xff0c;本文主要介绍AT模式的使用。 seata安装 下载seata服务&#xff0c;官方地址…...

保姆级教程:用Wireshark抓包+rsyslogd -dn调试,5分钟定位你的日志转发故障

运维侦探实战&#xff1a;三大利器精准定位日志转发故障 日志系统是运维工程师的"眼睛"&#xff0c;但当这双眼睛突然失明时&#xff0c;如何快速恢复视力&#xff1f;想象一下凌晨三点&#xff0c;你被警报吵醒&#xff0c;发现关键业务日志全部失踪&#xff0c;而明…...

PreScan泊车模型里的超声波传感器:参数怎么调?避坑指南来了

PreScan泊车模型中的超声波传感器参数调优实战指南 泊车辅助系统作为自动驾驶技术中最先落地的功能之一&#xff0c;其仿真验证环节直接关系到实际应用的安全性和可靠性。在PreScan仿真环境中&#xff0c;超声波传感器的参数配置往往成为影响整个泊车模型表现的关键变量。许多工…...

别再为远程调试发愁了!用frp在CentOS7上搭建内网穿透,轻松访问本地WebSocket服务

开发者必备&#xff1a;基于frp的WebSocket服务远程调试全攻略 凌晨三点的咖啡杯旁&#xff0c;你盯着本地运行的WebSocket服务陷入沉思——如何让异地同事实时测试这个聊天应用&#xff1f;传统方案要么需要复杂的企业级VPN&#xff0c;要么面临NAT穿透的稳定性问题。本文将手…...

VideoSrt:5分钟搞定专业视频字幕的智能工具

VideoSrt&#xff1a;5分钟搞定专业视频字幕的智能工具 【免费下载链接】video-srt-windows 这是一个可以识别视频语音自动生成字幕SRT文件的开源 Windows-GUI 软件工具。 项目地址: https://gitcode.com/gh_mirrors/vi/video-srt-windows 还在为视频字幕制作耗费大量时…...

Docker 27跨架构镜像转换失效?3大隐性陷阱(QEMU崩溃、binfmt注册异常、manifest list校验失败)全解析(生产环境血泪复盘)

第一章&#xff1a;Docker 27跨架构镜像转换失效的典型现象与定位全景当使用 Docker 27&#xff08;特别是 27.0.0 版本&#xff09;执行 docker buildx build --platform 构建多架构镜像时&#xff0c;开发者常遭遇构建成功但运行时崩溃、QEMU 模拟失败或 exec format error 等…...

WinUtil:一站式Windows系统优化与软件管理解决方案

WinUtil&#xff1a;一站式Windows系统优化与软件管理解决方案 【免费下载链接】winutil Chris Titus Techs Windows Utility - Install Programs, Tweaks, Fixes, and Updates 项目地址: https://gitcode.com/GitHub_Trending/wi/winutil Windows系统维护是每个技术用户…...

安卓15分享Wi-Fi二维码能换颜色吗?自定义颜色方法

在安卓15系统中&#xff0c;通过“附近分享”或“快速分享”功能来共享Wi-Fi密码变得非常方便&#xff0c;只需一个二维码就能让朋友轻松连接。系统生成的二维码界面通常会自动匹配你的手机主题色&#xff0c;看起来挺美观。但很多用户想知道&#xff1a;我能自己定义这个二维码…...

代码随想录—day11—栈与队列(part2)

题例:150. 逆波兰表达式求值 - 力扣&#xff08;LeetCode&#xff09; 给你一个字符串数组 tokens &#xff0c;表示一个根据 逆波兰表示法 表示的算术表达式。 请你计算该表达式。返回一个表示表达式值的整数。 注意&#xff1a; 有效的算符为 、-、* 和 / 。每个操作数&a…...

PICO4系统升级到5.7.1后,MRTK3手部模型异常?手把手教你修复关节翻转与射线问题

PICO4系统升级5.7.1后MRTK3手部模型异常修复指南 当PICO4设备系统升级到5.7.1版本后&#xff0c;许多开发者在使用MRTK3进行混合现实开发时遇到了手部模型异常的问题。这些问题包括手部模型位置翻转、关节扭曲以及左手射线方向错误等。本文将深入分析问题根源&#xff0c;并提供…...

共享汽车功率管理器件选型实战:空间、效率与可靠性的平衡之道

在共享汽车朝着电动化、智能化与高利用率不断演进的今天&#xff0c;其内部的电子控制系统已不再是简单的功能单元&#xff0c;而是直接决定了车辆可用性、用户体验与运营成本的核心。一套设计精良的功率管理方案&#xff0c;是共享汽车实现稳定供电、智能控制与长久耐用寿命的…...