mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
add export to file feature
This commit is contained in:
@@ -38,7 +38,7 @@
|
|||||||
<div class="icons-container">
|
<div class="icons-container">
|
||||||
<rename-icon @click="showRenameDialog(index)" />
|
<rename-icon @click="showRenameDialog(index)" />
|
||||||
<copy-icon @click="duplicateQuery(index)"/>
|
<copy-icon @click="duplicateQuery(index)"/>
|
||||||
<export-icon />
|
<export-icon @click="exportQuery(index)"/>
|
||||||
<delete-icon @click="showDeleteDialog(index)"/>
|
<delete-icon @click="showDeleteDialog(index)"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -92,6 +92,7 @@
|
|||||||
<button class="primary" @click="deleteQuery">Delete</button>
|
<button class="primary" @click="deleteQuery">Delete</button>
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</modal>
|
||||||
|
<a ref="downloader" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -200,6 +201,20 @@ export default {
|
|||||||
findTabIndex (id) {
|
findTabIndex (id) {
|
||||||
return this.$store.state.tabs.findIndex(tab => tab.id === id)
|
return this.$store.state.tabs.findIndex(tab => tab.id === id)
|
||||||
},
|
},
|
||||||
|
exportQuery (index) {
|
||||||
|
this.currentQueryIndex = index
|
||||||
|
const downloader = this.$refs.downloader
|
||||||
|
const currentQuery = JSON.parse(JSON.stringify(this.queries[this.currentQueryIndex]))
|
||||||
|
delete currentQuery.id
|
||||||
|
delete currentQuery.createdAt
|
||||||
|
const json = JSON.stringify(currentQuery)
|
||||||
|
const blob = new Blob([json], { type: 'octet/stream' })
|
||||||
|
const url = window.URL.createObjectURL(blob)
|
||||||
|
downloader.href = url
|
||||||
|
downloader.download = `${currentQuery.name}.json`
|
||||||
|
downloader.click()
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
},
|
||||||
saveQueriesInLocalStorage () {
|
saveQueriesInLocalStorage () {
|
||||||
localStorage.setItem('myQueries', JSON.stringify(this.queries))
|
localStorage.setItem('myQueries', JSON.stringify(this.queries))
|
||||||
}
|
}
|
||||||
@@ -277,4 +292,7 @@ tbody tr:hover .icons-container {
|
|||||||
.dialog input {
|
.dialog input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user