mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-04-21 03:17:28 +08:00
fix: 后端代码格式化
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* Maple Mono - Thin 100 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-100-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-100-normal.woff2') format('woff2');
|
||||
font-weight: 100;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
/* Maple Mono - Thin Italic 100 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-100-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-100-italic.woff2') format('woff2');
|
||||
font-weight: 100;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
/* Maple Mono - ExtraLight 200 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-200-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-200-normal.woff2') format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -27,8 +27,8 @@
|
||||
|
||||
/* Maple Mono - ExtraLight Italic 200 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-200-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-200-italic.woff2') format('woff2');
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -36,8 +36,8 @@
|
||||
|
||||
/* Maple Mono - Light 300 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-300-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-300-normal.woff2') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -45,8 +45,8 @@
|
||||
|
||||
/* Maple Mono - Light Italic 300 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-300-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-300-italic.woff2') format('woff2');
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -54,8 +54,8 @@
|
||||
|
||||
/* Maple Mono - Regular 400 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-400-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-400-normal.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -63,8 +63,8 @@
|
||||
|
||||
/* Maple Mono - Italic 400 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-400-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-400-italic.woff2') format('woff2');
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -72,8 +72,8 @@
|
||||
|
||||
/* Maple Mono - Medium 500 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-500-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-500-normal.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -81,8 +81,8 @@
|
||||
|
||||
/* Maple Mono - Medium Italic 500 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-500-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-500-italic.woff2') format('woff2');
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -90,8 +90,8 @@
|
||||
|
||||
/* Maple Mono - SemiBold 600 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-600-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-600-normal.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -99,8 +99,8 @@
|
||||
|
||||
/* Maple Mono - SemiBold Italic 600 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-600-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-600-italic.woff2') format('woff2');
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -108,8 +108,8 @@
|
||||
|
||||
/* Maple Mono - Bold 700 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-700-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-700-normal.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -117,8 +117,8 @@
|
||||
|
||||
/* Maple Mono - Bold Italic 700 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-700-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-700-italic.woff2') format('woff2');
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
@@ -126,8 +126,8 @@
|
||||
|
||||
/* Maple Mono - ExtraBold 800 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-800-normal.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-800-normal.woff2') format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
@@ -135,8 +135,8 @@
|
||||
|
||||
/* Maple Mono - ExtraBold Italic 800 */
|
||||
@font-face {
|
||||
font-family: "Maple Mono";
|
||||
src: url("/fonts/maple-mono-800-italic.woff2") format("woff2");
|
||||
font-family: 'Maple Mono';
|
||||
src: url('/fonts/maple-mono-800-italic.woff2') format('woff2');
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
|
||||
@@ -8,13 +8,9 @@
|
||||
<div class="comment-submit" :class="{ disabled: isDisabled }" @click="submit">
|
||||
<template v-if="!loading">
|
||||
发布评论
|
||||
<span class="shortcut-icon" v-if="!isMobile">
|
||||
{{ isMac ? '⌘' : 'Ctrl' }} ⏎
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<loading-four /> 发布中...
|
||||
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
||||
</template>
|
||||
<template v-else> <loading-four /> 发布中... </template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -115,7 +111,7 @@ export default {
|
||||
},
|
||||
})
|
||||
// 不是手机的情况下不添加快捷键
|
||||
if(!isMobile.value){
|
||||
if (!isMobile.value) {
|
||||
// 添加快捷键监听 (Ctrl+Enter 或 Cmd+Enter)
|
||||
const handleKeydown = (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
|
||||
@@ -172,7 +168,7 @@ export default {
|
||||
},
|
||||
)
|
||||
|
||||
return { submit, isDisabled, editorId, isMac, isMobile}
|
||||
return { submit, isDisabled, editorId, isMac, isMobile }
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -3,73 +3,73 @@ import { useWebSocket } from './useWebSocket'
|
||||
import { getToken } from '~/utils/auth'
|
||||
|
||||
const count = ref(0)
|
||||
let isInitialized = false;
|
||||
let isInitialized = false
|
||||
|
||||
export function useChannelsUnreadCount() {
|
||||
const config = useRuntimeConfig();
|
||||
const API_BASE_URL = config.public.apiBaseUrl;
|
||||
const { subscribe, isConnected, connect } = useWebSocket();
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
const { subscribe, isConnected, connect } = useWebSocket()
|
||||
|
||||
const fetchChannelUnread = async () => {
|
||||
const token = getToken();
|
||||
const token = getToken()
|
||||
if (!token) {
|
||||
count.value = 0;
|
||||
return;
|
||||
count.value = 0
|
||||
return
|
||||
}
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/channels/unread-count`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
})
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
count.value = data;
|
||||
const data = await response.json()
|
||||
count.value = data
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch channel unread count:', e);
|
||||
console.error('Failed to fetch channel unread count:', e)
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
const setupWebSocketListener = () => {
|
||||
const destination = '/user/queue/channel-unread';
|
||||
const destination = '/user/queue/channel-unread'
|
||||
|
||||
subscribe(destination, (message) => {
|
||||
const unread = parseInt(message.body, 10);
|
||||
const unread = parseInt(message.body, 10)
|
||||
if (!isNaN(unread)) {
|
||||
count.value = unread;
|
||||
count.value = unread
|
||||
}
|
||||
}).then(subscription => {
|
||||
}).then((subscription) => {
|
||||
if (subscription) {
|
||||
console.log('频道未读消息订阅成功');
|
||||
console.log('频道未读消息订阅成功')
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
const initialize = () => {
|
||||
const token = getToken();
|
||||
const token = getToken()
|
||||
if (!token) {
|
||||
count.value = 0;
|
||||
return;
|
||||
count.value = 0
|
||||
return
|
||||
}
|
||||
|
||||
if (!isConnected.value) {
|
||||
connect(token);
|
||||
connect(token)
|
||||
}
|
||||
|
||||
fetchChannelUnread();
|
||||
setupWebSocketListener();
|
||||
};
|
||||
fetchChannelUnread()
|
||||
setupWebSocketListener()
|
||||
}
|
||||
|
||||
const setFromList = (channels) => {
|
||||
count.value = Array.isArray(channels) ? channels.filter((c) => c.unreadCount > 0).length : 0;
|
||||
};
|
||||
count.value = Array.isArray(channels) ? channels.filter((c) => c.unreadCount > 0).length : 0
|
||||
}
|
||||
|
||||
const hasUnread = computed(() => count.value > 0);
|
||||
const hasUnread = computed(() => count.value > 0)
|
||||
|
||||
if (!isInitialized) {
|
||||
const token = getToken();
|
||||
const token = getToken()
|
||||
if (token) {
|
||||
isInitialized = true;
|
||||
initialize();
|
||||
isInitialized = true
|
||||
initialize()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,5 +79,5 @@ export function useChannelsUnreadCount() {
|
||||
fetchChannelUnread,
|
||||
initialize,
|
||||
setFromList,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export function useReactionTypes() {
|
||||
reactionTypes.value = [...(window.reactionTypes || [])]
|
||||
return reactionTypes.value
|
||||
}
|
||||
|
||||
|
||||
isLoading = true
|
||||
try {
|
||||
const token = getToken()
|
||||
@@ -47,6 +47,6 @@ export function useReactionTypes() {
|
||||
reactionTypes: readonly(reactionTypes),
|
||||
fetchReactionTypes,
|
||||
initialize,
|
||||
isInitialized: readonly(isInitialized)
|
||||
isInitialized: readonly(isInitialized),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { useWebSocket } from './useWebSocket';
|
||||
import { getToken } from '~/utils/auth';
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { useWebSocket } from './useWebSocket'
|
||||
import { getToken } from '~/utils/auth'
|
||||
|
||||
const count = ref(0);
|
||||
let isInitialized = false;
|
||||
const count = ref(0)
|
||||
let isInitialized = false
|
||||
|
||||
export function useUnreadCount() {
|
||||
const config = useRuntimeConfig();
|
||||
const API_BASE_URL = config.public.apiBaseUrl;
|
||||
const { subscribe, isConnected, connect } = useWebSocket();
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
const { subscribe, isConnected, connect } = useWebSocket()
|
||||
|
||||
const fetchUnreadCount = async () => {
|
||||
const token = getToken();
|
||||
const token = getToken()
|
||||
if (!token) {
|
||||
count.value = 0;
|
||||
return;
|
||||
count.value = 0
|
||||
return
|
||||
}
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/messages/unread-count`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
})
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
count.value = data;
|
||||
const data = await response.json()
|
||||
count.value = data
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch unread count:', error);
|
||||
console.error('Failed to fetch unread count:', error)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const setupWebSocketListener = () => {
|
||||
console.log('设置未读消息订阅...');
|
||||
const destination = '/user/queue/unread-count';
|
||||
|
||||
console.log('设置未读消息订阅...')
|
||||
const destination = '/user/queue/unread-count'
|
||||
|
||||
subscribe(destination, (message) => {
|
||||
const unreadCount = parseInt(message.body, 10);
|
||||
const unreadCount = parseInt(message.body, 10)
|
||||
if (!isNaN(unreadCount)) {
|
||||
count.value = unreadCount;
|
||||
count.value = unreadCount
|
||||
}
|
||||
}).then(subscription => {
|
||||
}).then((subscription) => {
|
||||
if (subscription) {
|
||||
console.log('未读消息订阅成功');
|
||||
console.log('未读消息订阅成功')
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
const initialize = () => {
|
||||
const token = getToken();
|
||||
const token = getToken()
|
||||
if (!token) {
|
||||
count.value = 0;
|
||||
return;
|
||||
count.value = 0
|
||||
return
|
||||
}
|
||||
|
||||
if (!isConnected.value) {
|
||||
connect(token);
|
||||
connect(token)
|
||||
}
|
||||
|
||||
fetchUnreadCount();
|
||||
setupWebSocketListener();
|
||||
};
|
||||
|
||||
fetchUnreadCount()
|
||||
setupWebSocketListener()
|
||||
}
|
||||
|
||||
if (!isInitialized) {
|
||||
const token = getToken();
|
||||
const token = getToken()
|
||||
if (token) {
|
||||
isInitialized = true;
|
||||
initialize();
|
||||
isInitialized = true
|
||||
initialize()
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
count,
|
||||
fetchUnreadCount,
|
||||
initialize,
|
||||
};
|
||||
}
|
||||
initialize,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const resubscribeCallbacks = new Map()
|
||||
// Helper for unified subscription logging
|
||||
const logSubscriptionActivity = (action, destination, subscriptionId = 'N/A') => {
|
||||
console.log(
|
||||
`[SUB_MAN] ${action} | Dest: ${destination} | SubID: ${subscriptionId} | Active: ${activeSubscriptions.value.size}`
|
||||
`[SUB_MAN] ${action} | Dest: ${destination} | SubID: ${subscriptionId} | Active: ${activeSubscriptions.value.size}`,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ const connect = (token) => {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const WEBSOCKET_URL = config.public.websocketUrl
|
||||
const socketUrl = `${WEBSOCKET_URL}/api/sockjs`
|
||||
@@ -31,9 +30,7 @@ const connect = (token) => {
|
||||
connectHeaders: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
debug: function (str) {
|
||||
|
||||
},
|
||||
debug: function (str) {},
|
||||
reconnectDelay: 10000,
|
||||
heartbeatIncoming: 4000,
|
||||
heartbeatOutgoing: 4000,
|
||||
@@ -42,7 +39,7 @@ const connect = (token) => {
|
||||
stompClient.onConnect = (frame) => {
|
||||
isConnected.value = true
|
||||
resubscribeCallbacks.forEach((callback, destination) => {
|
||||
doSubscribe(destination, callback)
|
||||
doSubscribe(destination, callback)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -50,16 +47,14 @@ const connect = (token) => {
|
||||
console.error('Full frame:', frame)
|
||||
}
|
||||
|
||||
stompClient.onWebSocketError = (event) => {
|
||||
|
||||
}
|
||||
stompClient.onWebSocketError = (event) => {}
|
||||
|
||||
stompClient.onWebSocketClose = (event) => {
|
||||
isConnected.value = false;
|
||||
activeSubscriptions.value.clear();
|
||||
logSubscriptionActivity('Cleared all subscriptions due to WebSocket close', 'N/A');
|
||||
};
|
||||
|
||||
isConnected.value = false
|
||||
activeSubscriptions.value.clear()
|
||||
logSubscriptionActivity('Cleared all subscriptions due to WebSocket close', 'N/A')
|
||||
}
|
||||
|
||||
stompClient.onDisconnect = (frame) => {
|
||||
isConnected.value = false
|
||||
}
|
||||
@@ -92,7 +87,7 @@ const unsubscribe = (destination) => {
|
||||
const unsubscribeAll = () => {
|
||||
logSubscriptionActivity('Unsubscribing from ALL', `Total: ${activeSubscriptions.value.size}`)
|
||||
const destinations = [...activeSubscriptions.value.keys()]
|
||||
destinations.forEach(dest => {
|
||||
destinations.forEach((dest) => {
|
||||
unsubscribe(dest)
|
||||
})
|
||||
}
|
||||
@@ -148,16 +143,20 @@ const subscribe = (destination, callback) => {
|
||||
const sub = doSubscribe(destination, callback)
|
||||
resolve(sub)
|
||||
} else {
|
||||
const unwatch = watch(isConnected, (newVal) => {
|
||||
if (newVal) {
|
||||
setTimeout(() => {
|
||||
const sub = doSubscribe(destination, callback)
|
||||
unwatch()
|
||||
resolve(sub)
|
||||
}, 100)
|
||||
}
|
||||
}, { immediate: false })
|
||||
|
||||
const unwatch = watch(
|
||||
isConnected,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
setTimeout(() => {
|
||||
const sub = doSubscribe(destination, callback)
|
||||
unwatch()
|
||||
resolve(sub)
|
||||
}, 100)
|
||||
}
|
||||
},
|
||||
{ immediate: false },
|
||||
)
|
||||
|
||||
setTimeout(() => {
|
||||
unwatch()
|
||||
if (!isConnected.value) {
|
||||
|
||||
Reference in New Issue
Block a user