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

怎么用b2b网站做排名搜索引擎营销名词解释

怎么用b2b网站做排名,搜索引擎营销名词解释,wordpress 读取菜单,连云港做鸭网站前言 由于开发3D可视化项目经常用到模型,而一个模型通常是几m甚至是几十m的大小对于一般的服务器来讲加载速度真的十分的慢,为了解决这个加载速度的问题,我想到了几个本地存储的。 首先是cookie,cookie肯定是不行的,因为最多以只…

前言
由于开发3D可视化项目经常用到模型,而一个模型通常是几m甚至是几十m的大小对于一般的服务器来讲加载速度真的十分的慢,为了解决这个加载速度的问题,我想到了几个本地存储的。

首先是cookie,cookie肯定是不行的,因为最多以只能存4k,

其次localStorage,最多能存5m(不是一个key的大小,是所有key的总大小最多加起来最多5m),相对于cookie已经打了很多了。但是当遇到大模型还是不够,实际开发中大部分模型都是10m-30m的。

经过网上的相关资料的搜索了解到了indexDB,indexD就正好合适了,因为我发现我常用的3d框架three.js他们也是使用indexDB去做存储,而且存储大小是250m以上(受计算机硬件和浏览器厂商的限制)。

一、直接上代码更看结果更直观

懒人直接看入门的全部代码

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><title>Title</title><link href="./favicon.png">
</head>
<body>
</body>
<script>let dbName = 'helloIndexDB', version = 1, storeName = 'helloStore'let indexedDB = window.indexedDBlet dbconst request = indexedDB.open(dbName, version)request.onsuccess = function(event) {db = event.target.result // 数据库对象console.log('数据库打开成功')}request.onerror = function(event) {console.log('数据库打开报错')}request.onupgradeneeded = function(event) {// 数据库创建或升级的时候会触发console.log('onupgradeneeded')db = event.target.result // 数据库对象let objectStoreif (!db.objectStoreNames.contains(storeName)) {objectStore = db.createObjectStore(storeName, { keyPath: 'id' }) // 创建表// objectStore.createIndex('name', 'name', { unique: true }) // 创建索引 可以让你搜索任意字段}}// 添加数据function addData(db, storeName, data) {let request = db.transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写").objectStore(storeName) // 仓库对象.add(data)request.onsuccess = function(event) {console.log('数据写入成功')}request.onerror = function(event) {console.log('数据写入失败')throw new Error(event.target.error)}}// 根据id获取数据function getDataByKey(db, storeName, key) {let transaction = db.transaction([storeName]) // 事务let objectStore = transaction.objectStore(storeName) // 仓库对象let request = objectStore.get(key)request.onerror = function(event) {console.log('事务失败')}request.onsuccess = function(event) {console.log('主键查询结果: ', request.result)}}// 根据id修改数function updateDB(db, storeName, data) {let request = db.transaction([storeName], 'readwrite') // 事务对象.objectStore(storeName) // 仓库对象.put(data)request.onsuccess = function() {console.log('数据更新成功')}request.onerror = function() {console.log('数据更新失败')}}// 根据id删除数据function deleteDB(db, storeName, id) {let request = db.transaction([storeName], 'readwrite').objectStore(storeName).delete(id)request.onsuccess = function() {console.log('数据删除成功')}request.onerror = function() {console.log('数据删除失败')}}// 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错setTimeout(() => {addData(db, storeName, {id: new Date().getTime(), // 必须且值唯一name: '张三',age: 18,desc: 'helloWord'})getDataByKey(db, storeName, 1638160036008)updateDB(db, storeName, {id: 1638164880484, desc: '修改的内容'})deleteDB(db, storeName, 1638164870439)}, 1000)</script>
</html>

第一步:准备环境和基本的html页面

 基本的html代码

​<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><title>Title</title>
</head>
<body>
</body>
<script></script>
</html>

第二步:打开数据库(如果没有自动创建)

  let dbName = 'helloIndexDB', version = 1, storeName = 'helloStore'let indexedDB = window.indexedDBlet dbconst request = indexedDB.open(dbName, version)request.onsuccess = function(event) {db = event.target.result // 数据库对象console.log('数据库打开成功')}request.onerror = function(event) {console.log('数据库打开报错')}request.onupgradeneeded = function(event) {// 数据库创建或升级的时候会触发console.log('onupgradeneeded')db = event.target.result // 数据库对象let objectStoreif (!db.objectStoreNames.contains(storeName)) {objectStore = db.createObjectStore(storeName, { keyPath: 'id' }) // 创建表// objectStore.createIndex('name', 'name', { unique: true }) // 创建索引 可以让你搜索任意字段}}

运行如上面的代码后打开控制台可以看到如下效果,数据库已经创建完成了,此时什么数据都没有

watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5reL6Zuo5LiA55u06LWwfg==,size_19,color_FFFFFF,t_70,g_se,x_16

第三步:存入一个helloWorld 

  // 添加数据function addData(db, storeName, data) {let request = db.transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写").objectStore(storeName) // 仓库对象.add(data)request.onsuccess = function(event) {console.log('数据写入成功')}request.onerror = function(event) {console.log('数据写入失败')throw new Error(event.target.error)}}// 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错setTimeout(() => {addData(db, storeName, {id: new Date().getTime(), // 必须且值唯一name: '张三',age: 18,desc: 'helloWord'})}, 1000)

刷新页面后可以看到如下结果,此时我这里已经存进去了,(我刷新了两次所以有两条数据)

watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5reL6Zuo5LiA55u06LWwfg==,size_20,color_FFFFFF,t_70,g_se,x_16

 第四步:封装删除,查询,修改方法并分别执行查看结果

 // 根据id获取数据function getDataByKey(db, storeName, key) {let transaction = db.transaction([storeName]) // 事务let objectStore = transaction.objectStore(storeName) // 仓库对象let request = objectStore.get(key)request.onerror = function(event) {console.log('事务失败')}request.onsuccess = function(event) {console.log('主键查询结果: ', request.result)}}// 根据id修改数function updateDB(db, storeName, data) {let request = db.transaction([storeName], 'readwrite') // 事务对象.objectStore(storeName) // 仓库对象.put(data)request.onsuccess = function() {console.log('数据更新成功')}request.onerror = function() {console.log('数据更新失败')}}// 根据id删除数据function deleteDB(db, storeName, id) {let request = db.transaction([storeName], 'readwrite').objectStore(storeName).delete(id)request.onsuccess = function() {console.log('数据删除成功')}request.onerror = function() {console.log('数据删除失败')}}// 由于打开indexDB是异步的加个定时器避免 db对象还没获取到值导致 报错setTimeout(() => {// addData(db, storeName, {//   id: new Date().getTime(), // 必须且值唯一//   name: '张三',//   age: 18,//   desc: 'helloWord'// })getDataByKey(db, storeName, 1638160036008)updateDB(db, storeName, {id: 1638164880484, desc: '修改的内容'})deleteDB(db, storeName, 1638164870439)}, 1000)

执行上面的代码后结果后,我这边的结果如下,

watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5reL6Zuo5LiA55u06LWwfg==,size_20,color_FFFFFF,t_70,g_se,x_16

 二、封装indexDB库,

第一步:封装类库

/*** 封装的方法以及用法* 打开数据库*/
export function openDB(dbName, storeName, version = 1) {return new Promise((resolve, reject) => {let indexedDB = window.indexedDBlet dbconst request = indexedDB.open(dbName, version)request.onsuccess = function(event) {db = event.target.result // 数据库对象resolve(db)}request.onerror = function(event) {reject(event)}request.onupgradeneeded = function(event) {// 数据库创建或升级的时候会触发console.log('onupgradeneeded')db = event.target.result // 数据库对象let objectStoreif (!db.objectStoreNames.contains(storeName)) {objectStore = db.createObjectStore(storeName, { keyPath: 'id' }) // 创建表// objectStore.createIndex('name', 'name', { unique: true }) // 创建索引 可以让你搜索任意字段}}})
}/*** 新增数据*/
export function addData(db, storeName, data) {return new Promise((resolve, reject) => {let request = db.transaction([storeName], 'readwrite') // 事务对象 指定表格名称和操作模式("只读"或"读写").objectStore(storeName) // 仓库对象.add(data)request.onsuccess = function(event) {resolve(event)}request.onerror = function(event) {throw new Error(event.target.error)reject(event)}})
}/*** 通过主键读取数据*/
export function getDataByKey(db, storeName, key) {return new Promise((resolve, reject) => {let transaction = db.transaction([storeName]) // 事务let objectStore = transaction.objectStore(storeName) // 仓库对象let request = objectStore.get(key)request.onerror = function(event) {reject(event)}request.onsuccess = function(event) {resolve(request.result)}})
}/*** 通过游标读取数据*/
export function cursorGetData(db, storeName) {let list = []let store = db.transaction(storeName, 'readwrite') // 事务.objectStore(storeName) // 仓库对象let request = store.openCursor() // 指针对象return new Promise((resolve, reject) => {request.onsuccess = function(e) {let cursor = e.target.resultif (cursor) {// 必须要检查list.push(cursor.value)cursor.continue() // 遍历了存储对象中的所有内容} else {resolve(list)}}request.onerror = function(e) {reject(e)}})
}/*** 通过索引读取数据*/
export function getDataByIndex(db, storeName, indexName, indexValue) {let store = db.transaction(storeName, 'readwrite').objectStore(storeName)let request = store.index(indexName).get(indexValue)return new Promise((resolve, reject) => {request.onerror = function(e) {reject(e)}request.onsuccess = function(e) {resolve(e.target.result)}})
}/*** 通过索引和游标查询记录*/
export function cursorGetDataByIndex(db, storeName, indexName, indexValue) {let list = []let store = db.transaction(storeName, 'readwrite').objectStore(storeName) // 仓库对象let request = store.index(indexName) // 索引对象.openCursor(IDBKeyRange.only(indexValue)) // 指针对象return new Promise((resolve, reject) => {request.onsuccess = function(e) {let cursor = e.target.resultif (cursor) {list.push(cursor.value)cursor.continue() // 遍历了存储对象中的所有内容} else {resolve(list)}}request.onerror = function(ev) {reject(ev)}})
}/*** 更新数据*/
export function updateDB(db, storeName, data) {let request = db.transaction([storeName], 'readwrite') // 事务对象.objectStore(storeName) // 仓库对象.put(data)return new Promise((resolve, reject) => {request.onsuccess = function(ev) {resolve(ev)}request.onerror = function(ev) {resolve(ev)}})
}/*** 删除数据*/
export function deleteDB(db, storeName, id) {let request = db.transaction([storeName], 'readwrite').objectStore(storeName).delete(id)return new Promise((resolve, reject) => {request.onsuccess = function(ev) {resolve(ev)}request.onerror = function(ev) {resolve(ev)}})
}/*** 删除数据库*/
export function deleteDBAll(dbName) {console.log(dbName)let deleteRequest = window.indexedDB.deleteDatabase(dbName)return new Promise((resolve, reject) => {deleteRequest.onerror = function(event) {console.log('删除失败')}deleteRequest.onsuccess = function(event) {console.log('删除成功')}})
}/*** 关闭数据库*/
export function closeDB(db) {db.close()console.log('数据库已关闭')
}export default {openDB,addData,getDataByKey,cursorGetData,getDataByIndex,cursorGetDataByIndex,updateDB,deleteDB,deleteDBAll,closeDB
}

第二步:使用类库,该库的使用方法如下

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><title>Title</title><link href="./favicon.png">
</head>
<body>
</body>注意要加 type="module"
<script type="module">
-->
<script type="module">import IndexDB from './IndexDB.js'(async function() {const dbName = 'myDB', storeName = 'db_1'const db = await IndexDB.openDB(dbName, storeName, 1)var data = await IndexDB.addData(db, storeName, {id: 111, // 必须且值唯一name: '张三',age: 18,desc: 'helloWord'})console.log(data)var data = await IndexDB.getDataByKey(db, storeName, 111)console.log(data)var data = await IndexDB.updateDB(db, storeName, { id: 111, desc: '修改的内容' })console.log(data)var data = await IndexDB.deleteDB(db, storeName, 111)console.log(data)})()
</script>
</html>

三、使用indexdb第三方类库indexdbwrapper(这种方式需要懂得使用打包工具开发不懂跳过)

/* 下载cnpm install --save indexdbwrapper
*/
// 引入
import IndexDBWrapper from 'indexdbwrapper'
// 使用
async function dbTest() {const dbName = 'dbName', storeName = 'storeName', version = 1const db = new IndexDBWrapper(dbName, version, {onupgradeneeded(event) {const db = event.target.result // 数据库对象let objectStoreif (!db.objectStoreNames.contains(storeName)) {objectStore = db.createObjectStore(storeName, { keyPath: 'id' }) // 创建表// objectStore.createIndex('createTime', 'createTime', { unique: false }) // 创建索引 可以让你搜索任意字段}}})await db.open()await db.add(storeName, { id: new Date().getTime(), updateTime: new Date().getTime() })console.log(await db.get(storeName, 1639015754840))console.log(await db.put(storeName, { id: 1639015754840, put: 'put2' }))console.log(await db.get(storeName, 1639015754840))console.log(await db.delete(storeName, 1639015754840))// console.log(await db.clear(storeName))
}
dbTest()


文章转载自:
http://dinncophotoconductive.stkw.cn
http://dinncofragmentize.stkw.cn
http://dinncosomnambulance.stkw.cn
http://dinncomagnet.stkw.cn
http://dinnconecktie.stkw.cn
http://dinncomountaintop.stkw.cn
http://dinncosubcutaneous.stkw.cn
http://dinncosafflower.stkw.cn
http://dinncobimetal.stkw.cn
http://dinncoundersanded.stkw.cn
http://dinncoforewoman.stkw.cn
http://dinncochucker.stkw.cn
http://dinncopeppercorn.stkw.cn
http://dinncoshortdated.stkw.cn
http://dinncogushing.stkw.cn
http://dinncowidgeon.stkw.cn
http://dinncoglass.stkw.cn
http://dinncohidropoietic.stkw.cn
http://dinncooptionee.stkw.cn
http://dinncostaggerbush.stkw.cn
http://dinncowhiffle.stkw.cn
http://dinncoreaper.stkw.cn
http://dinncocenterboard.stkw.cn
http://dinncocoherer.stkw.cn
http://dinncopalynomorph.stkw.cn
http://dinncoobsequence.stkw.cn
http://dinncointerlink.stkw.cn
http://dinncorabbanist.stkw.cn
http://dinncoshinbone.stkw.cn
http://dinncotoluidine.stkw.cn
http://dinncomaryknoller.stkw.cn
http://dinncobawdy.stkw.cn
http://dinncolonghair.stkw.cn
http://dinncoultracentrifugal.stkw.cn
http://dinncogoonda.stkw.cn
http://dinncoovenwood.stkw.cn
http://dinncoscentometer.stkw.cn
http://dinncochyliferous.stkw.cn
http://dinncoroxana.stkw.cn
http://dinncoozonic.stkw.cn
http://dinncobuckeye.stkw.cn
http://dinncotaintless.stkw.cn
http://dinncorenationalize.stkw.cn
http://dinncomoniker.stkw.cn
http://dinncokirlian.stkw.cn
http://dinncophilanthropist.stkw.cn
http://dinncobrusque.stkw.cn
http://dinncopraisable.stkw.cn
http://dinncohoveller.stkw.cn
http://dinncoelectrosleep.stkw.cn
http://dinncoteletransportation.stkw.cn
http://dinncovandalic.stkw.cn
http://dinnconephology.stkw.cn
http://dinncodemagog.stkw.cn
http://dinncopolychrome.stkw.cn
http://dinncohighgate.stkw.cn
http://dinncouneducated.stkw.cn
http://dinncohundredth.stkw.cn
http://dinncochargehand.stkw.cn
http://dinncolacw.stkw.cn
http://dinncowideband.stkw.cn
http://dinncocholesterolemia.stkw.cn
http://dinncopatentee.stkw.cn
http://dinncovirus.stkw.cn
http://dinncoadoze.stkw.cn
http://dinncohydrotechny.stkw.cn
http://dinncobarometric.stkw.cn
http://dinncovociferant.stkw.cn
http://dinncoloth.stkw.cn
http://dinncomopstick.stkw.cn
http://dinncoreplicon.stkw.cn
http://dinncostraitness.stkw.cn
http://dinncospacemark.stkw.cn
http://dinncobuluwayo.stkw.cn
http://dinncotenzon.stkw.cn
http://dinncosinapism.stkw.cn
http://dinncozmodem.stkw.cn
http://dinncoodbc.stkw.cn
http://dinncogone.stkw.cn
http://dinncoporn.stkw.cn
http://dinncomoisty.stkw.cn
http://dinncorensselaerite.stkw.cn
http://dinncointentionally.stkw.cn
http://dinncogesellschaft.stkw.cn
http://dinncobechic.stkw.cn
http://dinncomatchbook.stkw.cn
http://dinncofrenchify.stkw.cn
http://dinncoshucks.stkw.cn
http://dinncomesserschmitt.stkw.cn
http://dinncoexpectorant.stkw.cn
http://dinncointermezzo.stkw.cn
http://dinnconeurological.stkw.cn
http://dinncohant.stkw.cn
http://dinncoectoenzym.stkw.cn
http://dinncohypnopedia.stkw.cn
http://dinncocymbate.stkw.cn
http://dinncosudra.stkw.cn
http://dinncoparticle.stkw.cn
http://dinncoazonic.stkw.cn
http://dinncochihuahua.stkw.cn
http://www.dinnco.com/news/91264.html

相关文章:

  • 网站式小程序手机百度高级搜索入口
  • 做网站是用wordpress还是DW百度号码认证平台首页
  • 三木做网站东莞网络营销推广公司
  • 网站代理备案南京seo网站优化
  • ps如何做网站专题企业互联网推广
  • 北京市住房和城乡建设委员会seo网站建设是什么意思
  • 王爷不要漫画seo核心技术排名
  • 创办一个网站多少钱北京网站建设公司哪家好
  • 有效的网站需要做到什么意思四川seo技术培训
  • 环保主题静态网站模板下载湖南企业竞价优化首选
  • 响应式布局css哈尔滨百度搜索排名优化
  • b2b网站案例深圳全网信息流推广公司
  • 网站用户体验分析怎么做武汉seo优化分析
  • 昆明最新消息今天网站用户体验优化
  • 新云网站模板关键词竞价广告
  • 4a级旅游网站建设的要求重庆seo整站优化外包服务
  • java php 网站建设苏州seo培训
  • 南宁庆云网站建设肇庆seo按天计费
  • 济南市建设信用网站玉溪seo
  • 子网站怎么建设seo网址大全
  • 把自己做的动画传到哪个网站上百度云登录入口
  • 南昌做公司网站哪家好如何去除痘痘有效果
  • 郑州市政府官网安阳seo
  • 织梦网站模板陶瓷重庆seo推广公司
  • 网站文件夹没有权限设置seo牛人
  • 在线网页代理访问标题优化方法
  • 一个网站如何做盈利网络科技公司网站建设
  • 哈尔滨网站建设如何做网站seo排名优化
  • 德州 网站建设百度大数据预测平台
  • wordpress防镜像排名轻松seo 网站推广