This commit is contained in:
Yvan
2026-09-04 14:07:09 +08:00
parent af1e194396
commit 43db5e5450
22 changed files with 416 additions and 134 deletions
+31 -6
View File
@@ -1,3 +1,8 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name localhost;
@@ -10,16 +15,36 @@ server {
try_files $uri $uri/ /index.html;
}
location /api {
location = /api {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
rewrite ^/api/(.*)$ /$1 break; #重写
proxy_pass http://${KRA_APP}-backend:8000; # Kubernetes Service
}
}
location /api/swagger/index.html {
location ^~ /api/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600s;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://${KRA_APP}-backend:8000;
}
location = /api/swagger/index.html {
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://${KRA_APP}-backend:8000/swagger/index.html;
}
}
}
}
+1 -1
View File
@@ -61,7 +61,7 @@
const isRightSize = file.size / 1024 < props.fileSize
if (!isRightSize) {
// 压缩
const compress = new ImageCompress(file, props.fileSize, props.maxWH)
const compress = new ImageCompress(file, props.maxWH)
return compress.compress()
}
return isRightSize
+1 -15
View File
@@ -1,14 +1,12 @@
export default class ImageCompress {
constructor(file, fileSize, maxWH = 1920) {
constructor(file, maxWH = 1920) {
this.file = file
this.fileSize = fileSize
this.maxWH = maxWH // 最大长宽
}
compress() {
// 压缩
const fileType = this.file.type
const fileSize = this.file.size / 1024
return new Promise((resolve) => {
const reader = new FileReader()
reader.readAsDataURL(this.file)
@@ -28,12 +26,6 @@ export default class ImageCompress {
const newImgData = canvas.toDataURL(fileType, 0.9)
// 压缩宽高后的图像大小
const newImgSize = this.fileSizeKB(newImgData)
if (newImgSize > this.fileSize) {
}
const blob = this.dataURLtoBlob(newImgData, fileType)
const nfile = new File([blob], this.file.name)
resolve(nfile)
@@ -66,12 +58,6 @@ export default class ImageCompress {
}
}
fileSizeKB(dataURL) {
let sizeKB = 0
sizeKB = Math.round((dataURL.split(',')[1].length * 3) / 4 / 1024)
return sizeKB
}
/**
* 转为Blob
*/
+1 -1
View File
@@ -112,7 +112,7 @@ router.isReady().then(() => {
let query = router.currentRoute.value.query
classId.value = query.id
token.value = query.token
}).catch((err) => {
}).catch(() => {
})
const uploadRef = ref(null)
@@ -326,17 +326,28 @@ const selected = computed(
const integrationKey = (item) => `${item.kind}/${item.provider}`
const providerMeta = (item) => TARGETS[integrationKey(item)] || TARGETS[TARGET_ORDER[0]]
const isWebSocket = (item) => integrationKey(item) === 'websocket/melody'
const websocketApiBase = () => String(import.meta.env.VITE_BASE_API || '').trim()
const websocketUrlOverride = () => String(import.meta.env.VITE_WEBSOCKET_URL || '').trim()
const websocketUrlPath = (value) => {
try {
return new URL(value, window.location.origin).pathname.replace(/\/+$/, '')
} catch {
return ''
}
}
const websocketBackendIsExplicit = () =>
Boolean(
String(import.meta.env.VITE_WEBSOCKET_URL || '').trim() ||
String(import.meta.env.VITE_SERVER_PORT || '').trim()
websocketUrlOverride() ||
String(import.meta.env.VITE_SERVER_PORT || '').trim() ||
/^https?:\/\//i.test(websocketApiBase())
)
const websocketOrigin = () => {
if (websocketBackendIsExplicit()) {
const configuredBase = String(
import.meta.env.VITE_WEBSOCKET_URL ||
import.meta.env.VITE_BASE_PATH ||
window.location.origin
websocketUrlOverride() ||
(/^https?:\/\//i.test(websocketApiBase())
? websocketApiBase()
: import.meta.env.VITE_BASE_PATH || window.location.origin)
)
const backend = new URL(configuredBase, window.location.origin)
if (
@@ -355,9 +366,14 @@ const websocketOrigin = () => {
return `${protocol}//${window.location.host}`
}
const websocketPathPrefix = () => {
if (websocketBackendIsExplicit()) return ''
const base = String(import.meta.env.VITE_BASE_API || '').trim()
if (!base || /^https?:\/\//i.test(base)) return ''
const override = websocketUrlOverride()
if (override) return websocketUrlPath(override)
const base = websocketApiBase()
if (!base) return ''
if (/^https?:\/\//i.test(base)) {
return websocketUrlPath(base)
}
if (String(import.meta.env.VITE_SERVER_PORT || '').trim()) return ''
return `/${base.replace(/^\/+|\/+$/g, '')}`
}
const connectionInfo = computed(() => {