-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f6b3a3
commit 039a73a
Showing
19 changed files
with
4,000 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"@vue/app" | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
.DS_Store | ||
node_modules | ||
/dist | ||
|
||
# local env files | ||
.env.local | ||
.env.*.local | ||
|
||
# Log files | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Editor directories and files | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
.cache/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,27 @@ | |
"repository": "https://github.com/HeraldStudio/herald-web-template.git", | ||
"author": "wolf-tungsten <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "parcel ./public/index.html --port=8080", | ||
"build": "parcel build ./public/index.html --public-url //cdn.xgbxscwx.myseu.cn/;" | ||
}, | ||
"dependencies": { | ||
"parcel-bundler": "^1.12.4" | ||
"axios": "^0.19.2", | ||
"babel-polyfill": "^6.26.0", | ||
"element-ui": "^2.13.0", | ||
"parcel-bundler": "^1.12.4", | ||
"vue": "^2.5.17", | ||
"vue-hot-reload-api": "^2.3.4", | ||
"vue-router": "^3.1.6", | ||
"vuex": ">=2.5", | ||
"vuex-persist": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "*", | ||
"@vue/babel-preset-app": "^4.2.3", | ||
"@vue/component-compiler-utils": "^3.1.1", | ||
"babel-plugin-component": "^1.1.1", | ||
"less": "^3.11.1", | ||
"vue-template-compiler": "^2.6.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0"> | ||
<link rel="icon" href="logo.png"/> | ||
<title>信使计划</title> | ||
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script> | ||
<!-- <script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script> --> | ||
</head> | ||
<body> | ||
<noscript> | ||
<strong>We're sorry but seu-xsc-web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> | ||
</noscript> | ||
<div id="app"></div> | ||
<!-- built files will be auto injected --> | ||
<script src="../src/main.js"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<template> | ||
<div id="app"> | ||
<router-view></router-view> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import "element-ui/lib/theme-chalk/index.css"; | ||
import qs from 'querystring'; | ||
export default { | ||
name: "app", | ||
components: {}, | ||
data() { | ||
return { | ||
idsTicket: "", | ||
wechatCode: "" | ||
}; | ||
}, | ||
methods: { | ||
initAxios() { | ||
// 初始化 Axios 配置 | ||
this.$axios.defaults.baseURL = "https://xgbxscwx.seu.edu.cn/api/"; | ||
//this.$axios.defaults.baseURL = "localhost:3000"; | ||
this.$axios.defaults.headers["x-api-token"] = this.$store.state.token; | ||
}, | ||
async login() { | ||
// 对接 CAS-We-Can 或者统一身份认证的流程示例,按需修改 | ||
let loading = this.$loading({ fullscreen: true }); | ||
if(window.location.search){ | ||
// 如果当前页面参数携带了ticket | ||
let ticket = qs.parse(window.location.search.replace('?','')).ticket | ||
if(ticket){ | ||
// 包含 ticket,开启登录流程 | ||
let res = await this.$axios.post('/auth', { | ||
ticket, | ||
service: 'https://xgbxscwx.seu.edu.cn', | ||
platform: this.$device.platform() | ||
}) | ||
if(res.data.success){ | ||
this.$store.commit('token', res.data.result) | ||
window.location.search = '' | ||
return // 很重要,不要进入后面的流程 | ||
} // 执行到此处说明ticket无效,给他清理了就是了 | ||
} | ||
window.location.search = '' | ||
} | ||
let res = await this.$axios.get("/user"); | ||
if (!res.data.success) { | ||
// 如果获取失败,就说明 token 无效了 | ||
// 首先保存当前路由 | ||
// console.log(this.$route) | ||
this.$store.commit('saveUnfinishedRoute', { | ||
params:this.$route.params, | ||
fullPath:this.$route.fullPath | ||
}) | ||
if(this.$device.isWechat){ | ||
window.location = `https://xgbxscwx.seu.edu.cn/cas-we-can/login?goto=https://xgbxscwx.seu.edu.cn` | ||
} else { | ||
window.location = `https://newids.seu.edu.cn/authserver/login?goto=https://xgbxscwx.seu.edu.cn` | ||
} | ||
} else if (this.$store.state.hasUnfinishedRoute) { | ||
// token 有效,并且还有未完成的路由 | ||
loading.close() | ||
// console.log(this.$store.state.unfinishedRoute) | ||
this.$router.push({path:this.$store.state.unfinishedRoute.fullPath, params:this.$store.state.unfinishedRoute.params}) | ||
this.$store.commit('clearUnfinishedRoute') | ||
} else { | ||
loading.close() | ||
} | ||
} | ||
}, | ||
created() { | ||
this.initAxios(); | ||
this.login(); | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
background: #f0f0f0; | ||
} | ||
#app { | ||
font-family: "Avenir", Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
color: #2c3e50; | ||
} | ||
.content-title { | ||
font-size: 16px; | ||
font-weight: bold; | ||
margin-top: 20px; | ||
} | ||
</style> |
Oops, something went wrong.