mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 10:08:52 +08:00
remove saveDbName method (refactor)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sqliteviz",
|
||||
"version": "0.8.0",
|
||||
"version": "1.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -78,8 +78,8 @@ export default {
|
||||
loadDb () {
|
||||
this.state = 'drop'
|
||||
return Promise.all([this.$db.loadDb(this.$refs.file.files[0]), this.animationPromise])
|
||||
.then(([schema]) => {
|
||||
this.$store.commit('saveSchema', schema)
|
||||
.then(([{ dbName, schema }]) => {
|
||||
this.$store.commit('saveSchema', { dbName, schema })
|
||||
if (this.$route.path !== '/editor') {
|
||||
this.$router.push('/editor')
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ export default {
|
||||
methods: {
|
||||
changeDb () {
|
||||
this.$db.loadDb(this.$refs.dbfile.files[0])
|
||||
.then((schema) => {
|
||||
this.$store.commit('saveSchema', schema)
|
||||
.then(({ dbName, schema }) => {
|
||||
this.$store.commit('saveSchema', { dbName, schema })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import store from '@/store'
|
||||
const worker = new Worker('js/worker.sql-wasm.js')
|
||||
|
||||
export default {
|
||||
loadDb (file) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const dbName = file.name
|
||||
store.commit('saveDbName', dbName)
|
||||
const f = file
|
||||
const r = new FileReader()
|
||||
r.onload = () => {
|
||||
@@ -18,7 +15,10 @@ export default {
|
||||
|
||||
// on 'action: exec' completed
|
||||
worker.onmessage = event => {
|
||||
resolve(event.data.results[0].values)
|
||||
resolve({
|
||||
dbName: file.name,
|
||||
schema: event.data.results[0].values
|
||||
})
|
||||
}
|
||||
worker.postMessage({ action: 'exec', sql: getSchemaSql })
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@ export default new Vuex.Store({
|
||||
predefinedQueries: []
|
||||
},
|
||||
mutations: {
|
||||
saveSchema (state, schema) {
|
||||
saveSchema (state, { dbName, schema }) {
|
||||
state.dbName = dbName
|
||||
const parsedSchema = []
|
||||
schema.forEach(item => {
|
||||
parsedSchema.push({
|
||||
@@ -66,9 +67,6 @@ export default new Vuex.Store({
|
||||
saveDbFile (state, file) {
|
||||
state.dbFile = file
|
||||
},
|
||||
saveDbName (state, name) {
|
||||
state.dbName = name
|
||||
},
|
||||
addTab (state, tab) {
|
||||
// add new tab only if was not already opened
|
||||
if (!state.tabs.some(openedTab => openedTab.id === tab.id)) {
|
||||
|
||||
Reference in New Issue
Block a user