diff --git a/spug_web/src/libs/http.js b/spug_web/src/libs/http.js index ce572ef..a471b91 100644 --- a/spug_web/src/libs/http.js +++ b/spug_web/src/libs/http.js @@ -24,6 +24,8 @@ function handleResponse(response) { return Promise.resolve(response.data.data) } else if (response.headers['content-type'] === 'application/octet-stream') { return Promise.resolve(response) + } else if (!response.config.isInternal) { + return Promise.resolve(response.data) } else { result = '无效的数据格式' } @@ -36,7 +38,8 @@ function handleResponse(response) { // 请求拦截器 http.interceptors.request.use(request => { - if (request.url.startsWith('/api/')) { + request.isInternal = request.url.startsWith('/api/'); + if (request.isInternal) { request.headers['X-Token'] = localStorage.getItem('token') } request.timeout = request.timeout || 30000; diff --git a/spug_web/src/pages/system/setting/About.js b/spug_web/src/pages/system/setting/About.js index 1e3af4a..d55ca10 100644 --- a/spug_web/src/pages/system/setting/About.js +++ b/spug_web/src/pages/system/setting/About.js @@ -5,7 +5,7 @@ */ import React from 'react'; import styles from './index.module.css'; -import { Descriptions, Spin } from "antd"; +import { Descriptions, Spin, Icon, notification } from "antd"; import { observer } from 'mobx-react' import { http, VERSION } from 'libs'; @@ -24,6 +24,19 @@ class About extends React.Component { http.get('/api/setting/about/') .then(res => this.setState({info: res})) .finally(() => this.setState({fetching: false})) + http.get('https://gitee.com/api/v5/repos/openspug/spug/releases/latest') + .then(res => { + if (res.tag_name && res.tag_name !== VERSION) { + const logs = res.body.replace(/- */g, ''); + notification.open({ + duration: 0, + top: 88, + icon: , + message: `发现新版本 ${res.tag_name}`, + description:
{logs}
+ }) + } + }) } @@ -42,7 +55,8 @@ class About extends React.Component { https://spug.dev - https://spug.dev/docs/change-log/ + https://spug.dev/docs/change-log/