function Storage(Fevent) { const indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; if ( indexedDB === undefined ) { console.warn( 'Storage: IndexedDB not available.' ); return { init: function () {}, get: function () {}, set: function () {}, clear: function () {} }; } const name = 'threejs-editor'; const version = 1; let database; const requestx = indexedDB.open( name, version ); // 打开数据库 const request = indexedDB.open( name, version ); var db; request.onsuccess = function(event) { db = event.target.result; // 存储数据 var transaction = db.transaction( [ 'states' ], 'readwrite' ); var store = transaction.objectStore('states'); // store.add({ id: 1, data: 'some data' }); // 检索数据 var getRequest = store.get(window.parkId); getRequest.onsuccess = function(event) { var result = event.target.result; Fevent(result) }; }; // // // request.onupgradeneeded = function ( event ) { // // const db = event.target.result; // // if ( db.objectStoreNames.contains( 'states' ) === false ) { // // db.createObjectStore( 'states' ); // // } // // }; // // request.onsuccess = function ( event ) { // // database = event.target.result; // // callback(); // // }; // // request.onerror = function ( event ) { // // console.error( 'IndexedDB', event ); // // }; // // // const transaction = database.transaction( [ 'states' ], 'readwrite' ); // const objectStore = transaction.objectStore( 'states' ); // const request = objectStore.get( 0 ); // request.onsuccess = function ( event ) { // // callback( event.target.result ); // // }; // return ; } export { Storage };