Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 优化 repl #347

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions docs/.vitepress/theme/components/exampleRepl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
@ok="isShow = false"
>
<Repl
v-if="props.codeName"
:editor="CodeMirror"
:store="store"
:showImportMap="true"
:showCompileOutput="false"
Expand All @@ -20,12 +22,14 @@
import { version, ref, watch } from 'vue';
// eslint-disable-next-line import/no-unresolved
import { FDrawer } from '@fesjs/fes-design';
import CodeMirror from '@vue/repl/codemirror-editor';

import { Repl, ReplStore } from '@vue/repl';
// eslint-disable-next-line import/no-unresolved
import '@vue/repl/style.css';
import data from './demoCode.json';
const mainFile = 'App.vue';
const demoFile = 'demo.vue';
const mainFile = 'src/App.vue';
const demoFile = 'src/demo.vue';

const props = defineProps({
codeName: String,
Expand Down Expand Up @@ -64,22 +68,24 @@ export function setupFesDesign() {
}
`;

const defaultFiles = {
[mainFile]: data.app,
'src/space.vue': data.space,
'src/fes-design.js': fesDesignSetup,
'import-map.json': JSON.stringify({
imports: {
'@fesjs/fes-design':
'https://unpkg.com/@fesjs/fes-design@latest/dist/fes-design.esm-browser.js',
'@fesjs/fes-design/icon':
'https://unpkg.com/@fesjs/fes-design@latest/dist/fes-design.icon-browser.js',
},
}),
};
store.setFiles(defaultFiles);
store.setActive(mainFile);
function resolveSFCExample(demo) {
const files = {
[mainFile]: data.app,
'space.vue': data.space,
[demoFile]: data[demo],
'fes-design.js': fesDesignSetup,
'import-map.json': JSON.stringify({
imports: {
'@fesjs/fes-design':
'https://unpkg.com/@fesjs/fes-design@latest/dist/fes-design.esm-browser.js',
'@fesjs/fes-design/icon':
'https://unpkg.com/@fesjs/fes-design@latest/dist/fes-design.icon-browser.js',
},
}),
};
return files;
defaultFiles[demoFile] = data[demo];
return defaultFiles;
}

function updateExample(fileName) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码主要是一个Vue项目中的补丁,对Repl组件和相关变量进行了一些修改和调整。以下是我对代码的简要审查:

  1. 新增了v-if条件判断,只有在props.codeName存在时才会渲染该组件。
  2. 引入了CodeMirror组件,并将其作为Repl组件的属性传递。
  3. 修改了默认的文件路径(mainFiledemoFile),添加了"src/"前缀,以与实际目录结构匹配。
  4. 新增了defaultFiles对象,用于设置默认的文件内容和导入映射信息。
  5. 修改了resolveSFCExample函数,将特定的示例文件内容更新到defaultFiles对象中。

可能的问题和改进建议:

  • 代码片段中未包含完整的上下文,无法全面判断是否存在潜在错误。请确保引入的库和组件等都正确导入和配置。
  • 根据代码的上下文,可以看出涉及到动态修改文件内容和状态,需要确保相关操作的正确性和安全性。
  • 建议提供更多关于Replstore以及其他自定义组件和方法的信息,以便进行更准确和全面的代码审查。

请记住,这仅是对代码的初步审查,具体的问题和改进取决于实际运行环境和所需功能。如有需要,请提供更多信息以便更详细地分析代码。

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
"@types/jest": "^27.4.1",
"@vitejs/plugin-vue-jsx": "^1.3.0",
"@vue/babel-plugin-jsx": "^1.1.1",
"@vue/compiler-sfc": "^3.2.45",
"@vue/repl": "^1.0.0",
"@vue/compiler-sfc": "^3.3.4",
"@vue/repl": "^2.5.5",
"@vue/test-utils": "2.0.0-rc.17",
"@vue/vue3-jest": "27.0.0-alpha.4",
"@webank/eslint-config-ts": "^1.1.2",
Expand Down Expand Up @@ -110,7 +110,7 @@
"ts-morph": "^13.0.2",
"typescript": "^4.9.5",
"vitepress": "0.21.4",
"vue": "^3.2.45"
"vue": "^3.3.4"
},
"dependencies": {
"@babel/runtime": "^7.16.3",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个代码补丁主要是更新了一些依赖版本。下面是我对这个补丁的代码审查:

  1. "@vue/compiler-sfc" 从版本 3.2.45 升级到了 3.3.4
  2. "@vue/repl" 从版本 1.0.0 升级到了 2.5.5
  3. "vue": "^3.2.45" 从版本 3.2.45 升级到了 3.3.4

改动看起来比较小,主要是更新了一些依赖的版本。根据这个补丁代码,没有明显的错误风险。但是请确保你的项目中其他部分与这些更新的依赖兼容,并且测试覆盖率足够,以确保这些更新不会引入新的问题。

Expand Down
Loading