inscode-editor-sdk
v0.1.112
Published
```js 1. npm run build 2. 修改package.json的版本号 3. git add . && git commit -m "xxx" && git push origin main 4. git tag v0.1.0(v + package.json的版本号) 5. git push origin v0.1.0(v + package.json的版本号) ``` ## 组件使用方法一 > 直接复制包内所有内容,自己来适配vite配置 > 可以减少依赖包, 自定义比较好 ## 组
Readme
打包流程
1. npm run build
2. 修改package.json的版本号
3. git add . && git commit -m "xxx" && git push origin main
4. git tag v0.1.0(v + package.json的版本号)
5. git push origin v0.1.0(v + package.json的版本号)组件使用方法一
直接复制包内所有内容,自己来适配vite配置 可以减少依赖包, 自定义比较好
组件使用方法二
使用依赖包来管理
// package.json
"inscode-editor": "git+ssh://[email protected]:InsCode/inscode-editor-sdk.git#v0.0.11"
npm install
// 遇到失败检查是否有权限
// 执行 ssh -T [email protected] 的作用是测试你的 SSH 连接是否成功,并验证你的 SSH 公钥是否被 gitcode.com 认可代码结构
<template>
<InsCodeEditor
:message="message"
domain="gitcode.com"
:project="{ gitUrl: '', workspacePath: '', branch: 'main' }"
:message-id="messageId"
@init="handleInit"
@change-file="handleChangeFile"
>
<template #toolbarLeft>
<div >
toggle
</div>
</template>
<template #toolbarRight>
版本管理
</template>
</InsCodeEditor>
</template>
<scrip lang="ts" setup>
import { ref, type Ref } from 'vue';
import InsCodeEditor from 'inscode-editor';
import 'inscode-editor/dist/inscode-editor-sdk.css'
import { Action, StatusEnum, TypeEnum, type Message } from 'inscode-editor/src/package/types';
// @params String messageId
// 1.能通过当前页面路由参数获取唯一ID信息
// 2.方便以后支持代码丢失
const messageId = ref('demo')
// @params Object message
// 单次会话内容
const message:Ref<Message> = ref({
// 当前文件内容 code | image
type: TypeEnum.code,
// 会话动作
action: Action.write,
// 生成内容
content: '',
// 注意这个是根据每个action不能不一样,如果action中没有这个参数,请清空
mode: 'command',
// 注意这个是根据每个action不能不一样,如果action中没有这个参数,请清空
script: 'npm i && npm run dev',
// 文件路径
fsPath: '',
// 文件状态, writing completed
status: StatusEnum.writing
})
// 项目初始化成功
function handleInit () {
}
</script>
// 获取项目内容方法
1. search_files ---action
参数:
{ fsPath: '/repo0124', action: 'search_files', query: { regex: '', filePattern: '*.md', skipFiles: [] } }
2. list_files ---action
参数:
{ fsPath: '/repo0124', action: 'list_files'}
3. read_file ---action
参数:
{ fsPath: 'app/index.vue,src/aa.js' }
4. getSystemInfo --- 获取系统参数
4.1 容器未启动,就不请求这个参数
4.2 容器启动, 请求这个参数
参数
{ fsPath: '', action: 'getSystemInfo'}
5. execute_command
参数:
{ fsPath: '', action: 'execute_command', content: 'node index.js' }
6. download_resource_to_file =>图片是否成功
参数
{ fsPath: '', action: 'download_resource_to_file', content: 'path' }
// 自定义生成版本, 手动编辑文件内容,等容器关闭自动commit
7. generate_version_history
参数
{ fsPath: '', action: 'generate_version_history', content: '自定义commit信息' }
8. git_reset
参数
{ action: 'git_reset' }
//调用方法
editor.value?.getProjectInfo(参数).then((res:any) => {
console.log('getSystemInfo', res)
})