mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-09 11:39:31 +08:00
fix: 清理掉了所有warn,优化了在移动端侧边栏的逻辑问题
This commit is contained in:
@@ -48,8 +48,16 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleMenuOutside = () => {
|
const handleMenuOutside = (event) => {
|
||||||
if (isMobile.value) menuVisible.value = false
|
// 检查点击事件是否来自菜单按钮
|
||||||
|
const menuBtn = document.querySelector('.menu-btn')
|
||||||
|
if (menuBtn && (menuBtn === event.target || menuBtn.contains(event.target))) {
|
||||||
|
return // 如果是菜单按钮的点击,不处理关闭
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMobile.value) {
|
||||||
|
menuVisible.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { menuVisible, hideMenu, handleMenuOutside }
|
return { menuVisible, hideMenu, handleMenuOutside }
|
||||||
|
|||||||
@@ -43,4 +43,9 @@ export default defineNuxtConfig({
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
vue: {
|
||||||
|
compilerOptions: {
|
||||||
|
isCustomElement: (tag) => ['l-hatch', 'l-hatch-spinner'].includes(tag),
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ import TimeManager from '~/utils/time'
|
|||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useIsMobile } from '~/utils/screen'
|
import { useIsMobile } from '~/utils/screen'
|
||||||
import Dropdown from '~/components/Dropdown.vue'
|
import Dropdown from '~/components/Dropdown.vue'
|
||||||
|
import { ClientOnly } from '#components'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PostPageView',
|
name: 'PostPageView',
|
||||||
@@ -262,6 +263,7 @@ export default {
|
|||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
VueEasyLightbox,
|
VueEasyLightbox,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
|
ClientOnly,
|
||||||
},
|
},
|
||||||
async setup() {
|
async setup() {
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|||||||
@@ -297,27 +297,26 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, computed, onMounted, watch } from 'vue'
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import { API_BASE_URL, toast } from '~/main'
|
import AchievementList from '~/components/AchievementList.vue'
|
||||||
import { getToken, authState } from '~/utils/auth'
|
|
||||||
import BaseTimeline from '~/components/BaseTimeline.vue'
|
|
||||||
import UserList from '~/components/UserList.vue'
|
|
||||||
import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
||||||
|
import BaseTimeline from '~/components/BaseTimeline.vue'
|
||||||
import LevelProgress from '~/components/LevelProgress.vue'
|
import LevelProgress from '~/components/LevelProgress.vue'
|
||||||
|
import UserList from '~/components/UserList.vue'
|
||||||
|
import { API_BASE_URL, toast } from '~/main'
|
||||||
|
import { authState, getToken } from '~/utils/auth'
|
||||||
|
import { prevLevelExp } from '~/utils/level'
|
||||||
import { stripMarkdown, stripMarkdownLength } from '~/utils/markdown'
|
import { stripMarkdown, stripMarkdownLength } from '~/utils/markdown'
|
||||||
import TimeManager from '~/utils/time'
|
import TimeManager from '~/utils/time'
|
||||||
import { prevLevelExp } from '~/utils/level'
|
|
||||||
import AchievementList from '~/components/AchievementList.vue'
|
|
||||||
|
|
||||||
definePageMeta({
|
|
||||||
alias: ['/users/:id/'],
|
|
||||||
})
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ProfileView',
|
name: 'ProfileView',
|
||||||
components: { BaseTimeline, UserList, BasePlaceholder, LevelProgress, AchievementList },
|
components: { BaseTimeline, UserList, BasePlaceholder, LevelProgress, AchievementList },
|
||||||
setup() {
|
setup() {
|
||||||
|
definePageMeta({
|
||||||
|
alias: ['/users/:id/'],
|
||||||
|
})
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const username = route.params.id
|
const username = route.params.id
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// plugins/ldrs.client.ts
|
// plugins/ldrs.client.ts
|
||||||
import { defineNuxtPlugin } from '#app'
|
import { defineNuxtPlugin } from 'nuxt/app'
|
||||||
|
|
||||||
export default defineNuxtPlugin(async () => {
|
export default defineNuxtPlugin(async () => {
|
||||||
// 动态引入,防止打包时把 ldrs 拉进 SSR bundle
|
// 动态引入,防止打包时把 ldrs 拉进 SSR bundle
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import NProgress from 'nprogress'
|
import NProgress from 'nprogress'
|
||||||
import 'nprogress/nprogress.css'
|
import 'nprogress/nprogress.css'
|
||||||
|
import { defineNuxtPlugin } from 'nuxt/app'
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
@@ -12,7 +13,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
NProgress.done()
|
NProgress.done()
|
||||||
})
|
})
|
||||||
|
|
||||||
nuxtApp.hook('page:error', () => {
|
nuxtApp.hook('app:error', () => {
|
||||||
NProgress.done()
|
NProgress.done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { defineNuxtPlugin } from '#app'
|
import { defineNuxtPlugin } from 'nuxt/app'
|
||||||
import { initTheme } from '~/utils/theme'
|
import { initTheme } from '~/utils/theme'
|
||||||
|
|
||||||
export default defineNuxtPlugin(() => {
|
export default defineNuxtPlugin(() => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { defineNuxtPlugin } from '#app'
|
import { defineNuxtPlugin } from 'nuxt/app'
|
||||||
import 'vue-toastification/dist/index.css'
|
import 'vue-toastification/dist/index.css'
|
||||||
import '~/assets/toast.css'
|
import '~/assets/toast.css'
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import MarkdownIt from 'markdown-it'
|
|
||||||
import hljs from 'highlight.js'
|
import hljs from 'highlight.js'
|
||||||
import 'highlight.js/styles/github.css'
|
import 'highlight.js/styles/github.css'
|
||||||
|
import MarkdownIt from 'markdown-it'
|
||||||
import { toast } from '../main'
|
import { toast } from '../main'
|
||||||
import { tiebaEmoji } from './tiebaEmoji'
|
import { tiebaEmoji } from './tiebaEmoji'
|
||||||
|
|
||||||
@@ -86,18 +86,19 @@ export function handleMarkdownClick(e) {
|
|||||||
|
|
||||||
export function stripMarkdown(text) {
|
export function stripMarkdown(text) {
|
||||||
const html = md.render(text || '')
|
const html = md.render(text || '')
|
||||||
// SSR 环境下没有 document
|
|
||||||
if (typeof window === 'undefined') {
|
// 统一使用正则表达式方法,确保服务端和客户端行为一致
|
||||||
// 用正则去除 HTML 标签
|
let plainText = html.replace(/<[^>]+>/g, '')
|
||||||
return html
|
|
||||||
.replace(/<[^>]+>/g, '')
|
// 标准化空白字符处理
|
||||||
.replace(/\s+/g, ' ')
|
plainText = plainText
|
||||||
|
.replace(/\r\n/g, '\n') // Windows换行符转为Unix格式
|
||||||
|
.replace(/\r/g, '\n') // 旧Mac换行符转为Unix格式
|
||||||
|
.replace(/[ \t]+/g, ' ') // 合并空格和制表符为单个空格
|
||||||
|
.replace(/\n{3,}/g, '\n\n') // 最多保留两个连续换行(一个空行)
|
||||||
.trim()
|
.trim()
|
||||||
} else {
|
|
||||||
const el = document.createElement('div')
|
return plainText
|
||||||
el.innerHTML = html
|
|
||||||
return el.textContent || el.innerText || ''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stripMarkdownLength(text, length) {
|
export function stripMarkdownLength(text, length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user