# cthep-ui **Repository Path**: geshijia/cthep-ui ## Basic Information - **Project Name**: cthep-ui - **Description**: 爱习题组件库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2023-11-09 - **Last Updated**: 2025-08-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # https://gitee.com/geshijia/cthep-ui.git # 本组件依赖element-plus如果你的项目里没有element-plus请先引入element-plus https://element-plus.gitee.io/zh-CN/guide/quickstart.html # main.js注册element-plus和图标 ``` import { createApp } from 'vue' import ElementPlus from 'element-plus' import 'element-plus/dist/index.css' import * as ElementPlusIconsVue from '@element-plus/icons-vue' import App from './App.vue' const app = createApp(App) for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } app.use(ElementPlus) app.mount('#app') ``` # 安装插件 ``` npm install cthep-ui ``` # 找到node_modules/cthep-ui把tinymce文件夹拷贝到自己的项目public/static文件下(如果没有static文件自己创建一个) # 在main.js注册全部组件(也可在页面按需引入) ``` import cthepUi from "cthep-ui"; import "cthep-ui/index.css"; Vue.use(cthepUi); ``` # 录题组件ctAddQuestion ``` ``` # 接口要求 ``` 注意tinymceUrl接口必须按照以下标准 token 传输使用Authorization方式 并需要在前面加Bearer(前端传token不需要加Bearer会自动带) 返回参数格式为 { "msg": "ok!", "path": "/fileFolder/mathImageFolder/278a5ac9-21b8-4d39-b548-9d7ece2355c4.jpg", "code": 200 } //上传文件源码 var xhr, formData; var file = blobInfo.blob(); //转化为易于理解的file对象 if (file.size > 5242880) return failFun("图片大小不能超过5M"); if (!["image/jpeg", "image/png", "image/gif"].includes(file.type)) return failFun("只能上传JPG、PNG、GIF图片"); xhr = new XMLHttpRequest(); xhr.withCredentials = false; xhr.open("POST", url.value); xhr.setRequestHeader("Authorization", "Bearer " + getToken()); xhr.onload = function () { var json = JSON.parse(xhr.responseText); if (json.code != 200) { failFun("HTTP Error: " + json.error); return; } succFun(localStorage.getItem('domainName') + json.path, { alt: "文件" }); }; formData = new FormData(); formData.append("file", file, file.name); //此处与源文档不一样 xhr.send(formData); ``` ## 方法库 cthepUi.handleTree 树结构处理 cthepUi.parseTime 日期格式化