From 78e51d96f6d7d43bb2ab010a65a5610d6577fb52 Mon Sep 17 00:00:00 2001 From: rjl <98n9@163.com> Date: Wed, 28 Jan 2026 09:53:17 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B8=85=E7=90=86=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=A8=A1=E6=9D=BF=E7=BC=96=E8=BE=91=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除模板编辑相关组件、工具函数和类型定义,并删除不再需要的第三方依赖包。此功能已不再使用,清理以减少项目体积和复杂度。 - 删除模板编辑页面及其所有子组件(left-tree、middle-book、right-topic等) - 移除PDF转换、图片裁剪、数学公式编辑等工具函数 - 清理富文本编辑器组件及相关类型定义 - 从package.json移除@formkit/auto-animate、@sapphire/snowflake、katex、mathlive等未使用依赖 --- apps/admin/package.json | 5 - .../components/math-iframe-dialog.vue | 33 -- .../components/up-file-dialog.vue | 60 --- .../common/rest-basic-editor/editor-util.ts | 270 ----------- .../rest-basic-editor/rest-basic-editor.vue | 244 ---------- .../common/rest-basic-editor/types.ts | 23 - .../rest-draggable-resizable.vue | 327 ------------- .../template/template-detail/def-data.ts | 36 -- .../views/template/template-detail/index.vue | 79 +-- .../left-tree/components/import-bubble.vue | 194 -------- .../left-tree/components/menu-bubble.vue | 123 ----- .../modules/left-tree/left-tree.vue | 207 -------- .../middle-book/components/menu-bubble.vue | 95 ---- .../components/topic-item-module.vue | 312 ------------ .../modules/middle-book/middle-book.vue | 118 ----- .../components/add-analysis-bubble.vue | 200 -------- .../components/add-topic-form-bubble.vue | 250 ---------- .../components/edit-info-bubble.vue | 458 ------------------ .../components/release-task-bubble.vue | 103 ---- .../components/right-topic-item.vue | 195 -------- .../right-topic-list-normal.vue | 139 ------ .../components/add-topic-form-bubble.vue | 232 --------- .../components/right-topic-item.vue | 139 ------ .../right-topic-list-special.vue | 110 ----- .../modules/right-topic/right-topic-list.vue | 31 -- .../template/template-detail/pdf-util.ts | 11 - .../views/template/template-detail/types.ts | 100 ---- .../views/template/template-detail/util.ts | 138 ------ pnpm-lock.yaml | 74 +-- 29 files changed, 8 insertions(+), 4298 deletions(-) delete mode 100644 apps/admin/src/components/common/rest-basic-editor/components/math-iframe-dialog.vue delete mode 100644 apps/admin/src/components/common/rest-basic-editor/components/up-file-dialog.vue delete mode 100644 apps/admin/src/components/common/rest-basic-editor/editor-util.ts delete mode 100644 apps/admin/src/components/common/rest-basic-editor/rest-basic-editor.vue delete mode 100644 apps/admin/src/components/common/rest-basic-editor/types.ts delete mode 100644 apps/admin/src/components/common/rest-draggable-resizable/rest-draggable-resizable.vue delete mode 100644 apps/admin/src/views/template/template-detail/def-data.ts delete mode 100644 apps/admin/src/views/template/template-detail/modules/left-tree/components/import-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/left-tree/components/menu-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/left-tree/left-tree.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/middle-book/components/menu-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/middle-book/components/topic-item-module.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/middle-book/middle-book.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-analysis-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-topic-form-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/edit-info-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/release-task-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/right-topic-item.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/right-topic-list-normal.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/add-topic-form-bubble.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/right-topic-item.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/right-topic-list-special.vue delete mode 100644 apps/admin/src/views/template/template-detail/modules/right-topic/right-topic-list.vue delete mode 100644 apps/admin/src/views/template/template-detail/pdf-util.ts delete mode 100644 apps/admin/src/views/template/template-detail/types.ts delete mode 100644 apps/admin/src/views/template/template-detail/util.ts diff --git a/apps/admin/package.json b/apps/admin/package.json index 4e80b7e..62e1965 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -25,7 +25,6 @@ }, "dependencies": { "@better-scroll/core": "2.5.1", - "@formkit/auto-animate": "^0.9.0", "@iconify/vue": "5.0.0", "@opentiny/fluent-editor": "^4.0.1", "@sa/axios": "workspace:*", @@ -33,17 +32,13 @@ "@sa/hooks": "workspace:*", "@sa/materials": "workspace:*", "@sa/utils": "workspace:*", - "@sapphire/snowflake": "^3.5.5", "@vueuse/core": "14.1.0", - "@zumer/snapdom": "^2.0.1", "ali-oss": "^6.23.0", "clipboard": "2.0.11", "dayjs": "1.11.19", "defu": "6.1.4", "echarts": "6.0.0", "json5": "2.2.3", - "katex": "^0.16.27", - "mathlive": "^0.108.2", "naive-ui": "2.43.2", "nprogress": "0.2.0", "path-browserify": "^1.0.1", diff --git a/apps/admin/src/components/common/rest-basic-editor/components/math-iframe-dialog.vue b/apps/admin/src/components/common/rest-basic-editor/components/math-iframe-dialog.vue deleted file mode 100644 index 9d0913c..0000000 --- a/apps/admin/src/components/common/rest-basic-editor/components/math-iframe-dialog.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - diff --git a/apps/admin/src/components/common/rest-basic-editor/components/up-file-dialog.vue b/apps/admin/src/components/common/rest-basic-editor/components/up-file-dialog.vue deleted file mode 100644 index e3bbaa4..0000000 --- a/apps/admin/src/components/common/rest-basic-editor/components/up-file-dialog.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - {{ item.name }} - - - - - - - - diff --git a/apps/admin/src/components/common/rest-basic-editor/editor-util.ts b/apps/admin/src/components/common/rest-basic-editor/editor-util.ts deleted file mode 100644 index 7b81ef8..0000000 --- a/apps/admin/src/components/common/rest-basic-editor/editor-util.ts +++ /dev/null @@ -1,270 +0,0 @@ -import type { IEditorConfig, MathliveModule, Range, ToolbarOptions } from '@opentiny/fluent-editor' -import type OSS from 'ali-oss' -import type { GetEditorConfigParams, MyToolbarOption, UpFile } from './types' -import FluentEditor, { generateToolbarTip } from '@opentiny/fluent-editor' -import katex from 'katex' -import QuillToolbarTip, { type QuillToolbarTipOptions } from 'quill-toolbar-tip' -import { ref } from 'vue' -import { getAliOssTokenAxios } from '@/service/api/upload' -import { browserPathJoin } from '@/utils/date' -import { base64ToFile } from '@/utils/file' -import { initOSSClient, uploadFileToOSS } from '@/utils/oss' -import { getSnowflake } from '@/utils/rest' - -/** 自定义打开iframe的按钮的key */ -export const MY_OPEN_PROCESSON_IFRAME = 'my-open-processon-iframe' as const -export const upFileList = ref([]) - -/** - * 初始化编辑器 - */ -export function initEditor(container: HTMLElement, params: IEditorConfig): FluentEditor { - // 需要依赖 katex - window.katex = katex as any - - // 处理图片给每个图片添加类名和最大宽度 - const ImageBlot: any = FluentEditor.import('formats/image') - class CustomImageBlot extends ImageBlot { - static create(value: any) { - const node: HTMLImageElement = super.create(value) - editImageAttribute(node, false) - return node - } - } - FluentEditor.register(CustomImageBlot, true) - - // 处理视频给每个视频添加类名和最大宽度 - const VideoBlot: any = FluentEditor.import('formats/video') - class CustomVideoBlot extends VideoBlot { - static create(value: any) { - const node: HTMLVideoElement = super.create(value) - editVideoAttribute(node, false) - return node - } - } - FluentEditor.register(CustomVideoBlot, true) - - // 注册工具栏提示模块 - FluentEditor.register({ 'modules/toolbar-tip': generateToolbarTip(QuillToolbarTip) }, true) - const Parchment = FluentEditor.import('parchment') - addToolbarIcon() - - // 居中问题 - const config = { scope: Parchment.Scope.BLOCK, whitelist: ['right', 'center', 'justify'] } - const Align = new Parchment.StyleAttributor('align', 'text-align', config) - FluentEditor.register(Align, true) - - // 工具栏配置 - return new FluentEditor(container, params) -} - -/** - * 得到编辑器的配置 - */ -export async function getEditorConfig(params: GetEditorConfigParams): Promise { - const editorOptions: IEditorConfig = { - theme: 'snow', - modules: { - // 是否开启数学公式模块 - 'mathlive': true, - // 开启字数统计 - // counter: { - // count: 2000, - // }, - 'toolbar': { - // 工具栏显示那些按钮 - container: await getToolbarOption(params.toolbarOption || {}), - handlers: { - formula() { - // 点击数学公式按钮时打开弹出框 - const mathlive = this.quill.getModule('mathlive') as MathliveModule - mathlive.createDialog('') - }, - // 自定义打开iframe的按钮的点击事件的回调 - [`${MY_OPEN_PROCESSON_IFRAME}`](_value: boolean) { - params[MY_OPEN_PROCESSON_IFRAME]() // 执行回调 - }, - }, - }, - 'uploader': { - // only allow image - mimetypes: ['*', 'video/*', 'audio/*'], - async handler(_range: Range, files: File[]): Promise<(string | false)[]> { - try { - const paths = await Promise.all(files.map((file, index) => upFileAxios(file, `${Date.now()}_${index}`))) - return paths - } - catch (error: any) { - window.$message?.error(`上传失败: ${error.message}`) - // eslint-disable-next-line no-console - console.log('error====', error) - return files.map(() => false) - } - }, - }, - 'clipboard': { - matchers: [ - [ - 'img', - (node: HTMLImageElement, delta: any) => { - editImageAttribute(node, false) - return delta - }, - ], - [ - 'video', - (node: HTMLVideoElement, delta: any) => { - editVideoAttribute(node, false) - return delta - }, - ], - ], - }, - // 工具栏提示配置 - 'toolbar-tip': { - defaultTooltipOptions: { - tipHoverable: false, - }, - tipTextMap: { - [MY_OPEN_PROCESSON_IFRAME]: '跳转第三方公式编辑器\n可在第三方编辑器编辑好公式后复制过来\n[注意]:需要复制到公式输入框内才能生效', - }, - } satisfies Partial, - // 国际化配置 - 'i18n': { lang: 'zh-CN' }, - }, - } - return editorOptions -} - -/** - * 得到工具栏配置(显示那些按钮) - */ -function getToolbarOption(params: MyToolbarOption): Promise { - const { show, showUpFile, showUpVideo, customToolbar } = params - - if (show === false) { - return Promise.resolve([] satisfies ToolbarOptions['container']) - } - - if (customToolbar !== undefined) { - return Promise.resolve(customToolbar) - } - const va = ['image'] - showUpVideo !== false && va.push('video') // 只要不等于false就添加 (undefined也添加) - showUpFile !== false && va.push('file') // 只要不等于false就添加 (undefined也添加) - // 工具栏配置 - const TOOLBAR_CONFIG: ToolbarOptions['container'] = [ - ['undo', 'redo', 'clean', 'format-painter'], - [ - { header: [1, 2, 3, 4, 5, 6, false] }, - { size: [false, '12px', '14px', '16px', '18px', '20px', '24px', '32px', '36px', '48px', '72px'] }, - { 'line-height': [false, '1.2', '1.5', '1.75', '2', '3', '4', '5'] }, - { font: [false, 'serif', 'sans-serif', 'monospace', 'cursive', 'fantasy', '宋体', '黑体', '微软雅黑', '楷体', '仿宋', '等线'] }, - ], - ['bold', 'italic', 'strike', 'underline', 'divider'], - [{ color: [] }, { background: [] }], - [{ align: '' }, { align: 'center' }, { align: 'right' }, { align: 'justify' }], // 这里可以为字符串 - [{ list: 'ordered' }, { list: 'bullet' }, { list: 'check' }], - [{ script: 'sub' }, { script: 'super' }], - [{ indent: '-1' }, { indent: '+1' }], - ['link', 'blockquote'], - [...va], - ['fullscreen', 'formula', MY_OPEN_PROCESSON_IFRAME], - ] - return Promise.resolve(TOOLBAR_CONFIG) -} - -/** - * 添加打开iframe的弹出框的自定义按钮 - */ -function addToolbarIcon() { - // 这里时增加按钮 - const myOpenProcessonIframeIcon = `` - const icons = FluentEditor.import('ui/icons') as Record - icons[MY_OPEN_PROCESSON_IFRAME] = myOpenProcessonIframeIcon -} - -/** - * 上传文件 - */ -async function upFileAxios(file: File, id: string): Promise { - const item: UpFile = { id, name: file.name, progress: 0 } - try { - upFileList.value.push(item) - const { data: tokenData } = await getAliOssTokenAxios() - if (!tokenData) { - return false - } - // 初始化OSS客户端 - const client = initOSSClient(tokenData) - const path = browserPathJoin(`temp/${Date.now()}`, file!.name) - // 上传文件 - const res: OSS.MultipartUploadResult = await uploadFileToOSS(client, file, path, (progress) => { - item.progress = Math.floor(progress * 10000) / 100 - }) - const url = browserPathJoin(import.meta.env.VITE_BASE_OSS_URL, res.name) - upFileList.value.splice(upFileList.value.indexOf(item), 1) - return Promise.resolve(url) - // oxlint-disable-next-line no-unused-vars - } - catch (error: any) { - upFileList.value.splice(upFileList.value.indexOf(item), 1) - window.$message?.error(`上传失败: ${error.message}`) - return Promise.resolve(false) - } -} - -/** 编辑视频属性 */ -export function editVideoAttribute(node: HTMLVideoElement, isReplace = true) { - node.setAttribute('style', 'max-width: 100%;') // 强制内联样式 - node.classList.add('my-ql-video') - isReplace && replaceFileUrl(node) -} - -/** 编辑图片属性 */ -export function editImageAttribute(node: HTMLImageElement, isReplace = true) { - node.setAttribute('style', 'max-width: 100%;') // 强制内联样式 - node.classList.add('my-ql-image') - isReplace && replaceFileUrl(node) -} - -/** - * base64替换为url地址 - * @param node - */ -export function replaceFileUrl(node: HTMLImageElement | HTMLVideoElement) { - const ex = getExtensionFromDataUrl(node.src) - if (ex) { - const file = base64ToFile(node.src, `${Date.now()}_${getSnowflake()}.${ex}`) - upFileAxios(file, file.name) - } -} - -const mimeToExtension: Record = { - 'image/png': 'png', - 'image/jpeg': 'jpg', - 'image/jpg': 'jpg', - 'image/gif': 'gif', - 'image/webp': 'webp', - 'image/svg': 'webp', - 'video/mp4': 'mp4', - 'audio/mpeg': 'mp3', - 'application/pdf': 'pdf', - 'text/plain': 'txt', -} - -/** - * 从 base64 获取文件扩展名 - * @param dataUrl - * @param mimeMap - */ -function getExtensionFromDataUrl(dataUrl: string, mimeMap = mimeToExtension): string | null { - const base64Pattern = /^data:(image|video)\/([a-zA-Z]+);base64,([A-Za-z0-9+/]+={0,2})$/ - if (base64Pattern.test(dataUrl)) { - const mimeType = dataUrl.split(',')?.[0]?.split(':')?.[1]?.split(';')[0] - return mimeType && mimeType in mimeMap ? mimeMap[mimeType]! : null - } - else { - return null - } -} diff --git a/apps/admin/src/components/common/rest-basic-editor/rest-basic-editor.vue b/apps/admin/src/components/common/rest-basic-editor/rest-basic-editor.vue deleted file mode 100644 index 13bbcd1..0000000 --- a/apps/admin/src/components/common/rest-basic-editor/rest-basic-editor.vue +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - diff --git a/apps/admin/src/components/common/rest-basic-editor/types.ts b/apps/admin/src/components/common/rest-basic-editor/types.ts deleted file mode 100644 index 254b973..0000000 --- a/apps/admin/src/components/common/rest-basic-editor/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { ToolbarOptions } from '@opentiny/fluent-editor' -import type { MY_OPEN_PROCESSON_IFRAME } from './editor-util' - -export interface MyToolbarOption { - /** 是否显示工具栏 */ - show?: boolean - /** 是否显示上传文件按钮 */ - showUpFile?: boolean - /** 是否显示上传视频按钮 */ - showUpVideo?: boolean - /** 自定义工具栏 */ - customToolbar?: ToolbarOptions['container'] -} - -export interface GetEditorConfigParams { - toolbarOption?: MyToolbarOption - [MY_OPEN_PROCESSON_IFRAME]: () => void -} -export interface UpFile { - id: string - name: string - progress: number -} diff --git a/apps/admin/src/components/common/rest-draggable-resizable/rest-draggable-resizable.vue b/apps/admin/src/components/common/rest-draggable-resizable/rest-draggable-resizable.vue deleted file mode 100644 index ec020ce..0000000 --- a/apps/admin/src/components/common/rest-draggable-resizable/rest-draggable-resizable.vue +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/def-data.ts b/apps/admin/src/views/template/template-detail/def-data.ts deleted file mode 100644 index f1f9b14..0000000 --- a/apps/admin/src/views/template/template-detail/def-data.ts +++ /dev/null @@ -1,36 +0,0 @@ - -import type { QuestionInfo } from './types'; - -export const topicTypeList = [ - { label: '单选题', value: 1 }, - { label: '多选题', value: 2 }, - { label: '判断题', value: 3 }, - { label: '填空题', value: 4 }, - { label: '简答题', value: 5 }, -]; - -export const topicType2List = [ - { label: '普通题', value: 100 }, - { label: '大题号', value: 101 }, - { label: '子题号', value: 102 }, -]; - -export function defAnswerInfo(x: number) { - return { - x: x, - y: 0, - w: 100, - h: 50, - }; -} - -export function defQuestionInfo(no: string, type: number, y: number, pageWidth: number): QuestionInfo { - return { - no, - type, - x: 0, - y: y, - w: pageWidth, - h: 100, // Default height - }; -} diff --git a/apps/admin/src/views/template/template-detail/index.vue b/apps/admin/src/views/template/template-detail/index.vue index 4049b65..1d273dc 100644 --- a/apps/admin/src/views/template/template-detail/index.vue +++ b/apps/admin/src/views/template/template-detail/index.vue @@ -1,74 +1,9 @@ - - - - - - - - - - - 编辑书籍 - - - - - - - - 保存 - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/apps/admin/src/views/template/template-detail/modules/left-tree/components/import-bubble.vue b/apps/admin/src/views/template/template-detail/modules/left-tree/components/import-bubble.vue deleted file mode 100644 index 2841ff3..0000000 --- a/apps/admin/src/views/template/template-detail/modules/left-tree/components/import-bubble.vue +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - 用于排除部分书籍(封面/目录/引言)等没有页码的页面 - - 第1页开始于: - - - - 第 - 张PDF - - - - - - - - - - 开始导入 - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/left-tree/components/menu-bubble.vue b/apps/admin/src/views/template/template-detail/modules/left-tree/components/menu-bubble.vue deleted file mode 100644 index 77bf932..0000000 --- a/apps/admin/src/views/template/template-detail/modules/left-tree/components/menu-bubble.vue +++ /dev/null @@ -1,123 +0,0 @@ - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/left-tree/left-tree.vue b/apps/admin/src/views/template/template-detail/modules/left-tree/left-tree.vue deleted file mode 100644 index 02c86db..0000000 --- a/apps/admin/src/views/template/template-detail/modules/left-tree/left-tree.vue +++ /dev/null @@ -1,207 +0,0 @@ - - - - 目录 - - - - - 导入书籍 - - - - - - 重置起始页 - - - - - - - - - {{ option.name }} - - 校验成功 - 校验失败 - - - - - - - - - - 重新加载 - - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/middle-book/components/menu-bubble.vue b/apps/admin/src/views/template/template-detail/modules/middle-book/components/menu-bubble.vue deleted file mode 100644 index f1f3d3c..0000000 --- a/apps/admin/src/views/template/template-detail/modules/middle-book/components/menu-bubble.vue +++ /dev/null @@ -1,95 +0,0 @@ - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/middle-book/components/topic-item-module.vue b/apps/admin/src/views/template/template-detail/modules/middle-book/components/topic-item-module.vue deleted file mode 100644 index 57439d7..0000000 --- a/apps/admin/src/views/template/template-detail/modules/middle-book/components/topic-item-module.vue +++ /dev/null @@ -1,312 +0,0 @@ - - - - - - {{ questions?.no }} - - {{ showType }} - - - 配 - - - 答 - 解 - - - - - - - - - - - - - - {{ questions?.no }} - - - - - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/middle-book/middle-book.vue b/apps/admin/src/views/template/template-detail/modules/middle-book/middle-book.vue deleted file mode 100644 index 09399c0..0000000 --- a/apps/admin/src/views/template/template-detail/modules/middle-book/middle-book.vue +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-analysis-bubble.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-analysis-bubble.vue deleted file mode 100644 index 8334399..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-analysis-bubble.vue +++ /dev/null @@ -1,200 +0,0 @@ - - - - - 添加解析 - - - - - 添加自定义选项 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 取消 - 确定 - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-topic-form-bubble.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-topic-form-bubble.vue deleted file mode 100644 index 7d5d20a..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/add-topic-form-bubble.vue +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - 题号 - - - - 第 - 页 - - - - - 第 - 大题 - - - - - 第 - 小题 - - - - - 第 - 部分 - - - - - - - - - - handleSubjectSearch('')" - /> - - - - 分 - - - - - 秒 - - - - - - 取消 - 提交 - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/edit-info-bubble.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/edit-info-bubble.vue deleted file mode 100644 index 780bacf..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/edit-info-bubble.vue +++ /dev/null @@ -1,458 +0,0 @@ - - - - - - - 编辑信息 - - - - - - - 提交 - - - - - - - - - 基本信息 - - - - - - - - - - - - - - - - - - - - - - - - - - - - 正确 - 错误 - - - - - - - - - - - - - - 秒 - - - - - - - - - - - - - 题目 - - 题目 - - - - - - - 答案 - - - - - - - 解析 - - - - - - - - - - - 重试 - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/release-task-bubble.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/release-task-bubble.vue deleted file mode 100644 index 8bed023..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/release-task-bubble.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - 取消 - 提交 - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/right-topic-item.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/right-topic-item.vue deleted file mode 100644 index 7b96d1a..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/components/right-topic-item.vue +++ /dev/null @@ -1,195 +0,0 @@ - - - - - - - {{ topicInfo.question.no }} - - - {{ showType }} - - - - - - - - - - - - 单项解析 - - - - - - - - - - 发布任务(录制讲解音视频) - - - - emit('edit-topic', topicInfo)" - > - - - - - - 编辑或修改信息 - - - - - - - - - - 点击添加答题区域 - - - - - - - - - - 删除题目 - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/right-topic-list-normal.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/right-topic-list-normal.vue deleted file mode 100644 index ab5b2b7..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-normal/right-topic-list-normal.vue +++ /dev/null @@ -1,139 +0,0 @@ - - - - - 普通题目 - - - - - 添加题目 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/add-topic-form-bubble.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/add-topic-form-bubble.vue deleted file mode 100644 index 41113e9..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/add-topic-form-bubble.vue +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - 题号 - - - - 第 - - 页 - - - - - 第 - - 题 - - - - - 第 - - 部分 - - - - - - - - - - - - 取消 - 提交 - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/right-topic-item.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/right-topic-item.vue deleted file mode 100644 index 3458fa5..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/components/right-topic-item.vue +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - {{ topicInfo.question.no }} - - - {{ showType }} - - - - - - emit('edit-topic', $event, topicInfo)" - > - - - - 编辑或修改信息 - - - - - - - - 点击添加区域 - - - - - - - - 删除题目 - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/right-topic-list-special.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/right-topic-list-special.vue deleted file mode 100644 index 7acf226..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/components/right-topic-list-special/right-topic-list-special.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - - 特殊区域 - - - 添加区域 - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/modules/right-topic/right-topic-list.vue b/apps/admin/src/views/template/template-detail/modules/right-topic/right-topic-list.vue deleted file mode 100644 index dab107c..0000000 --- a/apps/admin/src/views/template/template-detail/modules/right-topic/right-topic-list.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/apps/admin/src/views/template/template-detail/pdf-util.ts b/apps/admin/src/views/template/template-detail/pdf-util.ts deleted file mode 100644 index f78137a..0000000 --- a/apps/admin/src/views/template/template-detail/pdf-util.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { ImageInfo } from './types'; - -export async function convertPDFToImageFiles(file: File): Promise<{ list: ImageInfo[], pdf: File }> { - console.warn('PDF conversion requires pdfjs-dist, which is missing. Returning empty list.'); - return { list: [], pdf: file }; -} - -export async function getPDFPageWidth(file: File): Promise { - console.warn('PDF conversion requires pdfjs-dist, which is missing. Returning 0.'); - return 0; -} diff --git a/apps/admin/src/views/template/template-detail/types.ts b/apps/admin/src/views/template/template-detail/types.ts deleted file mode 100644 index 947a9bf..0000000 --- a/apps/admin/src/views/template/template-detail/types.ts +++ /dev/null @@ -1,100 +0,0 @@ - -export interface BookBaseData { - width?: number; - height?: number; -} - -export interface QuestionInfo { - type?: number; - x: number; - y: number; - w: number; - h: number; - no: string; -} - -export interface LayoutItem { - questionId: number; - question: QuestionInfo; - answerList?: any[]; // Added based on topic-item-module usage -} - -export interface BookPageQuestion { - id: number; - type?: number; - [key: string]: any; -} - -export interface BookPageAreas { - id: number; - [key: string]: any; -} - -export interface CurrBookPageData { - url?: string; - bookPageId?: number; - layout: LayoutItem[]; - questions: BookPageQuestion[]; - areas: BookPageAreas[]; -} - -export interface CurrBookPageAllInfo { - bookBaseData: BookBaseData; - currBookPageData: CurrBookPageData; -} - -export type QuestionType = number; - -export interface QuestionsImages { - // Add properties as needed based on usage in util.ts - [key: string]: any; -} - -export interface CropImageOptions { - x: number; - y: number; - width: number; - height: number; -} - -export interface AddBookTopicForm { - type?: 100 | 101 | 102; - pageNumb?: number; - bigTpicNumb?: number; - subTopicNumb?: number; -} - -export interface BookPageOtherAddInput { - bookId: number; - bookPageId: number; - no: string; - type: number; -} - -export interface BookPageOtherUpdateInput { - bookId: number; - bookPageId: number; - no: string; - type: number; - id: number; -} - -export interface TopicInfo { - question: QuestionInfo; - answerList?: any[]; - questionId: number; -} - -export interface AnswerInfo { - x: number; - y: number; - w: number; - h: number; -} - -export interface ImageInfo { - file: File; - width: number; - height: number; - url?: string; -} diff --git a/apps/admin/src/views/template/template-detail/util.ts b/apps/admin/src/views/template/template-detail/util.ts deleted file mode 100644 index 75e8909..0000000 --- a/apps/admin/src/views/template/template-detail/util.ts +++ /dev/null @@ -1,138 +0,0 @@ - -import { ref } from 'vue'; -import pLimit from 'p-limit'; -import { type BookPageQuestion, type QuestionsImages, updateBookPageLayoutAxios } from '@/service/api/book'; -import { getAliOssTokenAxios } from '@/service/api/upload'; -import { initOSSClient } from '@/utils/oss'; -import type { CropImageOptions, CurrBookPageAllInfo, QuestionInfo } from './types'; -import { compareVersion } from '@/utils/common'; - -// Crop image function implementation -const cropImage = async (url: string, client: any, options: CropImageOptions, id: number): Promise => { - return new Promise((resolve, reject) => { - const img = new Image(); - img.crossOrigin = 'anonymous'; - img.src = url; - img.onload = async () => { - try { - const canvas = document.createElement('canvas'); - canvas.width = options.width; - canvas.height = options.height; - const ctx = canvas.getContext('2d'); - if (!ctx) { - reject(new Error('Canvas context not available')); - return; - } - - // Draw cropped image - ctx.drawImage( - img, - options.x, - options.y, - options.width, - options.height, - 0, - 0, - options.width, - options.height - ); - - // Convert to Blob - canvas.toBlob(async (blob) => { - if (!blob) { - reject(new Error('Canvas to Blob failed')); - return; - } - - const file = new File([blob], `question_${id}_${Date.now()}.png`, { type: 'image/png' }); - const path = `book/questions/${id}/${file.name}`; - - try { - // Upload to OSS - // Assuming client.put or multipartUpload. - // Since initOSSClient returns an OSS client, we can use it. - // Using put for small files (cropped images are usually small) - const result = await client.put(path, file); - - // Return the result format expected by the API - // The API expects a map of ID to URL? Or array of objects? - // Based on usage: `tasks.push(...)` and `imageFiles.push(...list)` - // And `updateBookPageLayoutAxios` takes `questionsImages: imageFiles` - // Let's return an object with the ID as key and URL as value, or just the URL object if QuestionsImages is a type. - // Looking at previous usage `urlObj[item.id!] = item`, it seems `QuestionsImages` might be `{ [id]: url }`. - - resolve({ [id]: result.url }); - } catch (err) { - reject(err); - } - }, 'image/png'); - } catch (err) { - reject(err); - } - }; - img.onerror = (err) => { - reject(new Error('Image load failed')); - }; - }); -}; - -/** 提交 */ -export function usePageLayoutSubmit() { - const submmitLoading = ref(false); - - async function pageLayoutSubmit(currBookPage: CurrBookPageAllInfo) { - try { - submmitLoading.value = true; - const urlObj: Record = {}; - currBookPage!.currBookPageData.questions.forEach((item) => { - if (item.id) { - urlObj[item.id!] = item; - } - }); - - // 获取阿里云OSS STS - const aliOssSTS = await getAliOssTokenAxios(); - const client = initOSSClient(aliOssSTS); - - // 截取图片并上传 (5个并发) - const imageFiles: QuestionsImages[] = []; - const limit = pLimit(5); - const tasks: Promise[] = []; - currBookPage!.currBookPageData.layout.forEach((item) => { - const question: QuestionInfo = item.question; - if (currBookPage!.currBookPageData.url) { - const cropImageOptions: CropImageOptions = { x: question.x, y: question.y, width: question.w, height: question.h }; - const url = currBookPage!.currBookPageData.url; - //截取图片并添加到上传队列 - tasks.push(limit(() => cropImage(url, client, cropImageOptions, item.questionId!))); - } - }); - - const list = await Promise.all(tasks); - imageFiles.push(...list); - - currBookPage!.currBookPageData.layout = currBookPage!.currBookPageData.layout.sort((a, b) => { - return compareVersion(a.question.no, b.question.no, '-'); - }); - await updateBookPageLayoutAxios({ - id: currBookPage!.currBookPageData!.bookPageId!, - layout: JSON.stringify(currBookPage!.currBookPageData.layout), - questionsImages: imageFiles, - }); - submmitLoading.value = false; - return Promise.resolve(); - } catch (error) { - console.log('error====', error); - submmitLoading.value = false; - return Promise.reject(error); - } - } - return { - pageLayoutSubmit, - submmitLoading, - }; -} - -export function getPDFPageWidth(width: number) { - return width; -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c90e539..cf2aa5c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,9 +32,6 @@ importers: '@better-scroll/core': specifier: 2.5.1 version: 2.5.1 - '@formkit/auto-animate': - specifier: ^0.9.0 - version: 0.9.0 '@iconify/vue': specifier: 5.0.0 version: 5.0.0(vue@3.5.26(typescript@5.9.3)) @@ -56,15 +53,9 @@ importers: '@sa/utils': specifier: workspace:* version: link:../../packages/utils - '@sapphire/snowflake': - specifier: ^3.5.5 - version: 3.5.5 '@vueuse/core': specifier: 14.1.0 version: 14.1.0(vue@3.5.26(typescript@5.9.3)) - '@zumer/snapdom': - specifier: ^2.0.1 - version: 2.0.2 ali-oss: specifier: ^6.23.0 version: 6.23.0 @@ -83,12 +74,6 @@ importers: json5: specifier: 2.2.3 version: 2.2.3 - katex: - specifier: ^0.16.27 - version: 0.16.27 - mathlive: - specifier: ^0.108.2 - version: 0.108.2 naive-ui: specifier: 2.43.2 version: 2.43.2(vue@3.5.26(typescript@5.9.3)) @@ -573,10 +558,6 @@ packages: '@clack/prompts@0.9.1': resolution: {integrity: sha512-JIpyaboYZeWYlyP0H+OoPPxd6nqueG/CmN6ixBiNFsIDHREevjIf0n0Ohh5gr5C8pEDknzgvz+pIJ8dMhzWIeg==} - '@cortex-js/compute-engine@0.30.2': - resolution: {integrity: sha512-Zx+iisk9WWdbxjm8EYsneIBszvjfUs7BHNwf1jBtSINIgfWGpHrTTq9vW0J59iGCFt6bOFxbmWyxNMRSmksHMA==} - engines: {node: '>=21.7.3', npm: '>=10.5.0'} - '@css-render/plugin-bem@0.15.14': resolution: {integrity: sha512-QK513CJ7yEQxm/P3EwsI+d+ha8kSOcjGvD6SevM41neEMxdULE+18iuQK6tEChAWMOQNQPLG/Rw3Khb69r5neg==} peerDependencies: @@ -858,9 +839,6 @@ packages: '@floating-ui/utils@0.2.10': resolution: {integrity: sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==} - '@formkit/auto-animate@0.9.0': - resolution: {integrity: sha512-VhP4zEAacXS3dfTpJpJ88QdLqMTcabMg0jwpOSxZ/VzfQVfl3GkZSCZThhGC5uhq/TxPHPzW0dzr4H9Bb1OgKA==} - '@humanfs/core@0.19.1': resolution: {integrity: sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==} engines: {node: '>=18.18.0'} @@ -1181,10 +1159,6 @@ packages: cpu: [x64] os: [win32] - '@sapphire/snowflake@3.5.5': - resolution: {integrity: sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==} - engines: {node: '>=v14.0.0', npm: '>=7.0.0'} - '@sec-ant/readable-stream@0.4.1': resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} @@ -1702,9 +1676,6 @@ packages: peerDependencies: vue: ^3.5.0 - '@zumer/snapdom@2.0.2': - resolution: {integrity: sha512-W6quT4lMcPu8Q9O/Q6witSfc6/+xuY8C8yDoHug/+o7zYKCNE/e0I3//XsWDkyq9C0mDE0TAWF/8bwCR7x3gHQ==} - acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -2065,18 +2036,10 @@ packages: resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==} engines: {node: '>= 10'} - commander@8.3.0: - resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} - engines: {node: '>= 12'} - comment-parser@1.4.1: resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==} engines: {node: '>= 12.0.0'} - complex-esm@2.1.1-esm1: - resolution: {integrity: sha512-IShBEWHILB9s7MnfyevqNGxV0A1cfcSnewL/4uPFiSxkcQL4Mm3FxJ0pXMtCXuWLjYz3lRRyk6OfkeDZcjD6nw==} - engines: {node: '>=16.14.2', npm: '>=8.5.0'} - component-emitter@1.3.1: resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==} @@ -2216,9 +2179,6 @@ packages: supports-color: optional: true - decimal.js@10.6.0: - resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==} - decode-named-character-reference@1.2.0: resolution: {integrity: sha512-c6fcElNV6ShtZXmsgNgFFV5tVX2PaV4g+MOAkb8eXHvn6sryJBrZa9r0zV6+dtTyoCKxtDy5tyQ5ZwQuidtd+Q==} @@ -3399,10 +3359,6 @@ packages: jstoxml@2.2.9: resolution: {integrity: sha512-OYWlK0j+roh+eyaMROlNbS5cd5R25Y+IUpdl7cNdB8HNrkgwQzIS7L9MegxOiWNBj9dQhA/yAxiMwCC5mwNoBw==} - katex@0.16.27: - resolution: {integrity: sha512-aeQoDkuRWSqQN6nSvVCEFvfXdqo1OQiCmmW1kc9xSdjutPv7BGO7pqY9sQRJpMOGrEdfDgF2TfRXe5eUAD2Waw==} - hasBin: true - keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} @@ -3528,9 +3484,6 @@ packages: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} - mathlive@0.108.2: - resolution: {integrity: sha512-GIZkfprGTxrbHckOvwo92ZmOOxdD018BHDzlrEwYUU+pzR5KabhqI1s43lxe/vqXdF5RLiQKgDcuk5jxEjhkYg==} - mdast-util-find-and-replace@3.0.2: resolution: {integrity: sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==} @@ -5488,11 +5441,6 @@ snapshots: picocolors: 1.1.1 sisteransi: 1.0.5 - '@cortex-js/compute-engine@0.30.2': - dependencies: - complex-esm: 2.1.1-esm1 - decimal.js: 10.6.0 - '@css-render/plugin-bem@0.15.14(css-render@0.15.14)': dependencies: css-render: 0.15.14 @@ -5730,8 +5678,6 @@ snapshots: '@floating-ui/utils@0.2.10': {} - '@formkit/auto-animate@0.9.0': {} - '@humanfs/core@0.19.1': {} '@humanfs/node@0.16.7': @@ -5976,8 +5922,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.54.0': optional: true - '@sapphire/snowflake@3.5.5': {} - '@sec-ant/readable-stream@0.4.1': {} '@sindresorhus/merge-streams@4.0.0': {} @@ -6049,7 +5993,7 @@ snapshots: '@stylistic/eslint-plugin@2.13.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)': dependencies: - '@typescript-eslint/utils': 8.50.1(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3) + '@typescript-eslint/utils': 8.53.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3) eslint: 9.39.2(jiti@2.6.1) eslint-visitor-keys: 4.2.1 espree: 10.4.0 @@ -6630,8 +6574,6 @@ snapshots: dependencies: vue: 3.5.26(typescript@5.9.3) - '@zumer/snapdom@2.0.2': {} - acorn-jsx@5.3.2(acorn@8.15.0): dependencies: acorn: 8.15.0 @@ -7035,12 +6977,8 @@ snapshots: commander@7.2.0: {} - commander@8.3.0: {} - comment-parser@1.4.1: {} - complex-esm@2.1.1-esm1: {} - component-emitter@1.3.1: {} concat-map@0.0.1: {} @@ -7159,8 +7097,6 @@ snapshots: dependencies: ms: 2.1.3 - decimal.js@10.6.0: {} - decode-named-character-reference@1.2.0: dependencies: character-entities: 2.0.2 @@ -8467,10 +8403,6 @@ snapshots: jstoxml@2.2.9: {} - katex@0.16.27: - dependencies: - commander: 8.3.0 - keyv@4.5.4: dependencies: json-buffer: 3.0.1 @@ -8599,10 +8531,6 @@ snapshots: math-intrinsics@1.1.0: {} - mathlive@0.108.2: - dependencies: - '@cortex-js/compute-engine': 0.30.2 - mdast-util-find-and-replace@3.0.2: dependencies: '@types/mdast': 4.0.4