添加 json view.
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
|||||||
import Breadcrumb from './app/breadcrumb/index.vue';
|
import Breadcrumb from './app/breadcrumb/index.vue';
|
||||||
import Chart from './view/chart/index.vue';
|
import Chart from './view/chart/index.vue';
|
||||||
import CardList from './view/card-list/index.vue';
|
import CardList from './view/card-list/index.vue';
|
||||||
|
import Editor from './view/editor/index.vue';
|
||||||
|
|
||||||
use([
|
use([
|
||||||
CanvasRenderer,
|
CanvasRenderer,
|
||||||
@@ -33,5 +34,6 @@ export default {
|
|||||||
Vue.component('Breadcrumb', Breadcrumb);
|
Vue.component('Breadcrumb', Breadcrumb);
|
||||||
Vue.component('a-query-header', AQueryHeader);
|
Vue.component('a-query-header', AQueryHeader);
|
||||||
Vue.component('card-list', CardList);
|
Vue.component('card-list', CardList);
|
||||||
|
Vue.component('Editor', Editor);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ export type RenderLineHighlight = 'all' | 'line' | 'none' | 'gutter'
|
|||||||
export interface Options {
|
export interface Options {
|
||||||
// 自适应布局
|
// 自适应布局
|
||||||
automaticLayout?: boolean;
|
automaticLayout?: boolean;
|
||||||
|
// 只读提示
|
||||||
|
readOnlyMessage?: {
|
||||||
|
value?: string,
|
||||||
|
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
// 是否折叠
|
// 是否折叠
|
||||||
folding?: boolean;
|
folding?: boolean;
|
||||||
// 折叠方式
|
// 折叠方式
|
||||||
@@ -44,7 +50,9 @@ export interface Options {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
minimap?: {
|
minimap?: {
|
||||||
// 关闭小地图
|
// 关闭小地图
|
||||||
enabled?: boolean
|
enabled?: boolean;
|
||||||
|
|
||||||
|
[key: string]: unknown;
|
||||||
};
|
};
|
||||||
fontSize?: number;
|
fontSize?: number;
|
||||||
// 取消代码后面一大段空白
|
// 取消代码后面一大段空白
|
||||||
@@ -63,6 +71,9 @@ export interface Options {
|
|||||||
export const createDefaultOptions = (): Options => {
|
export const createDefaultOptions = (): Options => {
|
||||||
return {
|
return {
|
||||||
automaticLayout: true,
|
automaticLayout: true,
|
||||||
|
readOnlyMessage: {
|
||||||
|
value: '当前为只读状态'
|
||||||
|
},
|
||||||
folding: true,
|
folding: true,
|
||||||
foldingHighlight: true,
|
foldingHighlight: true,
|
||||||
foldingStrategy: 'indentation',
|
foldingStrategy: 'indentation',
|
||||||
|
|||||||
@@ -71,7 +71,8 @@
|
|||||||
language: props.language,
|
language: props.language,
|
||||||
readOnly: props.readonly,
|
readOnly: props.readonly,
|
||||||
theme: props.theme === true ? (appStore.theme === 'dark' ? 'vs-dark' : 'vs') : props.theme,
|
theme: props.theme === true ? (appStore.theme === 'dark' ? 'vs-dark' : 'vs') : props.theme,
|
||||||
options: { ...createDefaultOptions(), ...props.options },
|
...createDefaultOptions(),
|
||||||
|
...props.options,
|
||||||
};
|
};
|
||||||
// 创建编辑器
|
// 创建编辑器
|
||||||
editor = monaco.editor.create(editorContainer.value, options);
|
editor = monaco.editor.create(editorContainer.value, options);
|
||||||
@@ -101,7 +102,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听配置
|
// 监听配置变更
|
||||||
watch(() => props.options, (v) => {
|
watch(() => props.options, (v) => {
|
||||||
if (editor) {
|
if (editor) {
|
||||||
editor.updateOptions(v);
|
editor.updateOptions(v);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<template #username="{ record }">
|
<template #username="{ record }">
|
||||||
<a-tooltip content="点击复制">
|
<a-tooltip content="点击复制">
|
||||||
<span class="pointer span-blue" @click="copy(record.username)">
|
<span class="pointer span-blue" @click="copy(record.username)">
|
||||||
<icon-copy class="mr4" />{{ record.username }}
|
<icon-copy /> {{ record.username }}
|
||||||
</span>
|
</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
@@ -226,6 +226,6 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<template #username="{ record }">
|
<template #username="{ record }">
|
||||||
<a-tooltip content="点击复制">
|
<a-tooltip content="点击复制">
|
||||||
<span class="pointer span-blue" @click="copy(record.username)">
|
<span class="pointer span-blue" @click="copy(record.username)">
|
||||||
<icon-copy class="mr4" />{{ record.username }}
|
<icon-copy /> {{ record.username }}
|
||||||
</span>
|
</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<template #address="{ record }">
|
<template #address="{ record }">
|
||||||
<a-tooltip content="点击复制">
|
<a-tooltip content="点击复制">
|
||||||
<span class="host-address" @click="copy(record.address)">
|
<span class="host-address" @click="copy(record.address)">
|
||||||
<icon-copy class="mr4" />{{ record.address }}
|
<icon-copy /> {{ record.address }}
|
||||||
</span>
|
</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
<template #address="{ record }">
|
<template #address="{ record }">
|
||||||
<a-tooltip content="点击复制">
|
<a-tooltip content="点击复制">
|
||||||
<span class="host-address" @click="copy(record.address)">
|
<span class="host-address" @click="copy(record.address)">
|
||||||
<icon-copy class="mr4" />{{ record.address }}
|
<icon-copy /> {{ record.address }}
|
||||||
</span>
|
</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -53,6 +53,12 @@
|
|||||||
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
@page-change="(page) => fetchTableData(page, pagination.pageSize)"
|
||||||
@page-size-change="(size) => fetchTableData(1, size)"
|
@page-size-change="(size) => fetchTableData(1, size)"
|
||||||
:bordered="false">
|
:bordered="false">
|
||||||
|
<!-- 配置项 -->
|
||||||
|
<template #keyName="{ record }">
|
||||||
|
<span class="pointer" @click="copy(record.keyName)">
|
||||||
|
<icon-copy class="span-blue" /> {{ record.keyName }}
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
<!-- 配置值类型 -->
|
<!-- 配置值类型 -->
|
||||||
<template #valueType="{ record }">
|
<template #valueType="{ record }">
|
||||||
<a-tag :color="getEnumValue(record.valueType, ValueTypeEnum, 'color')">
|
<a-tag :color="getEnumValue(record.valueType, ValueTypeEnum, 'color')">
|
||||||
@@ -80,7 +86,7 @@
|
|||||||
<!-- 查看 -->
|
<!-- 查看 -->
|
||||||
<a-button type="text"
|
<a-button type="text"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="viewDictKey(record.keyName)">
|
@click="emits('openView', record)">
|
||||||
查看
|
查看
|
||||||
</a-button>
|
</a-button>
|
||||||
<!-- 修改 -->
|
<!-- 修改 -->
|
||||||
@@ -125,12 +131,11 @@
|
|||||||
import {} from '../types/const';
|
import {} from '../types/const';
|
||||||
import { ValueTypeEnum } from '../types/enum.types';
|
import { ValueTypeEnum } from '../types/enum.types';
|
||||||
import { getEnumValue } from '@/utils/enum';
|
import { getEnumValue } from '@/utils/enum';
|
||||||
import { getDictValueEnum } from '@/api/system/dict-value';
|
|
||||||
import useCopy from '@/hooks/copy';
|
import useCopy from '@/hooks/copy';
|
||||||
|
|
||||||
const tableRenderData = ref<DictKeyQueryResponse[]>([]);
|
const tableRenderData = ref<DictKeyQueryResponse[]>([]);
|
||||||
const { loading, setLoading } = useLoading();
|
const { loading, setLoading } = useLoading();
|
||||||
const emits = defineEmits(['openAdd', 'openUpdate']);
|
const emits = defineEmits(['openAdd', 'openUpdate', 'openView']);
|
||||||
|
|
||||||
const { copy } = useCopy();
|
const { copy } = useCopy();
|
||||||
const pagination = usePagination();
|
const pagination = usePagination();
|
||||||
@@ -172,13 +177,6 @@
|
|||||||
addedCallback, updatedCallback
|
addedCallback, updatedCallback
|
||||||
});
|
});
|
||||||
|
|
||||||
// 查看
|
|
||||||
const viewDictKey = async (keyName: string) => {
|
|
||||||
const { data } = await getDictValueEnum(keyName);
|
|
||||||
// fixme 后续改为 jsonView
|
|
||||||
await copy(JSON.stringify(data), '复制成功');
|
|
||||||
};
|
|
||||||
|
|
||||||
// 加载数据
|
// 加载数据
|
||||||
const doFetchTableData = async (request: DictKeyQueryRequest) => {
|
const doFetchTableData = async (request: DictKeyQueryRequest) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal v-model:visible="visible"
|
||||||
|
title-align="start"
|
||||||
|
width="60%"
|
||||||
|
:body-style="{padding: '16px 4px'}"
|
||||||
|
:top="80"
|
||||||
|
:title="title"
|
||||||
|
:align-center="false"
|
||||||
|
:draggable="true"
|
||||||
|
:mask-closable="false"
|
||||||
|
:unmount-on-close="true"
|
||||||
|
:footer="false"
|
||||||
|
@close="handleClose">
|
||||||
|
<a-spin :loading="loading" style="width: 100%; height: calc(100vh - 240px)">
|
||||||
|
<editor v-model="value" readonly />
|
||||||
|
</a-spin>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
name: 'dict-key-view-modal'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import useLoading from '@/hooks/loading';
|
||||||
|
import useVisible from '@/hooks/visible';
|
||||||
|
import { getDictValueEnum } from '@/api/system/dict-value';
|
||||||
|
|
||||||
|
const { visible, setVisible } = useVisible();
|
||||||
|
const { loading, setLoading } = useLoading();
|
||||||
|
|
||||||
|
const title = ref<string>();
|
||||||
|
const value = ref<string>();
|
||||||
|
|
||||||
|
// 打开新增
|
||||||
|
const open = (e: any) => {
|
||||||
|
title.value = e.keyName;
|
||||||
|
value.value = undefined;
|
||||||
|
render(e.keyName);
|
||||||
|
setVisible(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 渲染
|
||||||
|
const render = async (keyName: string) => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
// 查看
|
||||||
|
const { data } = await getDictValueEnum(keyName);
|
||||||
|
value.value = JSON.stringify(data, undefined, 4);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
|
||||||
|
// 关闭
|
||||||
|
const handleClose = () => {
|
||||||
|
setLoading(false);
|
||||||
|
setVisible(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
:deep(.arco-modal-title) {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,11 +3,14 @@
|
|||||||
<!-- 列表-表格 -->
|
<!-- 列表-表格 -->
|
||||||
<dict-key-table ref="table"
|
<dict-key-table ref="table"
|
||||||
@openAdd="() => modal.openAdd()"
|
@openAdd="() => modal.openAdd()"
|
||||||
@openUpdate="(e) => modal.openUpdate(e)" />
|
@openUpdate="(e) => modal.openUpdate(e)"
|
||||||
|
@openView="(e) => view.open(e)" />
|
||||||
<!-- 添加修改模态框 -->
|
<!-- 添加修改模态框 -->
|
||||||
<dict-key-form-modal ref="modal"
|
<dict-key-form-modal ref="modal"
|
||||||
@added="modalAddCallback"
|
@added="modalAddCallback"
|
||||||
@updated="modalUpdateCallback" />
|
@updated="modalUpdateCallback" />
|
||||||
|
<!-- json 查看器模态框 -->
|
||||||
|
<dict-key-view-modal ref="view" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -21,9 +24,11 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import DictKeyTable from './components/dict-key-table.vue';
|
import DictKeyTable from './components/dict-key-table.vue';
|
||||||
import DictKeyFormModal from './components/dict-key-form-modal.vue';
|
import DictKeyFormModal from './components/dict-key-form-modal.vue';
|
||||||
|
import DictKeyViewModal from './components/dict-key-view-modal.vue';
|
||||||
|
|
||||||
const table = ref();
|
const table = ref();
|
||||||
const modal = ref();
|
const modal = ref();
|
||||||
|
const view = ref();
|
||||||
|
|
||||||
// 添加回调
|
// 添加回调
|
||||||
const modalAddCallback = () => {
|
const modalAddCallback = () => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const columns = [
|
|||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
tooltip: true,
|
tooltip: true,
|
||||||
}, {
|
}, {
|
||||||
title: '配置值类型',
|
title: '类型',
|
||||||
dataIndex: 'valueType',
|
dataIndex: 'valueType',
|
||||||
slotName: 'valueType',
|
slotName: 'valueType',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
@@ -29,7 +29,7 @@ const columns = [
|
|||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
tooltip: true,
|
tooltip: true,
|
||||||
}, {
|
}, {
|
||||||
title: '额外配置类型',
|
title: '额外配置',
|
||||||
dataIndex: 'extraSchema',
|
dataIndex: 'extraSchema',
|
||||||
slotName: 'extraSchema',
|
slotName: 'extraSchema',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
|||||||
Reference in New Issue
Block a user