Skip to content

Commit

Permalink
feat: 查询数据库防抖
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Apr 7, 2024
1 parent 4942ea1 commit 09304d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion webview/src/apps/wcferry/dbquery.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</select>
</div>
<div class="col text-end">
<button class="btn btn-primary" (click)="getDbTableRecords()" [disabled]="!tableName">查询</button>
<button class="btn btn-primary" (click)="getDbTableRecords()" [disabled]="!tableName || loading">查询</button>
</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions webview/src/apps/wcferry/dbquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class WcferryDbqueryComponent {
public sql = 'SELECT * FROM {TABLE} LIMIT 10';
public result = '';

public loading = false;

constructor() {
this.getDbList();
}
Expand All @@ -36,10 +38,13 @@ export class WcferryDbqueryComponent {
}

public getDbTableRecords() {
this.loading = true;
const db = this.dbName;
const sql = this.sql.replace(/\{TABLE\}/, this.tableName);
return WrestApi.dbQuerySql({ db, sql }).then((data) => {
this.result = JSON.stringify(data, null, 4);
}).finally(() => {
this.loading = false;
});
}

Expand Down

0 comments on commit 09304d8

Please sign in to comment.