Skip to content

Commit 8e76570

Browse files
committed
history added based on boredcity's pr
1 parent 4742d74 commit 8e76570

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

electron_app/package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

electron_app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"electron-localshortcut": "^3.2.1",
3232
"electron-notarize": "^1.2.1",
3333
"electron-settings": "^4.0.2",
34+
"fuse.js": "^6.6.2",
3435
"javascript-time-ago": "^2.3.13",
3536
"nsfwjs": "^2.4.2",
3637
"konva": "^8.3.13",

electron_app/src/components/History.vue

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
@import '../assets/css/theme.css';
22
<template>
33
<div class="animatable_content_box ">
4+
5+
<b-form-input
6+
onkeypress="return event.keyCode != 13;"
7+
size="sm"
8+
placeholder="Search by prompt text"
9+
v-model="searchText"
10+
autofocus
11+
debounce="200"
12+
style="max-width: 240px; float: left; margin-right: 30px;"
13+
id="searchText"
14+
/>
15+
416
<div @click="toggle_order()" style="float:right; margin-bottom: 20px;" class="l_button">
517
{{this.app_state.show_history_in_oldest_first ? "Oldest": "Newest"}} First
618
</div>
@@ -56,6 +68,7 @@ import ImageItem from '../components/ImageItem.vue'
5668
import {share_on_arthub} from '../utils.js'
5769
5870
import Vue from 'vue'
71+
import Fuse from 'fuse.js'
5972
6073
export default {
6174
name: 'History',
@@ -69,7 +82,9 @@ export default {
6982
7083
},
7184
data() {
72-
return {};
85+
return {
86+
searchText: ''
87+
};
7388
},
7489
methods: {
7590
delete_hist(k){
@@ -78,7 +93,20 @@ export default {
7893
7994
get_history() {
8095
let history = Object.values(this.app_state.app_data.history);
81-
return this.app_state.show_history_in_oldest_first ? history : history.reverse();
96+
const that = this;
97+
const list = this.app_state.show_history_in_oldest_first ? history : history.reverse();
98+
99+
if (that.searchText.trim() === '') {
100+
return list;
101+
}
102+
103+
const fuse = new Fuse(list, {
104+
keys: ['prompt'],
105+
useExtendedSearch: true,
106+
});
107+
108+
return fuse.search(that.searchText).map(r => r.item);
109+
82110
},
83111
84112
toggle_order() {

0 commit comments

Comments
 (0)