Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .doc/contents/Update/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

## 更新日志

### 2020-07-15
> 重要内容更新:权限分配页中,按钮展示优化,去掉了 `_{id}` 非必要部分. [4f74b43](https://github.com/anjoy8/Blog.Admin/commit/4f74b43ba0cfa59166391cdfe01b2d4e8492fce5)
> 注意要保证后端代码同步更新。


### 2020-07-13
> 重要内容更新:左侧导航条支持外链(必须满足正确的 `URL` 要求,比如带 `Http` 协议) [7d822c9](https://github.com/anjoy8/Blog.Admin/commit/7d822c987c39ec7b00deb1c5b1c54c06b023f928)


### 2020-05-01
> 重要内容更新:集成按钮级别权限


### 2020-04-30
> 新增:主分支,通过global.js配置,一键切换JWT和Ids4认证授权模式

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

### Nginx 部署

1. 直接执行 `build` 命令后,把 `dist` 文件夹拷贝到服务器,然后配置 `nginx` 即可;
2. 重点是在 `nginx` 中,需要做跨域代理,比如这样的:

```
location /api/ {
rewrite ^.+apb/?(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://localhost:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";
#proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```

### IIS 部署

1. 如果使用 `IIS` 部署的话,就只能使用后端 `CORS` 跨域了,必须保证你的后端项目已经配置好了前端的端口,来允许前端项目能访问,具体的可以查看我的 `Blog.Core` 后端项目中的 `appsettings.json` 中 `Startup/Cors/IPs` 下的配置;
2. 同时,我们请求后端的 `api` 就必须使用绝对路径了,因此,我们需要在 `api.js` 文件中,修改 `base` ,配置为后端项目的端口;


### 页面刷新 404 问题

具体的查看我的文章:
https://www.cnblogs.com/laozhang-is-phi/p/beautifulPublish-mostBugs.html#autoid-3-10-0
26 changes: 24 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"element-ui": "^2.8.2",
"font-awesome": "^4.7.0",
"js-cookie": "^2.2.0",
"oidc-client": "^1.4.1",
"v-charts": "^1.19.0",
"vue": "^2.5.21",
"vue-i18n": "^8.10.0",
Expand Down
22 changes: 18 additions & 4 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@
import ScrollPane from './components/ScrollPane'
import {getUserByToken} from './api/api';

import applicationUserManager from "./Auth/applicationusermanager";
import userAuth from "./Auth/UserAuth";

export default {
components: {Sidebar, ScrollPane},
mixins: [userAuth],
data() {
return {
sysName: 'BlogAdmin',
Expand Down Expand Up @@ -253,8 +257,14 @@
this.tagsList = [];
this.routes = [];
this.$store.commit("saveTagsData", "");
_this.$router.push('/login');
window.location.reload()

if (global.IS_IDS4) {
applicationUserManager.logout();
} else {
_this.$router.push('/login');
window.location.reload()
}

}).catch(() => {

});
Expand Down Expand Up @@ -421,7 +431,12 @@
},
watch: {
// 对router进行监听,每当访问router时,对tags的进行修改
$route(newValue) {
$route: async function(newValue, from) {

if (global.IS_IDS4) {
await this.refreshUserInfo();
}

this.setTags(newValue);

const tags = this.$refs.tag
Expand Down Expand Up @@ -482,7 +497,6 @@
position: relative;
overflow: hidden;
border: 1px solid #f0f0f0;
margin-bottom: 20px;
background: #f0f0f0;
}

Expand Down
27 changes: 27 additions & 0 deletions src/Auth/UserAuth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import applicationUserManager from "./applicationusermanager";
const userAuth = {
data() {
return {
user: {
name: "",
isAuthenticated: false
}
};
},
methods: {
async refreshUserInfo() {
const user = await applicationUserManager.getUser();
if (user) {
this.user.name = user.profile.name;
this.user.isAuthenticated = true;
} else {
this.user.name = "";
this.user.isAuthenticated = false;
}
}
},
async created() {
await this.refreshUserInfo();
}
};
export default userAuth;
26 changes: 26 additions & 0 deletions src/Auth/applicationusermanager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { UserManager } from 'oidc-client'

class ApplicationUserManager extends UserManager {
constructor () {
super({
authority: 'https://ids.neters.club',
client_id: 'blogadminjs',
redirect_uri: 'http://vueadmin.neters.club/callback',
response_type: 'id_token token',
scope: 'openid profile roles blog.core.api',
post_logout_redirect_uri: 'http://vueadmin.neters.club'
})
}

async login () {
await this.signinRedirect()
return this.getUser()
}

async logout () {
return this.signoutRedirect()
}
}

const applicationUserManager = new ApplicationUserManager()
export { applicationUserManager as default }
67 changes: 57 additions & 10 deletions src/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import router from '../router/index'
import store from "../store";
import Vue from 'vue';

import applicationUserManager from "../Auth/applicationusermanager";

let base = '';
// 如果是IIS部署,用这个,因为 IIS 只能是 CORS 跨域,不能代理
// let base = process.env.NODE_ENV=="production"? 'http://localhost:8081':'';
Expand Down Expand Up @@ -64,14 +66,14 @@ axios.interceptors.response.use(
type: 'success'
});

store.commit("saveToken", res.token);
store.commit("saveToken", res.response.token);

var curTime = new Date();
var expiredate = new Date(curTime.setSeconds(curTime.getSeconds() + res.expires_in));
var expiredate = new Date(curTime.setSeconds(curTime.getSeconds() + res.response.expires_in));
store.commit("saveTokenExpire", expiredate);

error.config.__isRetryRequest = true;
error.config.headers.Authorization = 'Bearer ' + res.token;
error.config.headers.Authorization = 'Bearer ' + res.response.token;
return axios(error.config);
} else {
// 刷新token失败 清除token信息并跳转到登录页面
Expand All @@ -92,6 +94,14 @@ axios.interceptors.response.use(
});
return null;
}
// 429 ip限流
if (error.response.status == 429) {
Vue.prototype.$message({
message: '刷新次数过多,请稍事休息重试!',
type: 'error'
});
return null;
}
}
return ""; // 返回接口返回的错误信息
}
Expand Down Expand Up @@ -126,19 +136,25 @@ export const saveRefreshtime = params => {
}
};
const ToLogin = params => {

store.commit("saveToken", "");
store.commit("saveTokenExpire", "");
store.commit("saveTagsData", "");
window.localStorage.removeItem('user');
window.localStorage.removeItem('NavigationBar');

router.replace({
path: "/login",
query: {redirect: router.currentRoute.fullPath}
});

window.location.reload()



if (global.IS_IDS4) {
applicationUserManager.login();
} else {
router.replace({
path: "/login",
query: {redirect: router.currentRoute.fullPath}
});

window.location.reload()
}
};

