在线编辑
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
"prettier": "^3.7.3",
|
||||
"typescript": "~5.8.0",
|
||||
"vite": "^7.0.6",
|
||||
"vite-plugin-monaco-editor-esm": "^2.0.2",
|
||||
"vite-plugin-vue-devtools": "^8.0.0",
|
||||
"vue-tsc": "^3.0.4"
|
||||
}
|
||||
|
||||
@@ -41,12 +41,16 @@ service.interceptors.request.use(
|
||||
|
||||
service.interceptors.response.use(
|
||||
(res) => {
|
||||
// 判断响应类型,如果是 blob,返回完整响应对象
|
||||
// 判断响应类型,如果是 文件流,返回完整响应对象
|
||||
if (res.headers['content-type'].includes('octet-stream')) {
|
||||
return res;
|
||||
}
|
||||
if (res.config.responseType === 'blob') {
|
||||
// 判断响应类型,如果是 blob,返回完整响应对象
|
||||
return res;
|
||||
}
|
||||
// 普通接口返回原来的 res.data
|
||||
if (res.data.code !== 200) {
|
||||
if (res.data?.code && res.data?.code !== 200) {
|
||||
ElMessage.warning(res.data.message);
|
||||
}
|
||||
return res.data;
|
||||
|
||||
@@ -129,22 +129,29 @@ const getFile = async () => {
|
||||
const res: any = await dataDownloadFileApi({ fileId: props.fileId });
|
||||
if (res) {
|
||||
// 设置语言
|
||||
// let fileSuffix = '';
|
||||
// if (fileName.lastIndexOf('.') != -1) {
|
||||
// fileSuffix = fileName.substring(fileName.lastIndexOf('.')).slice(1);
|
||||
// }
|
||||
let fileSuffix = '';
|
||||
if (fileTitle.value.lastIndexOf('.') != -1) {
|
||||
fileSuffix = fileTitle.value.substring(fileTitle.value.lastIndexOf('.')).slice(1);
|
||||
}
|
||||
// const language = fileSuffix && (window as any).FILE_TYPE_MAP[fileSuffix] ? FILE_TYPE[fileSuffix] : '';
|
||||
// 获取当前的文本模型
|
||||
const model = toRaw(editor.value).getModel();
|
||||
// setModelLanguage 方法来设置新的语言
|
||||
if (model) {
|
||||
monaco.editor.setModelLanguage(model, 'python');
|
||||
// console.log('setModelLanguage', fileSuffix);
|
||||
monaco.editor.setModelLanguage(model, fileSuffix);
|
||||
}
|
||||
// 填入内容时设置只读为false
|
||||
toRaw(editor.value).updateOptions({ readonly: true });
|
||||
// 设置内容
|
||||
// text.value = JSON.stringify(res) as string;
|
||||
text.value = res;
|
||||
toRaw(editor.value).updateOptions({ readonly: false });
|
||||
// console.log('res', res);
|
||||
// if (Object.prototype.toString.call(res) !== '[object String]') {
|
||||
// // 设置内容
|
||||
// text.value = JSON.stringify(res);
|
||||
// } else {
|
||||
// // 设置内容
|
||||
// text.value = res;
|
||||
// }
|
||||
text.value = res.request.response;
|
||||
toRaw(editor.value).setValue(text.value);
|
||||
// 设置光标位置为第一行第一列
|
||||
toRaw(editor.value).setPosition({ lineNumber: 1, column: 1 });
|
||||
|
||||
@@ -2,6 +2,7 @@ import { fileURLToPath, URL } from 'node:url';
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||
import monacoEditorPlugin from 'vite-plugin-monaco-editor-esm';
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig(({ mode }) => {
|
||||
@@ -9,7 +10,7 @@ export default defineConfig(({ mode }) => {
|
||||
|
||||
return {
|
||||
base: '/spdm/',
|
||||
plugins: [vue(), vueJsx()],
|
||||
plugins: [vue(), vueJsx(), monacoEditorPlugin({})],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||
@@ -35,6 +36,7 @@ export default defineConfig(({ mode }) => {
|
||||
// target: 'http://192.168.65.199:7101', // 李东洋
|
||||
// target: 'http://192.168.65.75:7100/simulation/project', // 朱欣茹
|
||||
target: 'http://192.168.65.161:3000/api/simulation/project', // 开发环境
|
||||
// target: 'http://carsafe.uicp.cn:58634/simulation/project', // 开发环境
|
||||
// target: 'http://192.168.65.161', // 开发环境
|
||||
// target: 'http://192.168.65.73:7100', // 开发环境
|
||||
// target: 'http://192.168.65.53:8080', // 戴琼瑶本地
|
||||
@@ -88,7 +90,8 @@ export default defineConfig(({ mode }) => {
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/local7107/, ''),
|
||||
},
|
||||
'/local7108': { // data文件模块
|
||||
'/local7108': {
|
||||
// data文件模块
|
||||
target: 'http://192.168.65.161:3000/api/simulation/flowable', // 开发环境
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/local7108/, ''),
|
||||
|
||||
Reference in New Issue
Block a user