Commit da6c9328 authored by liaozan's avatar liaozan 🏀

feat: fileContent preview with highlight+1

parent 18e95dce
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<a-modal v-model:visible="contentPreviewVisible" :footer="null" title="文件内容预览" width="1000px"> <a-modal v-model:visible="contentPreviewVisible" :footer="null" title="文件内容预览" width="1000px">
<!--suppress HtmlUnknownTag --> <!--suppress HtmlUnknownTag -->
<highlightjs :code="fileContent" autodetect></highlightjs> <highlightjs :autodetect="false" :code="fileContent" :language="fileExtension"></highlightjs>
</a-modal> </a-modal>
</div> </div>
</template> </template>
...@@ -40,6 +40,7 @@ import type {TreeProps} from 'ant-design-vue'; ...@@ -40,6 +40,7 @@ import type {TreeProps} from 'ant-design-vue';
import {FormInstance, message} from "ant-design-vue"; import {FormInstance, message} from "ant-design-vue";
import request, {isLoading} from "../utils/request"; import request, {isLoading} from "../utils/request";
import BaseResponse from "../models/BaseResponse"; import BaseResponse from "../models/BaseResponse";
import {TreeDataNode} from "ant-design-vue/es/vc-tree-select/interface";
interface FormState { interface FormState {
groupId: string, groupId: string,
...@@ -61,6 +62,7 @@ const id = ref(-1) ...@@ -61,6 +62,7 @@ const id = ref(-1)
const structPreviewVisible = ref(false) const structPreviewVisible = ref(false)
const contentPreviewVisible = ref(false) const contentPreviewVisible = ref(false)
const fileContent = ref<string | null>() const fileContent = ref<string | null>()
const fileExtension = ref<string | null>()
const loading = computed(() => isLoading.value) const loading = computed(() => isLoading.value)
const downloadForm = ref<FormInstance>(); const downloadForm = ref<FormInstance>();
...@@ -104,9 +106,10 @@ const onDownload = async (id: number) => { ...@@ -104,9 +106,10 @@ const onDownload = async (id: number) => {
downloadGeneratedProject(data, fileName) downloadGeneratedProject(data, fileName)
} }
const onSelect = async (selectedKeys: string[], event: { node: FileNode }) => { const onSelect = async (selectedKeys: string[], event: { node: TreeDataNode }) => {
const {node} = event const {node} = event
fileContent.value = node.fileContent fileContent.value = node.fileContent
fileExtension.value = node.title.substring(node.title.lastIndexOf('.') + 1)
contentPreviewVisible.value = true contentPreviewVisible.value = true
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment