diff --git a/nginx-https.conf b/nginx-https.conf index 48e63d2..b87cbec 100644 --- a/nginx-https.conf +++ b/nginx-https.conf @@ -50,7 +50,8 @@ server { # ========== 重要:后端API代理配置 ========== # 将所有API请求代理到后端服务器(解决混合内容问题) # 注意:这里的路径需要与前端 VUE_APP_BASE_API 配置一致 - location /jarvis-api/ { + # ^~ 表示命中前缀后不再尝试正则 location,避免被其它规则干扰 + location ^~ /jarvis-api/ { proxy_pass http://127.0.0.1:30313/; # 后端服务地址 # 请求头设置 @@ -81,7 +82,10 @@ server { client_max_body_size 100M; } - # 腾讯文档OAuth回调接口(必须放在 /jarvis-api/ 之后,location / 之前) + # OAuth 回调:须放在 /jarvis-api/ 之后、location / 之前。 + # 切勿重复定义同名 location(例如两个 /wps365-callback,仅第一个生效)。 + + # 腾讯文档 OAuth 回调 location /tendoc-callback { proxy_pass http://127.0.0.1:30313/tendoc-callback; @@ -110,7 +114,29 @@ server { client_max_body_size 100M; } - # 金山文档 OAuth 回调(须放在 /jarvis-api/ 之后,location / 之前) + # 金山文档:旧回调路径(后端 302 → /kdocs-callback,仅过渡用;后台建议改为 /kdocs-callback) + location /wps365-callback { + proxy_pass http://127.0.0.1:30313/wps365-callback; + + proxy_set_header Host $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_set_header X-Forwarded-Host $server_name; + + proxy_set_header Content-Type $content_type; + proxy_set_header Content-Length $content_length; + proxy_pass_request_headers on; + proxy_pass_request_body on; + + proxy_http_version 1.1; + proxy_connect_timeout 600s; + proxy_send_timeout 600s; + proxy_read_timeout 600s; + client_max_body_size 100M; + } + + # 金山文档 OAuth 回调(与 kdocs.redirect-uri、开放平台登记一致) location /kdocs-callback { proxy_pass http://127.0.0.1:30313/kdocs-callback; diff --git a/src/views/jarvis/docSync/components/KdocsCloudConfig.vue b/src/views/jarvis/docSync/components/KdocsCloudConfig.vue index 2effedf..f93e072 100644 --- a/src/views/jarvis/docSync/components/KdocsCloudConfig.vue +++ b/src/views/jarvis/docSync/components/KdocsCloudConfig.vue @@ -174,7 +174,8 @@ export default { try { const response = await getKdocsTokenStatus(this.userId) if (response.code === 200) { - this.isAuthorized = response.data.hasToken && response.data.isValid + // 有 token 即视为已授权;isValid 单独展示(避免 expires_in 缺失时误判未保存) + this.isAuthorized = !!response.data.hasToken this.tokenInfo = response.data if (response.data.userId) { this.userId = response.data.userId diff --git a/src/views/jarvis/kdocs/index.vue b/src/views/jarvis/kdocs/index.vue index a8ecda2..26c2bbf 100644 --- a/src/views/jarvis/kdocs/index.vue +++ b/src/views/jarvis/kdocs/index.vue @@ -132,7 +132,7 @@ export default { try { const response = await getKdocsTokenStatus(this.userId) if (response.code === 200) { - this.isAuthorized = response.data.hasToken && response.data.isValid + this.isAuthorized = !!response.data.hasToken if (this.isAuthorized) { this.loadUserInfo() }