export const getUserByToken = params => {
Expand Down Expand Up @@ -272,3 +288,34 @@ export const getAccessApiByDate = params => {
export const getAccessApiByHour = params => {
return axios.get(`${base}/api/Monitor/GetAccessApiByHour`, {params: params});
};
export const getServerInfo = params => {
return axios.get(`${base}/api/Monitor/Server`, {params: params});
};
export const getAccessLogs = params => {
return axios.get(`${base}/api/Monitor/GetAccessLogs`, {params: params});
};


// Task管理
export const getTaskListPage = params => {
return axios.get(`${base}/api/TasksQz/get`, {params: params});
};
export const removeTask = params => {
return axios.delete(`${base}/api/TasksQz/delete`, {params: params});
};
export const editTask = params => {
return axios.put(`${base}/api/TasksQz/put`, params);
};
export const addTask = params => {
return axios.post(`${base}/api/TasksQz/post`, params);
};

export const startJob = params => {
return axios.get(`${base}/api/TasksQz/StartJob`, {params: params});
};
export const stopJob = params => {
return axios.get(`${base}/api/TasksQz/StopJob`, {params: params});
};
export const reCovery = params => {
return axios.get(`${base}/api/TasksQz/ReCovery`, {params: params});
};
43 changes: 43 additions & 0 deletions src/components/AppLink.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<component :is="type" v-bind="linkProps(to)">
<slot />
</component>
</template>

<script>
import { isExternal } from '../../util/validate'

export default {
props: {
to: {
type: String,
required: true
}
},
computed: {
isExternal() {
return isExternal(this.to)
},
type() {
if (this.isExternal) {
return 'a'
}
return 'router-link'
}
},
methods: {
linkProps(to) {
if (this.isExternal) {
return {
href: to,
target: '_blank',
style:'color:#fff;'
}
}
return {
to: to
}
}
}
}
</script>
Loading