使用a标签的 click 事件以及 URL.createObjectURL 方法
适合小文件的下载(无后端)
const buffer = new Float32Array([1, 2, 3, 4, 5]) // 创建一个类型数组,大小为 20 bytes
// 创建 blob 对象,第一个参数可以放置多个变量,这里放一个就好了
const blob = new Blob([buffer], {
type: "application/octet-stream"| with temp_result as ( | |
| select st_point(1, 2) as test_point | |
| ) | |
| select st_asgeojson(test_point) as final_result from temp_result; |
| uniform sampler2D Tex; | |
| const float size = 0.5; | |
| void main(void) | |
| { | |
| vec2 realSize = vec2(textureSize(Tex, 0)); | |
| float ratio = (realSize.x > realSize.y) ? realSize.y/realSize.x : realSize.x/realSize.y; | |
| vec2 texSize = vec2(512., 512.); | |
| vec2 xy = gl_FragCoord.xy; |
| import { Color, defined, Event, Material, Property } from 'cesium' | |
| const PolylineTrailLinkType = 'PolylineTrailLink' | |
| const PolylineTrailLinkSource = /* glsl */` | |
| czm_material czm_getMaterial(czm_materialInput materialInput) | |
| { | |
| czm_material material = czm_getDefaultMaterial(materialInput); | |
| vec2 st = materialInput.st; |
| <button id="btn">ClickMe</button> | |
| <script> | |
| const btn = document.getElementById('btn') | |
| let fileHandle | |
| btn.addEventListener('click', async () => { | |
| [fileHandle] = await window.showOpenFilePicker() | |
| const file = await fileHandle.getFile() | |
| const contents = await file.text() | |
| console.log(contents) | |
| }) |
| function main() { | |
| let last = 0 | |
| // 上次渲染的值(此处初始化为一个整数) | |
| let lastState = Math.floor(Math.random() * 10) | |
| const canWeRender = function() { | |
| // 这次渲染的值 | |
| const currentState = Math.floor(Math.random() * 10) | |
| // 比较二者是否一致,如果一致,则false,否则true | |
| if (currentState === lastState) { | |
| console.log("lastState eq. currentState. Will not render.") |
| function friendlyFileSize(sizeInBytes) { | |
| if(sizeInBytes < 1024) { | |
| return `${sizeInBytes} Bytes`; | |
| } else if(sizeInBytes >= 1024 && sizeInBytes < 1048576) { | |
| return `${(sizeInBytes/1024).toFixed(2)} KB`; | |
| } else if(sizeInBytes >= 1048576) { | |
| return `${(sizeInBytes/1048576).toFixed(2)} MB`; | |
| } | |
| } |
| import localForage from 'localforage' | |
| // 创建仓库对象,并创建名为 “test” 的 indexeddb 以及 名为 “testidb” 的表 | |
| const store = localForage.createInstance({ | |
| driver: localForage.INDEXEDDB, | |
| name: "test", | |
| storeName: "testidb" | |
| }) | |
| // 设置 key-value |
| import Matrix2 from '../core/mat2.js' | |
| import Matrix3, { transpose, multiply, } from '../core/mat3.js' | |
| /** | |
| * 雅可比迭代法求解实对称矩阵的特征向量、特征值 | |
| * @param {Matrix2 | Matrix3} matrix 二维数组,当前支持二维、三维迭代求解 | |
| * @returns {Object} 返回一个对象 obj, obj.eigenVectors 是特征向量(二维数组),obj.eigenValues 是特征值(一维数组) | |
| */ | |
| function jacobi(matrix) { | |
| const length = matrix.length === undefined ? matrix.dimensions : matrix.length |
| /** | |
| * 将矩阵(二维数组形式)转置的高效方法 | |
| * @param {Array[][]} arr 二维数组,子数组中元素个数应一致 | |
| */ | |
| export function transpose(arr) { | |
| return arr[0].map((_, i) => arr.map(row => row[i])) | |
| } |