mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-27 21:17:39 +08:00
fix: setup 迁移完成
This commit is contained in:
@@ -230,7 +230,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { ref, computed, onMounted, onBeforeUnmount, nextTick, watch } from 'vue'
|
import { ref, computed, onMounted, onBeforeUnmount, nextTick, watch } from 'vue'
|
||||||
import VueEasyLightbox from 'vue-easy-lightbox'
|
import VueEasyLightbox from 'vue-easy-lightbox'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
@@ -243,7 +243,7 @@ import ReactionsGroup from '~/components/ReactionsGroup.vue'
|
|||||||
import DropdownMenu from '~/components/DropdownMenu.vue'
|
import DropdownMenu from '~/components/DropdownMenu.vue'
|
||||||
import { renderMarkdown, handleMarkdownClick, stripMarkdownLength } from '~/utils/markdown'
|
import { renderMarkdown, handleMarkdownClick, stripMarkdownLength } from '~/utils/markdown'
|
||||||
import { getMedalTitle } from '~/utils/medal'
|
import { getMedalTitle } from '~/utils/medal'
|
||||||
import { API_BASE_URL, toast } from '~/main'
|
import { toast } from '~/main'
|
||||||
import { getToken, authState } from '~/utils/auth'
|
import { getToken, authState } from '~/utils/auth'
|
||||||
import TimeManager from '~/utils/time'
|
import TimeManager from '~/utils/time'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
@@ -251,21 +251,9 @@ import { useIsMobile } from '~/utils/screen'
|
|||||||
import Dropdown from '~/components/Dropdown.vue'
|
import Dropdown from '~/components/Dropdown.vue'
|
||||||
import { ClientOnly } from '#components'
|
import { ClientOnly } from '#components'
|
||||||
|
|
||||||
export default {
|
const config = useRuntimeConfig()
|
||||||
name: 'PostPageView',
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
components: {
|
|
||||||
CommentItem,
|
|
||||||
CommentEditor,
|
|
||||||
BaseTimeline,
|
|
||||||
ArticleTags,
|
|
||||||
ArticleCategory,
|
|
||||||
ReactionsGroup,
|
|
||||||
DropdownMenu,
|
|
||||||
VueEasyLightbox,
|
|
||||||
Dropdown,
|
|
||||||
ClientOnly,
|
|
||||||
},
|
|
||||||
async setup() {
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const postId = route.params.id
|
const postId = route.params.id
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -291,9 +279,7 @@ export default {
|
|||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
|
|
||||||
const headerHeight = process.client
|
const headerHeight = process.client
|
||||||
? parseFloat(
|
? parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--header-height')) || 0
|
||||||
getComputedStyle(document.documentElement).getPropertyValue('--header-height'),
|
|
||||||
) || 0
|
|
||||||
: 0
|
: 0
|
||||||
|
|
||||||
useHead(() => ({
|
useHead(() => ({
|
||||||
@@ -794,66 +780,6 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
await fetchPost()
|
await fetchPost()
|
||||||
|
|
||||||
return {
|
|
||||||
postContent,
|
|
||||||
author,
|
|
||||||
title,
|
|
||||||
category,
|
|
||||||
tags,
|
|
||||||
comments,
|
|
||||||
postTime,
|
|
||||||
scrollerTopTime,
|
|
||||||
lastReplyTime,
|
|
||||||
postItems,
|
|
||||||
mainContainer,
|
|
||||||
currentIndex,
|
|
||||||
totalPosts,
|
|
||||||
postReactions,
|
|
||||||
articleMenuItems,
|
|
||||||
postId,
|
|
||||||
postComment,
|
|
||||||
onSliderInput,
|
|
||||||
copyPostLink,
|
|
||||||
subscribePost,
|
|
||||||
unsubscribePost,
|
|
||||||
joinLottery,
|
|
||||||
renderMarkdown,
|
|
||||||
isWaitingFetchingPost,
|
|
||||||
isWaitingPostingComment,
|
|
||||||
gotoProfile,
|
|
||||||
gotoUser,
|
|
||||||
subscribed,
|
|
||||||
loggedIn,
|
|
||||||
isAuthor,
|
|
||||||
status,
|
|
||||||
isAdmin,
|
|
||||||
approvePost,
|
|
||||||
editPost,
|
|
||||||
onCommentDeleted,
|
|
||||||
deletePost,
|
|
||||||
pinPost,
|
|
||||||
unpinPost,
|
|
||||||
rejectPost,
|
|
||||||
lightboxVisible,
|
|
||||||
lightboxIndex,
|
|
||||||
lightboxImgs,
|
|
||||||
handleContentClick,
|
|
||||||
isMobile,
|
|
||||||
pinnedAt,
|
|
||||||
commentSort,
|
|
||||||
fetchCommentSorts,
|
|
||||||
isFetchingComments,
|
|
||||||
getMedalTitle,
|
|
||||||
lottery,
|
|
||||||
countdown,
|
|
||||||
lotteryParticipants,
|
|
||||||
lotteryWinners,
|
|
||||||
lotteryEnded,
|
|
||||||
hasJoined,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.post-page-container {
|
.post-page-container {
|
||||||
|
|||||||
@@ -296,7 +296,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { computed, onMounted, ref, watch } from 'vue'
|
import { computed, onMounted, ref, watch } from 'vue'
|
||||||
import { useRoute, useRouter } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import AchievementList from '~/components/AchievementList.vue'
|
import AchievementList from '~/components/AchievementList.vue'
|
||||||
@@ -304,16 +304,14 @@ import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
|||||||
import BaseTimeline from '~/components/BaseTimeline.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 UserList from '~/components/UserList.vue'
|
||||||
import { API_BASE_URL, toast } from '~/main'
|
import { toast } from '~/main'
|
||||||
import { authState, getToken } from '~/utils/auth'
|
import { authState, getToken } from '~/utils/auth'
|
||||||
import { prevLevelExp } from '~/utils/level'
|
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'
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'ProfileView',
|
|
||||||
components: { BaseTimeline, UserList, BasePlaceholder, LevelProgress, AchievementList },
|
|
||||||
setup() {
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
alias: ['/users/:id/'],
|
alias: ['/users/:id/'],
|
||||||
})
|
})
|
||||||
@@ -536,46 +534,12 @@ export default {
|
|||||||
// router.replace({ query: { ...route.query, tab: val } })
|
// router.replace({ query: { ...route.query, tab: val } })
|
||||||
if (val === 'timeline' && timelineItems.value.length === 0) {
|
if (val === 'timeline' && timelineItems.value.length === 0) {
|
||||||
await loadTimeline()
|
await loadTimeline()
|
||||||
} else if (
|
} else if (val === 'following' && followers.value.length === 0 && followings.value.length === 0) {
|
||||||
val === 'following' &&
|
|
||||||
followers.value.length === 0 &&
|
|
||||||
followings.value.length === 0
|
|
||||||
) {
|
|
||||||
await loadFollow()
|
await loadFollow()
|
||||||
} else if (val === 'achievements' && medals.value.length === 0) {
|
} else if (val === 'achievements' && medals.value.length === 0) {
|
||||||
await loadAchievements()
|
await loadAchievements()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
|
||||||
user,
|
|
||||||
hotPosts,
|
|
||||||
hotReplies,
|
|
||||||
timelineItems,
|
|
||||||
followers,
|
|
||||||
followings,
|
|
||||||
medals,
|
|
||||||
subscribed,
|
|
||||||
isMine,
|
|
||||||
isLoading,
|
|
||||||
tabLoading,
|
|
||||||
selectedTab,
|
|
||||||
followTab,
|
|
||||||
formatDate,
|
|
||||||
stripMarkdown,
|
|
||||||
stripMarkdownLength,
|
|
||||||
loadTimeline,
|
|
||||||
loadFollow,
|
|
||||||
loadAchievements,
|
|
||||||
loadSummary,
|
|
||||||
subscribeUser,
|
|
||||||
unsubscribeUser,
|
|
||||||
gotoTag,
|
|
||||||
hotTags,
|
|
||||||
levelInfo,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { API_BASE_URL } from '~/main'
|
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
const TOKEN_KEY = 'token'
|
const TOKEN_KEY = 'token'
|
||||||
@@ -65,6 +64,8 @@ export function clearUserInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchCurrentUser() {
|
export async function fetchCurrentUser() {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (!token) return null
|
if (!token) return null
|
||||||
try {
|
try {
|
||||||
@@ -91,6 +92,8 @@ export function isLogin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function checkToken() {
|
export async function checkToken() {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (!token) return false
|
if (!token) return false
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { API_BASE_URL, DISCORD_CLIENT_ID, toast } from '../main'
|
import { DISCORD_CLIENT_ID, toast } from '../main'
|
||||||
import { WEBSITE_BASE_URL } from '../constants'
|
import { WEBSITE_BASE_URL } from '../constants'
|
||||||
import { setToken, loadCurrentUser } from './auth'
|
import { setToken, loadCurrentUser } from './auth'
|
||||||
import { registerPush } from './push'
|
import { registerPush } from './push'
|
||||||
@@ -15,6 +15,8 @@ export function discordAuthorize(state = '') {
|
|||||||
|
|
||||||
export async function discordExchange(code, state, reason) {
|
export async function discordExchange(code, state, reason) {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const res = await fetch(`${API_BASE_URL}/api/auth/discord`, {
|
const res = await fetch(`${API_BASE_URL}/api/auth/discord`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { API_BASE_URL, GITHUB_CLIENT_ID, toast } from '../main'
|
import { GITHUB_CLIENT_ID, toast } from '../main'
|
||||||
import { setToken, loadCurrentUser } from './auth'
|
import { setToken, loadCurrentUser } from './auth'
|
||||||
import { WEBSITE_BASE_URL } from '../constants'
|
import { WEBSITE_BASE_URL } from '../constants'
|
||||||
import { registerPush } from './push'
|
import { registerPush } from './push'
|
||||||
@@ -15,6 +15,8 @@ export function githubAuthorize(state = '') {
|
|||||||
|
|
||||||
export async function githubExchange(code, state, reason) {
|
export async function githubExchange(code, state, reason) {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const res = await fetch(`${API_BASE_URL}/api/auth/github`, {
|
const res = await fetch(`${API_BASE_URL}/api/auth/github`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { API_BASE_URL, GOOGLE_CLIENT_ID, toast } from '../main'
|
import { GOOGLE_CLIENT_ID, toast } from '../main'
|
||||||
import { setToken, loadCurrentUser } from './auth'
|
import { setToken, loadCurrentUser } from './auth'
|
||||||
import { registerPush } from './push'
|
import { registerPush } from './push'
|
||||||
import { WEBSITE_BASE_URL } from '../constants'
|
import { WEBSITE_BASE_URL } from '../constants'
|
||||||
@@ -32,6 +32,8 @@ export function googleAuthorize() {
|
|||||||
|
|
||||||
export async function googleAuthWithToken(idToken, redirect_success, redirect_not_approved) {
|
export async function googleAuthWithToken(idToken, redirect_success, redirect_not_approved) {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const res = await fetch(`${API_BASE_URL}/api/auth/google`, {
|
const res = await fetch(`${API_BASE_URL}/api/auth/google`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { API_BASE_URL } from '~/main'
|
|
||||||
import { getToken } from './auth'
|
import { getToken } from './auth'
|
||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
|
|
||||||
@@ -7,6 +6,8 @@ export const notificationState = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export async function fetchUnreadCount() {
|
export async function fetchUnreadCount() {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
try {
|
try {
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@@ -31,6 +32,9 @@ export async function fetchUnreadCount() {
|
|||||||
|
|
||||||
export async function markNotificationsRead(ids) {
|
export async function markNotificationsRead(ids) {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
|
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (!token || !ids || ids.length === 0) return false
|
if (!token || !ids || ids.length === 0) return false
|
||||||
const res = await fetch(`${API_BASE_URL}/api/notifications/read`, {
|
const res = await fetch(`${API_BASE_URL}/api/notifications/read`, {
|
||||||
@@ -49,6 +53,9 @@ export async function markNotificationsRead(ids) {
|
|||||||
|
|
||||||
export async function fetchNotificationPreferences() {
|
export async function fetchNotificationPreferences() {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
|
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (!token) return []
|
if (!token) return []
|
||||||
const res = await fetch(`${API_BASE_URL}/api/notifications/prefs`, {
|
const res = await fetch(`${API_BASE_URL}/api/notifications/prefs`, {
|
||||||
@@ -63,6 +70,8 @@ export async function fetchNotificationPreferences() {
|
|||||||
|
|
||||||
export async function updateNotificationPreference(type, enabled) {
|
export async function updateNotificationPreference(type, enabled) {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
if (!token) return false
|
if (!token) return false
|
||||||
const res = await fetch(`${API_BASE_URL}/api/notifications/prefs`, {
|
const res = await fetch(`${API_BASE_URL}/api/notifications/prefs`, {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { API_BASE_URL } from '../main'
|
|
||||||
import { getToken } from './auth'
|
import { getToken } from './auth'
|
||||||
|
|
||||||
function urlBase64ToUint8Array(base64String) {
|
function urlBase64ToUint8Array(base64String) {
|
||||||
@@ -21,6 +20,8 @@ function arrayBufferToBase64(buffer) {
|
|||||||
|
|
||||||
export async function registerPush() {
|
export async function registerPush() {
|
||||||
if (!('serviceWorker' in navigator) || !('PushManager' in window)) return
|
if (!('serviceWorker' in navigator) || !('PushManager' in window)) return
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
try {
|
try {
|
||||||
const reg = await navigator.serviceWorker.register('/notifications-sw.js')
|
const reg = await navigator.serviceWorker.register('/notifications-sw.js')
|
||||||
const res = await fetch(`${API_BASE_URL}/api/push/public-key`)
|
const res = await fetch(`${API_BASE_URL}/api/push/public-key`)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { API_BASE_URL, TWITTER_CLIENT_ID, toast } from '../main'
|
import { TWITTER_CLIENT_ID, toast } from '../main'
|
||||||
import { WEBSITE_BASE_URL } from '../constants'
|
import { WEBSITE_BASE_URL } from '../constants'
|
||||||
import { setToken, loadCurrentUser } from './auth'
|
import { setToken, loadCurrentUser } from './auth'
|
||||||
import { registerPush } from './push'
|
import { registerPush } from './push'
|
||||||
@@ -42,6 +42,8 @@ export async function twitterAuthorize(state = '') {
|
|||||||
|
|
||||||
export async function twitterExchange(code, state, reason) {
|
export async function twitterExchange(code, state, reason) {
|
||||||
try {
|
try {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const codeVerifier = sessionStorage.getItem('twitter_code_verifier')
|
const codeVerifier = sessionStorage.getItem('twitter_code_verifier')
|
||||||
sessionStorage.removeItem('twitter_code_verifier')
|
sessionStorage.removeItem('twitter_code_verifier')
|
||||||
const res = await fetch(`${API_BASE_URL}/api/auth/twitter`, {
|
const res = await fetch(`${API_BASE_URL}/api/auth/twitter`, {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { API_BASE_URL } from '../main'
|
|
||||||
|
|
||||||
export async function fetchFollowings(username) {
|
export async function fetchFollowings(username) {
|
||||||
if (!username) return []
|
if (!username) return []
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE_URL}/api/users/${username}/following`)
|
const res = await fetch(`${API_BASE_URL}/api/users/${username}/following`)
|
||||||
return res.ok ? await res.json() : []
|
return res.ok ? await res.json() : []
|
||||||
@@ -11,6 +11,8 @@ export async function fetchFollowings(username) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchAdmins() {
|
export async function fetchAdmins() {
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE_URL}/api/users/admins`)
|
const res = await fetch(`${API_BASE_URL}/api/users/admins`)
|
||||||
return res.ok ? await res.json() : []
|
return res.ok ? await res.json() : []
|
||||||
@@ -21,6 +23,8 @@ export async function fetchAdmins() {
|
|||||||
|
|
||||||
export async function searchUsers(keyword) {
|
export async function searchUsers(keyword) {
|
||||||
if (!keyword) return []
|
if (!keyword) return []
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${API_BASE_URL}/api/search/users?keyword=${encodeURIComponent(keyword)}`,
|
`${API_BASE_URL}/api/search/users?keyword=${encodeURIComponent(keyword)}`,
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import Vditor from 'vditor'
|
import Vditor from 'vditor'
|
||||||
import { API_BASE_URL } from '../main'
|
|
||||||
import { getToken, authState } from './auth'
|
import { getToken, authState } from './auth'
|
||||||
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
||||||
import { tiebaEmoji } from './tiebaEmoji'
|
import { tiebaEmoji } from './tiebaEmoji'
|
||||||
@@ -14,6 +13,8 @@ export function getPreviewTheme() {
|
|||||||
|
|
||||||
export function createVditor(editorId, options = {}) {
|
export function createVditor(editorId, options = {}) {
|
||||||
const { placeholder = '', preview = {}, input, after } = options
|
const { placeholder = '', preview = {}, input, after } = options
|
||||||
|
const config = useRuntimeConfig()
|
||||||
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
|
|
||||||
const fetchMentions = async (value) => {
|
const fetchMentions = async (value) => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user