mirror of
https://github.com/Lissy93/dashy.git
synced 2025-12-06 16:43:13 +01:00
Add opening method option for custom search widget.
This commit is contained in:
parent
667feb4d10
commit
1b77917335
1 changed files with 22 additions and 3 deletions
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button
|
<button
|
||||||
v-for="(engine, key) in engines" :key="key"
|
v-for="(engine, key) in engines" :key="key"
|
||||||
v-on:click="search(engine)">
|
v-on:click="search(engine, openingMethod)">
|
||||||
{{ engine.title }}
|
{{ engine.title }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -15,7 +15,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import router from '@/router';
|
||||||
import WidgetMixin from '@/mixins/WidgetMixin';
|
import WidgetMixin from '@/mixins/WidgetMixin';
|
||||||
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [WidgetMixin],
|
mixins: [WidgetMixin],
|
||||||
|
|
@ -35,11 +37,28 @@ export default {
|
||||||
defaultEngine() {
|
defaultEngine() {
|
||||||
return this.engines[0];
|
return this.engines[0];
|
||||||
},
|
},
|
||||||
|
openingMethod() {
|
||||||
|
return this.options.openingMethod || '';
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
search(engine) {
|
search(engine, openingMethod) {
|
||||||
if (engine !== undefined && this.query !== '') {
|
if (engine !== undefined && this.query !== '') {
|
||||||
window.open(engine.url + this.query, '_blank');
|
const url = engine.url + this.query;
|
||||||
|
switch (openingMethod) {
|
||||||
|
case 'newtab':
|
||||||
|
window.open(url, '_blank');
|
||||||
|
break;
|
||||||
|
case 'sametab':
|
||||||
|
window.open(url, '_self');
|
||||||
|
break;
|
||||||
|
case 'workspace':
|
||||||
|
router.push({ name: 'workspace', query: { url } });
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrorHandler(`Unknown opening method: ${openingMethod}`);
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue