|
@@ -3,14 +3,14 @@
|
|
<magic-input v-model:value="keyword" :placeholder="$i('message.searchText')" />
|
|
<magic-input v-model:value="keyword" :placeholder="$i('message.searchText')" />
|
|
<template v-if="results.length >0">
|
|
<template v-if="results.length >0">
|
|
<div class="magic-search-result">
|
|
<div class="magic-search-result">
|
|
- <div v-for="(item, key) in results" :key="key" class="magic-search-result-item" :class="{ selected: selectedItem === item}" @click="onClick(item)">
|
|
|
|
|
|
+ <div v-for="(item, key) in results" :key="key" class="magic-search-result-item" :class="{ selected: selectedItem === item}" @click="onClick(item)" @dblclick="onClick(item, true)">
|
|
<div class="label" v-html="item.text"></div>
|
|
<div class="label" v-html="item.text"></div>
|
|
- <div class="name">{{ item.name }}</div>
|
|
|
|
|
|
+ <div class="name"><magic-text-icon :icon="item.icon" />{{ item.name }}</div>
|
|
<div class="line" v-text="item.line"></div>
|
|
<div class="line" v-text="item.line"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
- <div class="display-text">{{displayText}}</div>
|
|
|
|
- <magic-monaco-editor readonly :value="selectedItem.script" language="magicscript" style="width: 100%; height:300px" :matches="keyword"></magic-monaco-editor>
|
|
|
|
|
|
+ <div class="display-text"><magic-text-icon :icon="selectedItem.icon" />{{displayText}}</div>
|
|
|
|
+ <magic-monaco-editor readonly :value="selectedItem.script" :language="selectedItem.language" style="width: 100%; height:300px" :matches="keyword"></magic-monaco-editor>
|
|
</template>
|
|
</template>
|
|
</magic-dialog>
|
|
</magic-dialog>
|
|
</template>
|
|
</template>
|
|
@@ -36,13 +36,15 @@ const fetchScript = item => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-const onClick = item => {
|
|
|
|
|
|
+const onClick = (item, open) => {
|
|
selectedItem.value = item
|
|
selectedItem.value = item
|
|
fetchScript(item)
|
|
fetchScript(item)
|
|
- bus.$emit(Message.OPEN_WITH_ID, item.id)
|
|
|
|
- show.value = false
|
|
|
|
- results.value = []
|
|
|
|
- keyword.value = ''
|
|
|
|
|
|
+ if(open) {
|
|
|
|
+ bus.$emit(Message.OPEN_WITH_ID, item.id)
|
|
|
|
+ show.value = false
|
|
|
|
+ results.value = []
|
|
|
|
+ keyword.value = ''
|
|
|
|
+ }
|
|
}
|
|
}
|
|
bus.$on(Message.DO_SEARCH, () => {
|
|
bus.$on(Message.DO_SEARCH, () => {
|
|
results.value = []
|
|
results.value = []
|
|
@@ -122,17 +124,19 @@ watch(keyword, (val) => {
|
|
timer = setTimeout(()=>{
|
|
timer = setTimeout(()=>{
|
|
request.send('/search', { keyword: text} ,{ method: 'POST'}).success(async data => {
|
|
request.send('/search', { keyword: text} ,{ method: 'POST'}).success(async data => {
|
|
const list = []
|
|
const list = []
|
|
-
|
|
|
|
for (let index = 0; index < data.length; index++) {
|
|
for (let index = 0; index < data.length; index++) {
|
|
const item = data[index];
|
|
const item = data[index];
|
|
const find = findResource(item.id)
|
|
const find = findResource(item.id)
|
|
const config = services[find.type]
|
|
const config = services[find.type]
|
|
- const tokenizer = await TokenizationRegistry.getPromise(config.language || 'magicscript')
|
|
|
|
|
|
+ const language = config.language || 'magicscript'
|
|
|
|
+ const tokenizer = await TokenizationRegistry.getPromise(language)
|
|
list.push({
|
|
list.push({
|
|
...item,
|
|
...item,
|
|
|
|
+ icon: config.getIcon(find.item),
|
|
text: replaceKeywords(await tokenizeToString(item.text, tokenizer), text),
|
|
text: replaceKeywords(await tokenizeToString(item.text, tokenizer), text),
|
|
name: find && find.name || 'unknown',
|
|
name: find && find.name || 'unknown',
|
|
- script: ''
|
|
|
|
|
|
+ script: '',
|
|
|
|
+ language
|
|
})
|
|
})
|
|
}
|
|
}
|
|
if(list.length > 0){
|
|
if(list.length > 0){
|
|
@@ -178,7 +182,6 @@ watch(keyword, (val) => {
|
|
}
|
|
}
|
|
|
|
|
|
.display-text {
|
|
.display-text {
|
|
- padding: 0 10px;
|
|
|
|
height: 30px;
|
|
height: 30px;
|
|
line-height: 30px;
|
|
line-height: 30px;
|
|
border-top: 1px solid var(--main-border-color);
|
|
border-top: 1px solid var(--main-border-color);
|