Commit 67062cf5 by cocomilk2012

update

parent 4806a0be
VUE_APP_OIDC_CONFIG = '{ "authority": "http://106.120.107.150:5000", "client_id": "teamix-personal-center-web-pc", "client_secret": "123456", "redirect_uri": "http://localhost:8080/callback.html", "response_type": "id_token token", "scope": "openid workapps.client api.workapps.user","post_logout_redirect_uri":"http://localhost:8080", "silent_redirect_uri": "http://localhost:8080/silent-renew.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true,"loadUserInfo":true }'
VUE_APP_OIDC_CONFIG = '{ "authority": "http://106.120.107.150:5000", "client_id": "qqxb-self-service-web-mobile", "client_secret": "123456", "redirect_uri": "http://localhost:8080/callback.html", "response_type": "id_token token", "scope": "openid workapps.client api.workapps.user","post_logout_redirect_uri":"http://localhost:8080", "silent_redirect_uri": "http://localhost:8080/silent-renew.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true,"loadUserInfo":true }'
VUE_APP_BASE_URL= http://organization.test.hrs100.cn:18080
......
VUE_APP_OIDC_CONFIG = '{ "authority": "https://passport.teammix.com", "client_id": "qqxb-activity-web-mobile", "client_secret": "qqxb#teammix#2019", "redirect_uri": "https://invite.activity.h5.hrs100.com/callback.html", "response_type": "id_token token", "scope": "workapps.client api.workapps.user api.workapps.org api.workapps.open openid","post_logout_redirect_uri":"https://invite.activity.h5.hrs100.com", "silent_redirect_uri": "https://invite.activity.h5.hrs100.com/silent-renew-oidc.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true }'
VUE_APP_OIDC_CONFIG = '{ "authority": "https://passport.teammix.com", "client_id": "qqxb-self-service-web-mobile", "client_secret": "qqxb#teammix#2019", "redirect_uri": "https://invite.activity.h5.hrs100.com/callback.html", "response_type": "id_token token", "scope": "workapps.client api.workapps.user api.workapps.org api.workapps.open openid","post_logout_redirect_uri":"https://invite.activity.h5.hrs100.com", "silent_redirect_uri": "https://invite.activity.h5.hrs100.com/silent-renew-oidc.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true }'
VUE_APP_USERINFO_URL="";
......
......@@ -10086,6 +10086,11 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"dev": true
},
"vconsole": {
"version": "3.3.4",
"resolved": "https://registry.npm.taobao.org/vconsole/download/vconsole-3.3.4.tgz",
"integrity": "sha1-p9rNiIez0+kC6NGEJc2lbDTnf1E="
},
"vendors": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.4.tgz",
......
......@@ -21,6 +21,7 @@
"oidc-client": "^1.10.1",
"qs": "^6.9.4",
"vant": "^2.2.0",
"vconsole": "^3.3.4",
"vue": "^2.6.10",
"vue-class-component": "^7.2.3",
"vue-router": "^3.3.1",
......
function bin2hex (s) {
var i,
l,
o = "",
n;
s += "";
for (i = 0, l = s.length; i < l; i++) {
n = s.charCodeAt(i).toString(16)
o += n.length < 2 ? "0" + n : n;
}
return o;
}
function getCanvas () {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#f60";
ctx.fillRect(125, 1, 62, 20);
var b64 = canvas.toDataURL().replace("data:image/png;base64,", "");
var bin = atob(b64);
var crc = bin2hex(bin.slice(-16, -12));
return crc;
}
function getOsInfo () {
var userAgent = navigator.userAgent.toLowerCase();
var name = "Unknown";
var version = "Unknown";
if (userAgent.indexOf("win") > -1) {
name = "Windows";
if (userAgent.indexOf("windows nt 5.0") > -1) {
version = "Windows 2000";
} else if (
userAgent.indexOf("windows nt 5.1") > -1 ||
userAgent.indexOf("windows nt 5.2") > -1
) {
version = "Windows XP";
} else if (userAgent.indexOf("windows nt 6.0") > -1) {
version = "Windows Vista";
} else if (
userAgent.indexOf("windows nt 6.1") > -1 ||
userAgent.indexOf("windows 7") > -1
) {
version = "Windows 7";
} else if (
userAgent.indexOf("windows nt 6.2") > -1 ||
userAgent.indexOf("windows 8") > -1
) {
version = "Windows 8";
} else if (userAgent.indexOf("windows nt 6.3") > -1) {
version = "Windows 8.1";
} else if (
userAgent.indexOf("windows nt 6.2") > -1 ||
userAgent.indexOf("windows nt 10.0") > -1
) {
version = "Windows 10";
} else {
version = "Unknown";
}
} else if (userAgent.indexOf("iphone") > -1) {
name = "Iphone";
} else if (userAgent.indexOf("mac") > -1) {
name = "Mac";
} else if (
userAgent.indexOf("x11") > -1 ||
userAgent.indexOf("unix") > -1 ||
userAgent.indexOf("sunname") > -1 ||
userAgent.indexOf("bsd") > -1
) {
name = "Unix";
} else if (userAgent.indexOf("linux") > -1) {
if (userAgent.indexOf("android") > -1) {
name = "Android"
} else {
name = "Linux";
}
} else {
name = "Unknown";
}
var os = new Object();
os.name = name;
os.version = version;
return os;
//document.write("系统:" + os.name + "版本:" + os.name)
}
function getBrowerInfo () {
var Browser =
Browser ||
(function (window) {
var document = window.document,
navigator = window.navigator,
agent = navigator.userAgent.toLowerCase(),
//IE8+支持.返回浏览器渲染当前文档所用的模式
//IE6,IE7:undefined.IE8:8(兼容模式返回7).IE9:9(兼容模式返回7||8)
//IE10:10(兼容模式7||8||9)
IEMode = document.documentMode,
//chorme
chrome = window.chrome || false,
System = {
//user-agent
agent: agent,
//是否为IE
isIE: /trident/.test(agent),
//Gecko内核
isGecko: agent.indexOf("gecko") > 0 && agent.indexOf("like gecko") < 0,
//webkit内核
isWebkit: agent.indexOf("webkit") > 0,
//是否为标准模式
isStrict: document.compatMode === "CSS1Compat",
//是否支持subtitle
supportSubTitle: function () {
return "track" in document.createElement("track");
},
//是否支持scoped
supportScope: function () {
return "scoped" in document.createElement("style");
},
//获取IE的版本号
ieVersion: function () {
var rMsie = /(msie\s|trident.*rv:)([\w.]+)/;
var ma = window.navigator.userAgent.toLowerCase()
var match = rMsie.exec(ma);
try {
return match[2];
} catch (e) {
// console.log("error");
return IEMode;
}
},
//Opera版本号
operaVersion: function () {
try {
if (window.opera) {
return agent.match(/opera.([\d.]+)/)[1];
} else if (agent.indexOf("opr") > 0) {
return agent.match(/opr\/([\d.]+)/)[1];
}
} catch (e) {
return 0;
}
}
};
try {
//浏览器类型(IE、Opera、Chrome、Safari、Firefox)
System.type = System.isIE
? "IE"
: window.opera || agent.indexOf("opr") > 0
? "Opera"
: agent.indexOf("chrome") > 0
? "Chrome"
: //safari也提供了专门的判定方式
window.openDatabase
? "Safari"
: agent.indexOf("firefox") > 0
? "Firefox"
: "unknow";
//版本号
System.version = (System.type === "IE") ? System.ieVersion() :
(System.type === "Firefox") ? agent.match(/firefox\/([\d.]+)/)[1] :
(System.type === "Chrome") ? agent.match(/chrome\/([\d.]+)/)[1] :
(System.type === "Opera") ? System.operaVersion() :
(System.type === "Safari") ? agent.match(/version\/([\d.]+)/)[1] :
"0";
//浏览器外壳
System.shell = function () {
if (agent.indexOf("edge") > 0) {
System.version = agent.match(/edge\/([\d.]+)/)[1] || System.version;
return "edge浏览器";
}
//遨游浏览器
if (agent.indexOf("maxthon") > 0) {
System.version = agent.match(/maxthon\/([\d.]+)/)[1] || System.version;
return "傲游浏览器";
}
//QQ浏览器
if (agent.indexOf("qqbrowser") > 0) {
System.version = agent.match(/qqbrowser\/([\d.]+)/)[1] || System.version;
return "QQ浏览器";
}
//搜狗浏览器
if (agent.indexOf("se 2.x") > 0) {
return '搜狗浏览器';
}
//Chrome:也可以使用window.chrome && window.chrome.webstore判断
if (chrome && System.type !== "Opera") {
var external = window.external,
clientInfo = window.clientInformation,
//客户端语言:zh-cn,zh.360下面会返回undefined
clientLanguage = clientInfo.languages;
//猎豹浏览器:或者agent.indexOf("lbbrowser")>0
if (external && 'LiebaoGetVersion' in external) {
return '猎豹浏览器';
}
//百度浏览器
if (agent.indexOf("bidubrowser") > 0) {
System.version = agent.match(/bidubrowser\/([\d.]+)/)[1] ||
agent.match(/chrome\/([\d.]+)/)[1];
return "百度浏览器";
}
//360极速浏览器和360安全浏览器
if (System.supportSubTitle() && typeof clientLanguage === "undefined") {
//object.key()返回一个数组.包含可枚举属性和方法名称
var storeKeyLen = Object.keys(chrome.webstore).length,
v8Locale = "v8Locale" in window;
return storeKeyLen > 1 ? '360极速浏览器' : '360安全浏览器';
}
return "Chrome";
}
return System.type;
};
//浏览器名称(如果是壳浏览器,则返回壳名称)
System.name = System.shell();
//对版本号进行过滤过处理
// System.version = System.versionFilter(System.version);
} catch (e) {
// console.log(e.message);
}
return {
client: System
};
})(window);
if (Browser.client.name == undefined || Browser.client.name == "") {
Browser.client.name = "Unknown";
Browser.client.version = "Unknown";
} else if (Browser.client.version == undefined) {
Browser.client.version = "Unknown";
}
// document.write(Browser.client.name + " " + Browser.client.version);
return Browser;
}
function GetCommonPms () {
const v = "1.0.1";
const did = getCanvas();
const dh = getOsInfo().version;
const BrowerInfo = getBrowerInfo();
const db = BrowerInfo.client.name;
const dv = BrowerInfo.client.version;
const t = new Date().getTime();
const pms = `v=${v}&&did=${did}&&dh=${dh}&&db=${db}&&dv=${dv}&&dm=&&lat=&&lng=&&t=${t}`;
return pms;
}
export {
GetCommonPms
};
import Vue from 'vue';
import App from './App.vue';
import router from './router'
import store from './store'
import 'amfe-flexible/index.js'
import server from '@/services/install'
import router from './router';
import store from './store';
import 'amfe-flexible/index.js';
import server from '@/services/install';
// import FastClick from 'fastclick'
import '@/assets/css/index.less'
import * as filters from "@/utils/filters";
import '@/assets/css/index.less';
import * as filters from '@/utils/filters';
Vue.config.productionTip = false;
// FastClick.attach(document.body);
......@@ -15,8 +14,15 @@ Object.keys(filters).forEach((key: string) => {
Vue.filter(key, (filters as any)[key]);
});
Vue.use(server)
Vue.use(server);
if (
process.env.NODE_ENV === 'development' ||
process.env.NODE_ENV === 'staging'
) {
const VConsole = require('vconsole');
const my_console = new VConsole();
}
new Vue({
router,
......
......@@ -2,33 +2,35 @@ import Vue from 'vue';
import Router from 'vue-router';
import Mgr from '@/common/SecurityService';
import employee_router from './employee/employee-router';
import qs from 'qs';
import axios from 'axios';
//@ts-ignore
import { GetCommonPms } from '../assets/js/CommonPms.js';
Vue.use(Router);
let mgr = new Mgr();
const oidc_config = JSON.parse(process.env.VUE_APP_OIDC_CONFIG);
const isOpenHttps = process.env.VUE_APP_OPEN_HTTPS;
/**
* 加载和设置路由
*/
const router = new Router({
mode: 'history',
mode: 'history',
base: process.env.BASE_URL,//'/',
routes: [
...employee_router
]
base: process.env.BASE_URL, //'/',
routes: [...employee_router],
});
/**
* 使用授权码登录
* @param authCode 授权码
*/
function loginByAuthcode(authCode: any) {
let loginArgs = { extraQueryParams: { authcode: authCode } };
mgr.signIn(loginArgs);
let loginArgs = { extraQueryParams: { authcode: authCode } };
mgr.signIn(loginArgs);
}
/**
......@@ -36,61 +38,133 @@ function loginByAuthcode(authCode: any) {
* @param authcode 授权码
*/
function autoLogin(authcode: any) {
mgr.getUser().then(user => {
if (user == null) {
loginByAuthcode(authcode);
} else {
//如果已经登录,则先退出
localStorage.setItem("authcode", authcode);
mgr.signOut();
}
})
}
/**
* 请求路由前 一些操作
*/
router.beforeEach((to, from, next) => {
// console.log(isOpenHttps);
if (isOpenHttps === "true" && location.href.startsWith("http://")) {
location.href = location.href.replace("http://", "https://");
mgr.getUser().then((user) => {
if (user == null) {
loginByAuthcode(authcode);
} else {
//如果已经登录,则先退出
localStorage.setItem('authcode', authcode);
mgr.signOut();
}
});
}
const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
localStorage.setItem("returnUrl", to.path);
//更改标题
if (to.meta.title) {
document.title = to.meta.title;
}
//@ts-ignore
function getAccessToken(authcode) {
return new Promise((resolve, reject) => {
let commonPms = GetCommonPms();
//@ts-ignore
let url = `${oidc_config.authority}/connect/token?${commonPms}`;
let pms = {
//@ts-ignore
client_id: oidc_config.client_id,
//@ts-ignore
client_secret: oidc_config.client_secret,
grant_type: 'auth_code',
scope:
'openid workapps.client api.workapps.user api.workapps.org api.workapps.open',
code: authcode,
};
axios.post(url, qs.stringify(pms)).then((res) => {
if (res && res.status) {
const accessToken = res.data.access_token;
resolve(accessToken);
} else {
reject(res);
}
});
});
}
let authcode = localStorage.getItem("authcode")
if (authcode) {
localStorage.removeItem("authcode");
loginByAuthcode(authcode)
} else {
let authcode = to.query.authcode;
if (authcode) {
autoLogin(authcode);
} else {
if (requiresAuth) {
mgr.getUser().then(user => {
if (user == null) {
mgr.signIn();
} else {
next();
}
});
}
else {
next();
}
}
//@ts-ignore
function getPathByTo(to, authcode_key) {
let toPath = to.path || '/';
for (let key in to.query) {
if (key == authcode_key) {
continue;
}
toPath += toPath.indexOf('?') > -1 ? '&' : '?';
toPath += `${key}=${to.query[key]}`;
}
toPath =
toPath.indexOf('?') > -1
? toPath + '&t=' + new Date().valueOf()
: toPath + '?t=' + new Date().valueOf();
return toPath;
}
router.beforeEach((to, from, next) => {
if (isOpenHttps === 'true' && location.href.startsWith('http://')) {
location.href = location.href.replace('http://', 'https://');
}
const requiresAuth = to.matched.some((record) => record.meta.requiresAuth);
//更改标题
if (to.meta.title) {
document.title = to.meta.title;
}
const authcode = to.query.authCode || to.query.authcode;
if (!!authcode) {
getAccessToken(authcode)
.then((res) => {
const redirectPath = getPathByTo(to, 'authcode');
console.log('redirectPath=', redirectPath);
//@ts-ignore
const accessToken: string = res;
localStorage.setItem('token', accessToken);
window.location.href = redirectPath;
})
.catch((err) => {
console.log('err=', err);
});
} else {
next();
}
});
/**
* 请求路由前 一些操作
*/
// router.beforeEach((to, from, next) => {
// // console.log(isOpenHttps);
// if (isOpenHttps === "true" && location.href.startsWith("http://")) {
// location.href = location.href.replace("http://", "https://");
// }
// const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
// localStorage.setItem("returnUrl", to.path);
// //更改标题
// if (to.meta.title) {
// document.title = to.meta.title;
// }
// let authcode = localStorage.getItem("authcode")
// if (authcode) {
// localStorage.removeItem("authcode");
// loginByAuthcode(authcode)
// } else {
// let authcode = to.query.authcode;
// if (authcode) {
// autoLogin(authcode);
// } else {
// if (requiresAuth) {
// mgr.getUser().then(user => {
// if (user == null) {
// mgr.signIn();
// } else {
// next();
// }
// });
// }
// else {
// next();
// }
// }
// }
// });
export default router;
// import * as types from "../types";
// import { isNullOrEmpty } from "@/utils/public";
import Mgr from "@/common/SecurityService";
import Mgr from '@/common/SecurityService';
// import request from '@/utils/method';
// import urls from '@/utils/urls';
let mgr = new Mgr();
const initPageState = () => {
return {
userInfo: {},
accessToken: "",
anymouseAccessToken: "",
companyAccessToken: ""
}
return {
userInfo: {},
accessToken: '',
anymouseAccessToken: '',
companyAccessToken: '',
};
};
const user = {
state: initPageState(),
mutations: {},
actions: {},
getters: {
async getUserInfo(state: Object | any) {
if (Object.keys(state.userInfo).length > 0) {
return state.userInfo;
}
state: initPageState(),
mutations: {},
actions: {},
getters: {
async getUserInfo(state: Object | any) {
if (Object.keys(state.userInfo).length > 0) {
return state.userInfo;
}
let user = await mgr.getUser();
if (user) {
state.userInfo = user!.profile;
}
let user = await mgr.getUser();
if (user) {
state.userInfo = user!.profile;
}
return state.userInfo;
},
async getAccessToken(state: Object | any) {
if (state.accessToken === "") {
let user = await mgr.getUser();
if (user) {
state.accessToken = user!.access_token;
}
}
return state.accessToken;
},
async getAnymouseAccessToken(state: Object | any) {
if (state.anymouseAccessToken === "") {
let aToken = localStorage.getItem("aat");
if (!!(aToken)) {
state.anymouseAccessToken = aToken;
} else {
// let url = `${urls.tokenUrl}/connect/token`;
// await request.post(url,)
}
}
return state.anymouseAccessToken;
return state.userInfo;
},
async getAccessToken(state: Object | any) {
if (state.accessToken === '') {
//let user = await mgr.getUser();
// if (user) {
// state.accessToken = user!.access_token;
// }
state.accessToken = localStorage.getItem('token');
}
return state.accessToken;
},
async getAnymouseAccessToken(state: Object | any) {
if (state.anymouseAccessToken === '') {
let aToken = localStorage.getItem('aat');
if (!!aToken) {
state.anymouseAccessToken = aToken;
} else {
// let url = `${urls.tokenUrl}/connect/token`;
// await request.post(url,)
}
}
}
return state.anymouseAccessToken;
},
},
};
export default user;
......@@ -101,7 +101,7 @@ export default class FlexEmployee extends Vue {
private Payment_receivable: string = "";
private receive_receivable: string = "";
private fullName: string = "";
private taskRecordList: any = [];
private taskRecordList: any = null;
private toDetail(id: any): void {
this.$router.push({ name: "FlexEmployeeDetial", query: { id } });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment