feature: Support snippet quote

This commit is contained in:
qianmoQ 2022-10-27 00:37:08 +08:00
parent eaf63d3e69
commit 7ac6bb01f4
5 changed files with 46 additions and 10 deletions

View File

@ -36,5 +36,6 @@ export default {
format: 'Format',
snippet: 'Snippet',
submit: 'Submit',
updateTime: 'Update Time'
updateTime: 'Update Time',
quote: 'Quote'
}

View File

@ -36,5 +36,6 @@ export default {
format: '格式化',
snippet: '片段',
submit: '提交',
updateTime: "更新时间"
updateTime: '更新时间',
quote: '引用'
}

View File

@ -46,6 +46,7 @@ const routes: Array<RouteRecordRaw> = [
},
children: [
{
name: 'ConsoleIndex',
path: "index",
component: () => import("../views/pages/console/ConsoleOnline.vue")
}

View File

@ -16,14 +16,18 @@
<eye-outlined/>
</a-tooltip>
</a-button>
<a-tooltip>
<template #title>{{ $t('common.modify') }}</template>
<a-button type="primary" shape="circle" size="small" :disabled="currentUserId !== record.user.id" @click="handlerCreateOrUpdate(record.id)">
<template #icon>
<edit-outlined/>
</template>
</a-button>
</a-tooltip>
<a-button type="primary" shape="circle" size="small" :disabled="currentUserId !== record.user.id" @click="handlerCreateOrUpdate(record.id)">
<a-tooltip>
<template #title>{{ $t('common.modify') }}</template>
<edit-outlined/>
</a-tooltip>
</a-button>
<a-button shape="circle" size="small" @click="handlerGoConsoleIndex(record.id)">
<a-tooltip>
<template #title>{{ $t('common.quote') }}</template>
<aim-outlined/>
</a-tooltip>
</a-button>
<a-popconfirm title="Are you sure delete?" ok-text="Yes" cancel-text="No" :disabled="currentUserId !== record.user.id"
@confirm="handlerDeleteRecord(record.id)">
<a-tooltip>
@ -58,6 +62,7 @@ import {useI18n} from 'vue-i18n';
import Common from "@/common/Common";
import {createHeaders} from "@/views/pages/admin/snippet/SnippetGenerate";
import {SnippetService} from "@/services/SnippetService";
import router from "@/router";
export default defineComponent({
name: "SnippetConsoleView",
@ -148,6 +153,10 @@ export default defineComponent({
this.visibleSnippetInfo = false;
this.applyId = 0;
this.handlerInitialize(this.pagination.current, this.pagination.pageSize);
},
handlerGoConsoleIndex(id: number)
{
router.push('/console/index?id=' + id + '&from=snippet');
}
}
});

View File

@ -113,6 +113,8 @@ import * as monaco from 'monaco-editor';
import MonacoEditor from 'monaco-editor-vue3';
import {defineComponent} from "vue";
import SnippetDetails from "@/views/pages/admin/snippet/SnippetDetails.vue";
import {useRouter} from "vue-router";
import {SnippetService} from "@/services/SnippetService";
export default defineComponent({
name: "DashboardConsoleView",
@ -139,7 +141,29 @@ export default defineComponent({
snippetDetails: false
}
},
created()
{
this.handlerInitialize();
},
methods: {
handlerInitialize()
{
const router = useRouter();
if (router.currentRoute?.value?.query) {
const id = router.currentRoute.value.query.id as unknown as number;
const from = router.currentRoute.value.query.from;
if (id && from) {
if (from === 'snippet') {
new SnippetService().getById(id)
.then((response) => {
if (response.status) {
this.editorValue = response.data.code;
}
});
}
}
}
},
handlerEditorDidMount(editor: any)
{
const suggestions = new LanguageService().transSuggestions([]);