Skip to content

Commit 8d74c0c

Browse files
authored
Merge pull request #3 from anjoy8/master
2020-08-13
2 parents 5774e88 + dc8a3a1 commit 8d74c0c

32 files changed

Lines changed: 2155 additions & 765 deletions

.doc/contents/Update/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
## 更新日志
3+
4+
### 2020-07-15
5+
> 重要内容更新:权限分配页中,按钮展示优化,去掉了 `_{id}` 非必要部分. [4f74b43](https://github.com/anjoy8/Blog.Admin/commit/4f74b43ba0cfa59166391cdfe01b2d4e8492fce5)
6+
> 注意要保证后端代码同步更新。
7+
8+
9+
### 2020-07-13
10+
> 重要内容更新:左侧导航条支持外链(必须满足正确的 `URL` 要求,比如带 `Http` 协议) [7d822c9](https://github.com/anjoy8/Blog.Admin/commit/7d822c987c39ec7b00deb1c5b1c54c06b023f928)
11+
12+
13+
### 2020-05-01
14+
> 重要内容更新:集成按钮级别权限
15+
16+
17+
### 2020-04-30
18+
> 新增:主分支,通过global.js配置,一键切换JWT和Ids4认证授权模式
19+

.doc/contents/guide/getting-started.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,4 @@ Gitee(国内) 下载 [https://gitee.com/laozhangIsPhi/Blog.Admin](https://gi
4040
根目录会出现一个 `dist` 文件夹,
4141
然后拷贝到服务器,用 `Nginx` 或者 `IIS` 进行代理即可。
4242

43-
### Nginx 部署
4443

45-
1. 直接执行 `build` 命令后,把 `dist` 文件夹拷贝到服务器,然后配置 `nginx` 即可;
46-
2. 重点是在 `nginx` 中,需要做跨域代理,比如这样的:
47-
48-
```
49-
location /api/ {
50-
rewrite ^.+apb/?(.*)$ /$1 break;
51-
include uwsgi_params;
52-
proxy_pass http://localhost:8081;
53-
proxy_http_version 1.1;
54-
proxy_set_header Upgrade $http_upgrade;
55-
#proxy_set_header Connection "upgrade";
56-
#proxy_set_header Host $host;
57-
proxy_set_header X-Real-IP $remote_addr;
58-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
59-
}
60-
```
61-
62-
### IIS 部署
63-
64-
1. 如果使用 `IIS` 部署的话,就只能使用后端 `CORS` 跨域了,必须保证你的后端项目已经配置好了前端的端口,来允许前端项目能访问,具体的可以查看我的 `Blog.Core` 后端项目中的 `appsettings.json``Startup/Cors/IPs` 下的配置;
65-
2. 同时,我们请求后端的 `api` 就必须使用绝对路径了,因此,我们需要在 `api.js` 文件中,修改 `base` ,配置为后端项目的端口;
66-
67-
68-
### 页面刷新 404 问题
69-
70-
具体的查看我的文章:
71-
https://www.cnblogs.com/laozhang-is-phi/p/beautifulPublish-mostBugs.html#autoid-3-10-0

package-lock.json

Lines changed: 24 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"element-ui": "^2.8.2",
1616
"font-awesome": "^4.7.0",
1717
"js-cookie": "^2.2.0",
18+
"oidc-client": "^1.4.1",
1819
"v-charts": "^1.19.0",
1920
"vue": "^2.5.21",
2021
"vue-i18n": "^8.10.0",

src/App.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@
153153
import ScrollPane from './components/ScrollPane'
154154
import {getUserByToken} from './api/api';
155155
156+
import applicationUserManager from "./Auth/applicationusermanager";
157+
import userAuth from "./Auth/UserAuth";
158+
156159
export default {
157160
components: {Sidebar, ScrollPane},
161+
mixins: [userAuth],
158162
data() {
159163
return {
160164
sysName: 'BlogAdmin',
@@ -253,8 +257,14 @@
253257
this.tagsList = [];
254258
this.routes = [];
255259
this.$store.commit("saveTagsData", "");
256-
_this.$router.push('/login');
257-
window.location.reload()
260+
261+
if (global.IS_IDS4) {
262+
applicationUserManager.logout();
263+
} else {
264+
_this.$router.push('/login');
265+
window.location.reload()
266+
}
267+
258268
}).catch(() => {
259269
260270
});
@@ -421,7 +431,12 @@
421431
},
422432
watch: {
423433
// 对router进行监听,每当访问router时,对tags的进行修改
424-
$route(newValue) {
434+
$route: async function(newValue, from) {
435+
436+
if (global.IS_IDS4) {
437+
await this.refreshUserInfo();
438+
}
439+
425440
this.setTags(newValue);
426441
427442
const tags = this.$refs.tag
@@ -482,7 +497,6 @@
482497
position: relative;
483498
overflow: hidden;
484499
border: 1px solid #f0f0f0;
485-
margin-bottom: 20px;
486500
background: #f0f0f0;
487501
}
488502

src/Auth/UserAuth.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import applicationUserManager from "./applicationusermanager";
2+
const userAuth = {
3+
data() {
4+
return {
5+
user: {
6+
name: "",
7+
isAuthenticated: false
8+
}
9+
};
10+
},
11+
methods: {
12+
async refreshUserInfo() {
13+
const user = await applicationUserManager.getUser();
14+
if (user) {
15+
this.user.name = user.profile.name;
16+
this.user.isAuthenticated = true;
17+
} else {
18+
this.user.name = "";
19+
this.user.isAuthenticated = false;
20+
}
21+
}
22+
},
23+
async created() {
24+
await this.refreshUserInfo();
25+
}
26+
};
27+
export default userAuth;

src/Auth/applicationusermanager.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { UserManager } from 'oidc-client'
2+
3+
class ApplicationUserManager extends UserManager {
4+
constructor () {
5+
super({
6+
authority: 'https://ids.neters.club',
7+
client_id: 'blogadminjs',
8+
redirect_uri: 'http://vueadmin.neters.club/callback',
9+
response_type: 'id_token token',
10+
scope: 'openid profile roles blog.core.api',
11+
post_logout_redirect_uri: 'http://vueadmin.neters.club'
12+
})
13+
}
14+
15+
async login () {
16+
await this.signinRedirect()
17+
return this.getUser()
18+
}
19+
20+
async logout () {
21+
return this.signoutRedirect()
22+
}
23+
}
24+
25+
const applicationUserManager = new ApplicationUserManager()
26+
export { applicationUserManager as default }

src/api/api.js

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import router from '../router/index'
44
import store from "../store";
55
import Vue from 'vue';
66

7+
import applicationUserManager from "../Auth/applicationusermanager";
8+
79
let base = '';
810
// 如果是IIS部署,用这个,因为 IIS 只能是 CORS 跨域,不能代理
911
// let base = process.env.NODE_ENV=="production"? 'http://localhost:8081':'';
@@ -64,14 +66,14 @@ axios.interceptors.response.use(
6466
type: 'success'
6567
});
6668

67-
store.commit("saveToken", res.token);
69+
store.commit("saveToken", res.response.token);
6870

6971
var curTime = new Date();
70-
var expiredate = new Date(curTime.setSeconds(curTime.getSeconds() + res.expires_in));
72+
var expiredate = new Date(curTime.setSeconds(curTime.getSeconds() + res.response.expires_in));
7173
store.commit("saveTokenExpire", expiredate);
7274

7375
error.config.__isRetryRequest = true;
74-
error.config.headers.Authorization = 'Bearer ' + res.token;
76+
error.config.headers.Authorization = 'Bearer ' + res.response.token;
7577
return axios(error.config);
7678
} else {
7779
// 刷新token失败 清除token信息并跳转到登录页面
@@ -92,6 +94,14 @@ axios.interceptors.response.use(
9294
});
9395
return null;
9496
}
97+
// 429 ip限流
98+
if (error.response.status == 429) {
99+
Vue.prototype.$message({
100+
message: '刷新次数过多,请稍事休息重试!',
101+
type: 'error'
102+
});
103+
return null;
104+
}
95105
}
96106
return ""; // 返回接口返回的错误信息
97107
}
@@ -126,19 +136,25 @@ export const saveRefreshtime = params => {
126136
}
127137
};
128138
const ToLogin = params => {
139+
129140
store.commit("saveToken", "");
130141
store.commit("saveTokenExpire", "");
131142
store.commit("saveTagsData", "");
132143
window.localStorage.removeItem('user');
133144
window.localStorage.removeItem('NavigationBar');
134145

135-
router.replace({
136-
path: "/login",
137-
query: {redirect: router.currentRoute.fullPath}
138-
});
139-
140-
window.location.reload()
141-
146+
147+
148+
if (global.IS_IDS4) {
149+
applicationUserManager.login();
150+
} else {
151+
router.replace({
152+
path: "/login",
153+
query: {redirect: router.currentRoute.fullPath}
154+
});
155+
156+
window.location.reload()
157+
}
142158
};
143159

144160
export const getUserByToken = params => {
@@ -272,3 +288,34 @@ export const getAccessApiByDate = params => {
272288
export const getAccessApiByHour = params => {
273289
return axios.get(`${base}/api/Monitor/GetAccessApiByHour`, {params: params});
274290
};
291+
export const getServerInfo = params => {
292+
return axios.get(`${base}/api/Monitor/Server`, {params: params});
293+
};
294+
export const getAccessLogs = params => {
295+
return axios.get(`${base}/api/Monitor/GetAccessLogs`, {params: params});
296+
};
297+
298+
299+
// Task管理
300+
export const getTaskListPage = params => {
301+
return axios.get(`${base}/api/TasksQz/get`, {params: params});
302+
};
303+
export const removeTask = params => {
304+
return axios.delete(`${base}/api/TasksQz/delete`, {params: params});
305+
};
306+
export const editTask = params => {
307+
return axios.put(`${base}/api/TasksQz/put`, params);
308+
};
309+
export const addTask = params => {
310+
return axios.post(`${base}/api/TasksQz/post`, params);
311+
};
312+
313+
export const startJob = params => {
314+
return axios.get(`${base}/api/TasksQz/StartJob`, {params: params});
315+
};
316+
export const stopJob = params => {
317+
return axios.get(`${base}/api/TasksQz/StopJob`, {params: params});
318+
};
319+
export const reCovery = params => {
320+
return axios.get(`${base}/api/TasksQz/ReCovery`, {params: params});
321+
};

src/components/AppLink.vue

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<component :is="type" v-bind="linkProps(to)">
3+
<slot />
4+
</component>
5+
</template>
6+
7+
<script>
8+
import { isExternal } from '../../util/validate'
9+
10+
export default {
11+
props: {
12+
to: {
13+
type: String,
14+
required: true
15+
}
16+
},
17+
computed: {
18+
isExternal() {
19+
return isExternal(this.to)
20+
},
21+
type() {
22+
if (this.isExternal) {
23+
return 'a'
24+
}
25+
return 'router-link'
26+
}
27+
},
28+
methods: {
29+
linkProps(to) {
30+
if (this.isExternal) {
31+
return {
32+
href: to,
33+
target: '_blank',
34+
style:'color:#fff;'
35+
}
36+
}
37+
return {
38+
to: to
39+
}
40+
}
41+
}
42+
}
43+
</script>

0 commit comments

Comments
 (0)