yuang-framework-ui-pc 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -7
- package/src/config/http.ts +17 -20
- package/src/router/index.ts +0 -2
- package/src/utils/gatewayUtils.ts +22 -0
- package/src/utils/ssoUtils.ts +57 -0
- package/dist/favicon.ico +0 -0
- package/dist/style.css +0 -1
- package/dist/yuang-framework-ui-pc.es.js +0 -24
- package/dist/yuang-framework-ui-pc.umd.js +0 -1
- package/src/common/ssoClient.ts +0 -102
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuang-framework-ui-pc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
"build": "vite build",
|
|
9
9
|
"preview": "vite preview",
|
|
10
10
|
"test:unit": "vitest",
|
|
11
|
-
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e'",
|
|
12
|
-
"test:e2e:dev": "start-server-and-test 'vite dev --port 4173' http://localhost:4173 'cypress open --e2e'",
|
|
13
11
|
"build-only": "vite build",
|
|
14
12
|
"type-check": "vue-tsc --build --force",
|
|
15
13
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
@@ -19,9 +17,9 @@
|
|
|
19
17
|
"dist",
|
|
20
18
|
"src"
|
|
21
19
|
],
|
|
22
|
-
"main": "dist/yuang-framework-ui-pc.umd.js",
|
|
23
|
-
"module": "dist/yuang-framework-ui-pc.es.js",
|
|
24
|
-
"unpkg": "dist/yuang-framework-ui-pc.iife.js",
|
|
20
|
+
"main": "dist/yuang-framework-ui-pc.umd.js",
|
|
21
|
+
"module": "dist/yuang-framework-ui-pc.es.js",
|
|
22
|
+
"unpkg": "dist/yuang-framework-ui-pc.iife.js",
|
|
25
23
|
"author": "yuang",
|
|
26
24
|
"license": "ISC",
|
|
27
25
|
"dependencies": {
|
|
@@ -30,6 +28,7 @@
|
|
|
30
28
|
"axios": "^1.7.3",
|
|
31
29
|
"element-plus": "^2.7.8",
|
|
32
30
|
"js-cookie": "^3.0.5",
|
|
31
|
+
"moment": "^2.30.1",
|
|
33
32
|
"pinia": "^2.1.7",
|
|
34
33
|
"vue": "^3.4.29",
|
|
35
34
|
"vue-router": "^4.3.3"
|
|
@@ -46,7 +45,6 @@
|
|
|
46
45
|
"@vue/eslint-config-typescript": "^13.0.0",
|
|
47
46
|
"@vue/test-utils": "^2.4.6",
|
|
48
47
|
"@vue/tsconfig": "^0.5.1",
|
|
49
|
-
"cypress": "^13.12.0",
|
|
50
48
|
"eslint": "^8.57.0",
|
|
51
49
|
"eslint-plugin-cypress": "^3.3.0",
|
|
52
50
|
"eslint-plugin-vue": "^9.23.0",
|
package/src/config/http.ts
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
1
1
|
import axios from "axios"
|
|
2
2
|
import router from "@/router/index";
|
|
3
3
|
|
|
4
|
+
import {clearSsoAccessToken} from '@/utils/ssoUtils';
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
const $http = axios.create({
|
|
6
|
-
baseURL: '/
|
|
8
|
+
baseURL: '/gateway-api/',
|
|
7
9
|
timeout: 5000,
|
|
8
|
-
headers: {
|
|
10
|
+
headers: {}
|
|
9
11
|
})
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
/* 请求拦截 */
|
|
13
|
-
$http.interceptors.request.use(
|
|
14
|
-
config => {
|
|
15
|
-
|
|
16
|
-
let anonymousAccessToken = localStorage.getItem("anonymousAccessToken") ?? 'test';
|
|
17
|
-
let ssoAccessToken = localStorage.getItem("ssoAccessToken") ?? '';
|
|
18
|
-
if (anonymousAccessToken) {
|
|
19
|
-
config.headers["anonymousAccessToken"] = anonymousAccessToken;
|
|
20
|
-
}
|
|
21
|
-
if (ssoAccessToken) {
|
|
22
|
-
config.headers["ssoAccessToken"] = ssoAccessToken;
|
|
23
|
-
}
|
|
24
|
-
|
|
15
|
+
$http.interceptors.request.use(config => {
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
let gatewayAccessToken = localStorage.getItem("gatewayAccessToken") ?? '';
|
|
18
|
+
let ssoAccessToken = localStorage.getItem("ssoAccessToken") ?? '';
|
|
19
|
+
if (gatewayAccessToken) {
|
|
20
|
+
config.headers["Gateway-Access-Token"] = gatewayAccessToken;
|
|
21
|
+
}
|
|
22
|
+
if (ssoAccessToken) {
|
|
23
|
+
config.headers["Sso-Access-Token"] = ssoAccessToken;
|
|
24
|
+
}
|
|
25
|
+
config.headers["Request-Id"] = 'test';
|
|
26
|
+
return config;
|
|
27
|
+
}, err => Promise.reject(err));
|
|
30
28
|
|
|
31
29
|
|
|
32
30
|
/* 响应拦截器 */
|
|
33
31
|
$http.interceptors.response.use((res) => {
|
|
34
32
|
// 登录过期处理
|
|
35
33
|
if (res.data.statusCode === 401) {
|
|
36
|
-
|
|
37
|
-
localStorage.removeItem('ssoRefreshToken');
|
|
34
|
+
clearSsoAccessToken();
|
|
38
35
|
router.push('/sso/login');
|
|
39
36
|
return Promise.reject(new Error(res.data.message));
|
|
40
37
|
}
|
package/src/router/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {ElMessage} from 'element-plus/es';
|
|
2
|
+
|
|
3
|
+
import http from '@/config/http';
|
|
4
|
+
|
|
5
|
+
const initGateway = () => {
|
|
6
|
+
return new Promise(async resolve => {
|
|
7
|
+
let gatewayAccessToken = localStorage.getItem("gatewayAccessToken");
|
|
8
|
+
if (!gatewayAccessToken) {
|
|
9
|
+
let res = await http.get('/server/gateway/getGatewayAccessToken');
|
|
10
|
+
if (res.data.statusCode != 200) {
|
|
11
|
+
return EleMessage.error(res.data.message);
|
|
12
|
+
}
|
|
13
|
+
localStorage.setItem("gatewayAccessToken", res.data.data.gatewayAccessToken);
|
|
14
|
+
}
|
|
15
|
+
resolve();
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
initGateway
|
|
22
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import Cookies from 'js-cookie'
|
|
5
|
+
|
|
6
|
+
const getSsoLoginUrl = function () {
|
|
7
|
+
return 'http://localhost:8110/sso-ui-pc/sso/login';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const getSsoLogoutUrl = function () {
|
|
11
|
+
return 'http://localhost:8110/sso-ui-pc/sso/logout';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const ssoAccessTokenCookieKey:string = 'Sso-Access-Token';
|
|
16
|
+
const ssoAccessTokenLocalKey:string = 'ssoAccessToken';
|
|
17
|
+
const ssoRefreshTokenLocalKey:string = 'ssoRefreshToken';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const getSsoAccessToken = function () {
|
|
21
|
+
let ssoAccessToken = Cookies.get(ssoAccessTokenCookieKey);
|
|
22
|
+
|
|
23
|
+
if (!ssoAccessToken) {
|
|
24
|
+
ssoAccessToken = localStorage.getItem(ssoAccessTokenLocalKey) as string;
|
|
25
|
+
return ssoAccessToken
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return ssoAccessToken
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const setSsoAccessToken = function (param: any) {
|
|
33
|
+
localStorage.setItem(ssoAccessTokenLocalKey, param.ssoAccessToken);
|
|
34
|
+
localStorage.setItem(ssoRefreshTokenLocalKey, param.ssoRefreshToken);
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const clearSsoAccessToken = function () {
|
|
40
|
+
Cookies.remove(ssoAccessTokenCookieKey);
|
|
41
|
+
|
|
42
|
+
localStorage.removeItem(ssoAccessTokenLocalKey);
|
|
43
|
+
localStorage.removeItem(ssoRefreshTokenLocalKey);
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
getSsoLoginUrl,
|
|
50
|
+
getSsoLogoutUrl,
|
|
51
|
+
|
|
52
|
+
getSsoAccessToken,
|
|
53
|
+
setSsoAccessToken,
|
|
54
|
+
|
|
55
|
+
clearSsoAccessToken,
|
|
56
|
+
|
|
57
|
+
}
|
package/dist/favicon.ico
DELETED
|
Binary file
|
package/dist/style.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
button[data-v-842edfb2]{width:100px;height:50px;display:flex;align-items:center;justify-content:center;border:none;border-radius:10px;cursor:pointer}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineComponent as s, getCurrentInstance as r, openBlock as a, createElementBlock as _, createElementVNode as u } from "vue";
|
|
2
|
-
const l = /* @__PURE__ */ s({
|
|
3
|
-
__name: "index",
|
|
4
|
-
setup(e) {
|
|
5
|
-
const { proxy: t } = r(), n = () => {
|
|
6
|
-
t.$message.success("我是测试按钮");
|
|
7
|
-
};
|
|
8
|
-
return (o, c) => (a(), _("div", null, [
|
|
9
|
-
u("button", { onClick: n }, "我是测试按钮")
|
|
10
|
-
]));
|
|
11
|
-
}
|
|
12
|
-
}), p = (e, t) => {
|
|
13
|
-
const n = e.__vccOpts || e;
|
|
14
|
-
for (const [o, c] of t)
|
|
15
|
-
n[o] = c;
|
|
16
|
-
return n;
|
|
17
|
-
}, m = /* @__PURE__ */ p(l, [["__scopeId", "data-v-842edfb2"]]), f = [m], d = function(e) {
|
|
18
|
-
f.forEach((t) => {
|
|
19
|
-
e.component(t.name, t);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
d as default
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(e,o){typeof exports=="object"&&typeof module<"u"?module.exports=o(require("vue")):typeof define=="function"&&define.amd?define(["vue"],o):(e=typeof globalThis<"u"?globalThis:e||self,e["yuang-framework-ui-pc"]=o(e.Vue))})(this,function(e){"use strict";const i=[((t,n)=>{const c=t.__vccOpts||t;for(const[s,u]of n)c[s]=u;return c})(e.defineComponent({__name:"index",setup(t){const{proxy:n}=e.getCurrentInstance(),c=()=>{n.$message.success("我是测试按钮")};return(s,u)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{onClick:c},"我是测试按钮")]))}}),[["__scopeId","data-v-842edfb2"]])];return function(t){i.forEach(n=>{t.component(n.name,n)})}});
|
package/src/common/ssoClient.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import Cookies from "js-cookie"
|
|
5
|
-
|
|
6
|
-
// const getLoginUrl = function () {
|
|
7
|
-
// return window.$config.sso.loginUrl;
|
|
8
|
-
// }
|
|
9
|
-
//
|
|
10
|
-
// const getLogoutUrl = function () {
|
|
11
|
-
// return window.$config.sso.logoutUrl;
|
|
12
|
-
// }
|
|
13
|
-
//
|
|
14
|
-
// const getTicketUrl = function () {
|
|
15
|
-
// return window.$config.sso.ticketUrl;
|
|
16
|
-
// }
|
|
17
|
-
//
|
|
18
|
-
// const getSessionName = function () {
|
|
19
|
-
// return window.$config.sso.sessionName;
|
|
20
|
-
// }
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const getUserUid = function () {
|
|
24
|
-
// const userUid = Cookies.get(getSessionName())
|
|
25
|
-
//
|
|
26
|
-
// if (userUid === null || userUid === undefined || userUid.length === 0) {
|
|
27
|
-
// return null
|
|
28
|
-
// }
|
|
29
|
-
//
|
|
30
|
-
// return userUid
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// const setUserUid = function (userUid) {
|
|
34
|
-
// Cookies.set(getSessionName(), userUid)
|
|
35
|
-
// }
|
|
36
|
-
|
|
37
|
-
function getTokenName() {
|
|
38
|
-
return "ssoAccessToken"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getToken() {
|
|
42
|
-
const token = Cookies.get(getTokenName())
|
|
43
|
-
|
|
44
|
-
if (token === null || token === undefined || token.length === 0) {
|
|
45
|
-
return null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return token
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// export function setToken(token: String) {
|
|
52
|
-
// Cookies.set(getTokenName(), token)
|
|
53
|
-
// }
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// const clearUserUid = function () {
|
|
58
|
-
// Cookies.remove(getSessionName())
|
|
59
|
-
// }
|
|
60
|
-
|
|
61
|
-
const clearToken = function () {
|
|
62
|
-
Cookies.remove(getTokenName())
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const signOut = function () {
|
|
66
|
-
// clearUserUid()
|
|
67
|
-
// clearToken()
|
|
68
|
-
//
|
|
69
|
-
// if(window.$config.sso.useMode == 1) {
|
|
70
|
-
// var parent = document.querySelector("body");
|
|
71
|
-
// var iframe = document.createElement("iframe");
|
|
72
|
-
// iframe.setAttribute("src", getLogoutUrl());
|
|
73
|
-
// iframe.setAttribute("style", "display:none;");
|
|
74
|
-
//
|
|
75
|
-
// parent.appendChild(iframe);
|
|
76
|
-
// }else if(window.$config.sso.useMode == 2) {
|
|
77
|
-
// let win = window.open(getLogoutUrl());
|
|
78
|
-
// setTimeout(()=>{
|
|
79
|
-
// win.close();
|
|
80
|
-
// },100);
|
|
81
|
-
// }else{
|
|
82
|
-
// const actionUrl = encodeURIComponent(`${window.$config.misAdmin.fullBaseUrl}/server/sso/login?actionUrl=/`)
|
|
83
|
-
// window.location.href = `${getLogoutUrl()}?actionUrl=${actionUrl}`
|
|
84
|
-
// }
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export default {
|
|
89
|
-
// getLoginUrl,
|
|
90
|
-
// getLogoutUrl,
|
|
91
|
-
// getTicketUrl,
|
|
92
|
-
// getSessionName,
|
|
93
|
-
|
|
94
|
-
getUserUid,
|
|
95
|
-
// setUserUid,
|
|
96
|
-
// setToken,
|
|
97
|
-
getToken,
|
|
98
|
-
signOut,
|
|
99
|
-
// clearUserUid,
|
|
100
|
-
clearToken,
|
|
101
|
-
|
|
102
|
-
}
|