diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts index ef53d16..235bc2d 100644 --- a/src/auto-imports.d.ts +++ b/src/auto-imports.d.ts @@ -89,6 +89,7 @@ declare global { const onUnmounted: typeof import('vue')['onUnmounted'] const onUpdated: typeof import('vue')['onUpdated'] const onWatcherCleanup: typeof import('vue')['onWatcherCleanup'] + const parseHTMLToNodes: typeof import('./utils/richText')['default'] const pausableWatch: typeof import('@vueuse/core')['pausableWatch'] const provide: typeof import('vue')['provide'] const provideLocal: typeof import('@vueuse/core')['provideLocal'] @@ -105,9 +106,11 @@ declare global { const refDefault: typeof import('@vueuse/core')['refDefault'] const refThrottled: typeof import('@vueuse/core')['refThrottled'] const refWithControl: typeof import('@vueuse/core')['refWithControl'] + const repairRichText: typeof import('./utils/richText')['repairRichText'] const resolveComponent: typeof import('vue')['resolveComponent'] const resolveRef: typeof import('@vueuse/core')['resolveRef'] const resolveUnref: typeof import('@vueuse/core')['resolveUnref'] + const sanitizeRichTextImages: typeof import('./utils/richText')['sanitizeRichTextImages'] const shallowReactive: typeof import('vue')['shallowReactive'] const shallowReadonly: typeof import('vue')['shallowReadonly'] const shallowRef: typeof import('vue')['shallowRef'] @@ -424,6 +427,7 @@ declare module 'vue' { readonly resolveComponent: UnwrapRef readonly resolveRef: UnwrapRef readonly resolveUnref: UnwrapRef + readonly sanitizeRichTextImages: UnwrapRef readonly shallowReactive: UnwrapRef readonly shallowReadonly: UnwrapRef readonly shallowRef: UnwrapRef diff --git a/src/pages.json b/src/pages.json index b9d5964..66c097b 100644 --- a/src/pages.json +++ b/src/pages.json @@ -18,6 +18,10 @@ "path": "pages/me/index", "type": "page" }, + { + "path": "pages/pet-manual/article", + "type": "page" + }, { "path": "pages/pet-manual/index", "type": "page" diff --git a/src/pages/pet-manual/article.vue b/src/pages/pet-manual/article.vue new file mode 100644 index 0000000..fe69e03 --- /dev/null +++ b/src/pages/pet-manual/article.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/uni-pages.d.ts b/src/uni-pages.d.ts index f9e690a..31ff4c0 100644 --- a/src/uni-pages.d.ts +++ b/src/uni-pages.d.ts @@ -7,6 +7,7 @@ interface NavigateToOptions { url: "/pages/feed-plan/index" | "/pages/home/index" | "/pages/me/index" | + "/pages/pet-manual/article" | "/pages/pet-manual/index"; } interface RedirectToOptions extends NavigateToOptions {} diff --git a/src/utils/richText.ts b/src/utils/richText.ts new file mode 100644 index 0000000..62efe48 --- /dev/null +++ b/src/utils/richText.ts @@ -0,0 +1,26 @@ + + +function sanitizeRichTextImages(html: string): string { + let newContent = html.replace(/]*>/gi, (match: string): string => { + match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '') + match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '') + match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '') + match = match.replace(/style\s*=\s*(["'])(?:(?!\1).)*\1/gi, '') + return match + }) + + newContent = newContent.replace(/style="[^"]+"/gi, (match: string): string => { + match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi, 'max-width:100%;') + return match + }) + + newContent = newContent.replace(/]*\/>/gi, '') + + newContent = newContent.replace(/