Skip to content

Commit

Permalink
Merge pull request #197 from InfinityPacer/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp authored Oct 10, 2024
2 parents e9bb811 + 54046a4 commit b5d89ff
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_API_BASE_URL=http://localhost:3001/api/v1/
VITE_API_BASE_URL=/api/v1/
VITE_PUBLIC_VAPID_KEY=BH3w49sZA6jXUnE-yt4jO6VKh73lsdsvwoJ6Hx7fmPIDKoqGiUl2GEoZzy-iJfn4SfQQcx7yQdHf9RknwrL_lSM
4 changes: 1 addition & 3 deletions src/components/cards/PluginCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import VersionHistory from '@/components/misc/VersionHistory.vue'
import { isNullOrEmptyObject } from '@core/utils'
import noImage from '@images/logos/plugin.png'
import { getDominantColor } from '@/@core/utils/image'
import store from '@/store'
import { useDisplay } from 'vuetify'
import ProgressDialog from '../dialog/ProgressDialog.vue'
Expand Down Expand Up @@ -277,10 +276,9 @@ function visitAuthorPage() {
// 查看日志URL
function openLoggerWindow() {
const token = store.state.auth.token
const url = `${
import.meta.env.VITE_API_BASE_URL
}system/logging?token=${token}&length=-1&logfile=plugins/${props.plugin?.id?.toLowerCase()}.log`
}system/logging?length=-1&logfile=plugins/${props.plugin?.id?.toLowerCase()}.log`
window.open(url, '_blank')
}
Expand Down
8 changes: 1 addition & 7 deletions src/components/dialog/ReorganizeDialog.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts" setup>
import { useToast } from 'vue-toast-notification'
import MediaIdSelector from '../misc/MediaIdSelector.vue'
import store from '@/store'
import api from '@/api'
import { storageOptions } from '@/api/constants'
import { numberValidator } from '@/@validators'
Expand Down Expand Up @@ -119,12 +118,7 @@ watch(transferForm, async () => {
// 使用SSE监听加载进度
function startLoadingProgress() {
progressText.value = '请稍候 ...'
const token = store.state.auth.token
progressEventSource.value = new EventSource(
`${import.meta.env.VITE_API_BASE_URL}system/progress/filetransfer?token=${token}`,
)
progressEventSource.value = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/progress/filetransfer`)
progressEventSource.value.onmessage = event => {
const progress = JSON.parse(event.data)
if (progress) {
Expand Down
8 changes: 1 addition & 7 deletions src/components/filebrowser/FileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useToast } from 'vue-toast-notification'
import ReorganizeDialog from '../dialog/ReorganizeDialog.vue'
import { formatBytes } from '@core/utils/formatters'
import type { Context, EndPoints, FileItem } from '@/api/types'
import store from '@/store'
import api from '@/api'
import MediaInfoCard from '@/components/cards/MediaInfoCard.vue'
import ProgressDialog from '../dialog/ProgressDialog.vue'
Expand Down Expand Up @@ -524,12 +523,7 @@ async function batchScrape() {
// 使用SSE监听加载进度
function startLoadingProgress() {
progressText.value = '请稍候 ...'
const token = store.state.auth.token
progressEventSource.value = new EventSource(
`${import.meta.env.VITE_API_BASE_URL}system/progress/batchrename?token=${token}`,
)
progressEventSource.value = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/progress/batchrename`)
progressEventSource.value.onmessage = event => {
const progress = JSON.parse(event.data)
if (progress) {
Expand Down
4 changes: 1 addition & 3 deletions src/layouts/components/ShortcutBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import LoggingView from '@/views/system/LoggingView.vue'
import RuleTestView from '@/views/system/RuleTestView.vue'
import ModuleTestView from '@/views/system/ModuleTestView.vue'
import MessageView from '@/views/system/MessageView.vue'
import store from '@/store'
import api from '@/api'
import { useDisplay } from 'vuetify'
import { getQueryValue } from '@/@core/utils'
Expand Down Expand Up @@ -55,8 +54,7 @@ function scrollMessageToEnd() {
// 拼接全部日志url
function allLoggingUrl() {
const token = store.state.auth.token
return `${import.meta.env.VITE_API_BASE_URL}system/logging?token=${token}&length=-1`
return `${import.meta.env.VITE_API_BASE_URL}system/logging?length=-1`
}
// 发送消息
Expand Down
22 changes: 9 additions & 13 deletions src/layouts/components/UserNotification.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import store from '@/store'
import { formatDateDifference } from '@core/utils/formatters'
import { SystemNotification } from '@/api/types'
Expand All @@ -17,18 +16,15 @@ const appsMenu = ref(false)
// SSE持续接收消息
function startSSEMessager() {
const token = store.state.auth.token
if (token) {
eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/message?token=${token}`)
eventSource.addEventListener('message', event => {
if (event.data) {
const noti: SystemNotification = JSON.parse(event.data)
notificationList.value.unshift(noti)
hasNewMessage.value = true
// TODO 在顶部显示消息汽泡
}
})
}
eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/message`)
eventSource.addEventListener('message', event => {
if (event.data) {
const noti: SystemNotification = JSON.parse(event.data)
notificationList.value.unshift(noti)
hasNewMessage.value = true
// TODO 在顶部显示消息汽泡
}
})
}
// 页面加载时,加载当前用户数据
Expand Down
8 changes: 1 addition & 7 deletions src/pages/resource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import NoDataFound from '@/components/NoDataFound.vue'
import api from '@/api'
import type { Context } from '@/api/types'
import store from '@/store'
import TorrentCardListView from '@/views/discover/TorrentCardListView.vue'
import TorrentRowListView from '@/views/discover/TorrentRowListView.vue'
import { useDisplay } from 'vuetify'
Expand Down Expand Up @@ -55,12 +54,7 @@ const errorDescription = ref('未搜索到任何资源')
// 使用SSE监听加载进度
function startLoadingProgress() {
progressText.value = '正在搜索,请稍候...'
const token = store.state.auth.token
progressEventSource.value = new EventSource(
`${import.meta.env.VITE_API_BASE_URL}system/progress/search?token=${token}`,
)
progressEventSource.value = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/progress/search`)
progressEventSource.value.onmessage = event => {
const progress = JSON.parse(event.data)
if (progress) {
Expand Down
16 changes: 5 additions & 11 deletions src/views/system/LoggingView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script lang="ts" setup>
import store from '@/store'
// 日志列表
const logs = ref<string[]>([])
Expand All @@ -17,15 +15,11 @@ let eventSource: EventSource | null = null
// SSE持续获取日志
function startSSELogging() {
const token = store.state.auth.token
if (token) {
eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/logging?token=${token}`)
eventSource.addEventListener('message', event => {
const message = event.data
if (message) logs.value.push(message)
})
}
eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/logging`)
eventSource.addEventListener('message', event => {
const message = event.data
if (message) logs.value.push(message)
})
}
// 从日志中提取日志详情
Expand Down
25 changes: 10 additions & 15 deletions src/views/system/MessageView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts" setup>
import store from '@/store'
import type { Message } from '@/api/types'
import MessageCard from '@/components/cards/MessageCard.vue'
import api from '@/api'
Expand Down Expand Up @@ -29,20 +28,16 @@ let eventSource: EventSource | null = null
// SSE持续获取消息
function startSSEMessager() {
const token = store.state.auth.token
if (token) {
eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/message?token=${token}&role=user`)
eventSource.addEventListener('message', event => {
const message = event.data
if (message) {
const object = JSON.parse(message)
if (compareTime(object.date, lastTime.value) <= 0) return
messages.value.push(object)
emit('scroll')
}
})
}
eventSource = new EventSource(`${import.meta.env.VITE_API_BASE_URL}system/message?role=user`)
eventSource.addEventListener('message', event => {
const message = event.data
if (message) {
const object = JSON.parse(message)
if (compareTime(object.date, lastTime.value) <= 0) return
messages.value.push(object)
emit('scroll')
}
})
}
// 调用API加载存量消息
Expand Down
10 changes: 10 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,14 @@ export default defineConfig({
exclude: ['vuetify'],
entries: ['./src/**/*.vue'],
},
server: {
proxy: {
'/api/v1': {
target: 'http://localhost:3001',
changeOrigin: true,
secure: false,
cookieDomainRewrite: 'localhost',
},
},
},
})

0 comments on commit b5d89ff

Please sign in to comment.