mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 11:36:01 +00:00
SYNC: Merge branch 'feature/backup-restore'
This commit is contained in:
25
packages/web/src/utility/openWebFile.ts
Normal file
25
packages/web/src/utility/openWebFile.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import newQuery from '../query/newQuery';
|
||||
import _ from 'lodash';
|
||||
|
||||
export function canOpenByWeb(file, extensions) {
|
||||
if (!file) return false;
|
||||
const nameLower = file.toLowerCase();
|
||||
if (nameLower.endsWith('.sql')) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function openWebFileCore(file, extensions) {
|
||||
const nameLower = file.path.toLowerCase();
|
||||
|
||||
if (nameLower.endsWith('.sql')) {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
newQuery({
|
||||
initialData: e.target.result,
|
||||
});
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user