Merge branch 'main' of github.com:nagisa77/OpenIsle

This commit is contained in:
tim
2025-09-10 18:13:16 +08:00
2 changed files with 54 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
package com.openisle.schdule;
package com.openisle.scheduler;
import com.openisle.config.CachingConfig;
import com.openisle.model.User;

View File

@@ -6,8 +6,15 @@
</div>
<div class="comment-bottom-container">
<div class="comment-submit" :class="{ disabled: isDisabled }" @click="submit">
<template v-if="!loading"> 发布评论 </template>
<template v-else> <loading-four /> 发布中... </template>
<template v-if="!loading">
发布评论
<span class="shortcut-icon" v-if="!isMobile">
{{ isMac ? '' : 'Ctrl' }}
</span>
</template>
<template v-else>
<loading-four /> 发布中...
</template>
</div>
</div>
</div>
@@ -24,6 +31,7 @@ import {
} from '~/utils/vditor'
import '~/assets/global.css'
import LoginOverlay from '~/components/LoginOverlay.vue'
import { useIsMobile } from '~/utils/screen'
export default {
name: 'CommentEditor',
@@ -52,12 +60,22 @@ export default {
},
components: { LoginOverlay },
setup(props, { emit }) {
const isMobile = useIsMobile()
const vditorInstance = ref(null)
const text = ref('')
const editorId = ref(props.editorId)
if (!editorId.value) {
editorId.value = 'editor-' + useId()
}
const isMac = ref(false)
if (navigator.userAgentData) {
isMac.value = navigator.userAgentData.platform === 'macOS'
} else {
isMac.value = /Mac|iPhone|iPad|iPod/.test(navigator.userAgent)
}
const getEditorTheme = getEditorThemeUtil
const getPreviewTheme = getPreviewThemeUtil
const applyTheme = () => {
@@ -96,7 +114,27 @@ export default {
applyTheme()
},
})
// applyTheme()
// 不是手机的情况下不添加快捷键
if(!isMobile.value){
// 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter)
const handleKeydown = (e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
e.preventDefault()
submit()
}
}
const el = document.getElementById(editorId.value)
if (el) {
el.addEventListener('keydown', handleKeydown)
}
onUnmounted(() => {
if (el) {
el.removeEventListener('keydown', handleKeydown)
}
})
}
})
onUnmounted(() => {
@@ -134,7 +172,7 @@ export default {
},
)
return { submit, isDisabled, editorId }
return { submit, isDisabled, editorId, isMac, isMobile}
},
}
</script>
@@ -174,10 +212,16 @@ export default {
.comment-submit:hover {
background-color: var(--primary-color-hover);
}
@media (max-width: 768px) {
.comment-editor-container {
margin-bottom: 10px;
}
/** 评论按钮快捷键样式 */
.shortcut-icon {
padding: 2px 6px;
border-radius: 6px;
font-size: 12px;
font-weight: 500;
line-height: 1.2;
background-color: rgba(0, 0, 0, 0.25);
}
.comment-submit.disabled .shortcut-icon {
background-color: rgba(0, 0, 0, 0);
}
</style>