mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 10:46:00 +00:00
perspective image display
This commit is contained in:
@@ -46,6 +46,9 @@ export function stringifyCellValue(value) {
|
||||
}
|
||||
|
||||
export function safeJsonParse(json, defaultValue?, logError = false) {
|
||||
if (_isArray(json) || _isPlainObject(json)) {
|
||||
return json;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(json);
|
||||
} catch (err) {
|
||||
@@ -93,3 +96,22 @@ export function isWktGeometry(s) {
|
||||
/^POINT\s*\(|^LINESTRING\s*\(|^POLYGON\s*\(|^MULTIPOINT\s*\(|^MULTILINESTRING\s*\(|^MULTIPOLYGON\s*\(|^GEOMCOLLECTION\s*\(|^GEOMETRYCOLLECTION\s*\(/
|
||||
);
|
||||
}
|
||||
|
||||
export function arrayBufferToBase64(buffer) {
|
||||
var binary = '';
|
||||
var bytes = [].slice.call(new Uint8Array(buffer));
|
||||
bytes.forEach(b => (binary += String.fromCharCode(b)));
|
||||
return btoa(binary);
|
||||
}
|
||||
|
||||
export function getAsImageSrc(obj) {
|
||||
if (obj?.type == 'Buffer' && _isArray(obj?.data)) {
|
||||
return `data:image/png;base64, ${arrayBufferToBase64(obj?.data)}`;
|
||||
}
|
||||
|
||||
if (_isString(obj) && (obj.startsWith('http://') || obj.startsWith('https://'))) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user