yuang-framework-ui-common 1.0.2

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/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # vue3-demo
2
+
3
+ This template should help get you started developing with Vue 3 in Vite.
4
+
5
+ ## Recommended IDE Setup
6
+
7
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
8
+
9
+ ## Type Support for `.vue` Imports in TS
10
+
11
+ TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
12
+
13
+ ## Customize configuration
14
+
15
+ See [Vite Configuration Reference](https://vitejs.dev/config/).
16
+
17
+ ## Project Setup
18
+
19
+ ```sh
20
+ npm install
21
+ ```
22
+
23
+ ### Compile and Hot-Reload for Development
24
+
25
+ ```sh
26
+ npm run dev
27
+ ```
28
+
29
+ ### Type-Check, Compile and Minify for Production
30
+
31
+ ```sh
32
+ npm run build
33
+ ```
34
+
35
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
36
+
37
+ ```sh
38
+ npm run test:unit
39
+ ```
40
+
41
+ ### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
42
+
43
+ ```sh
44
+ npm run test:e2e:dev
45
+ ```
46
+
47
+ This runs the end-to-end tests against the Vite development server.
48
+ It is much faster than the production build.
49
+
50
+ But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):
51
+
52
+ ```sh
53
+ npm run build
54
+ npm run test:e2e
55
+ ```
56
+
57
+ ### Lint with [ESLint](https://eslint.org/)
58
+
59
+ ```sh
60
+ npm run lint
61
+ ```
Binary file
@@ -0,0 +1,4 @@
1
+ const e = {};
2
+ export {
3
+ e as default
4
+ };
@@ -0,0 +1 @@
1
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n():typeof define=="function"&&define.amd?define(n):(e=typeof globalThis<"u"?globalThis:e||self,e["yuang-framework-ui-common"]=n())})(this,function(){"use strict";return{}});
@@ -0,0 +1,44 @@
1
+ import axios from "axios"
2
+
3
+ import {clearSsoAccessToken} from '../utils/ssoUtils';
4
+
5
+
6
+ const $http = axios.create({
7
+ baseURL: '/gateway-api/',
8
+ timeout: 5000,
9
+ headers: {}
10
+ })
11
+
12
+
13
+ /* 请求拦截 */
14
+ $http.interceptors.request.use(config => {
15
+
16
+ let gatewayAccessToken = localStorage.getItem("gatewayAccessToken") ?? '';
17
+ let ssoAccessToken = localStorage.getItem("ssoAccessToken") ?? '';
18
+ if (gatewayAccessToken) {
19
+ config.headers["Gateway-Access-Token"] = gatewayAccessToken;
20
+ }
21
+ if (ssoAccessToken) {
22
+ config.headers["Sso-Access-Token"] = ssoAccessToken;
23
+ }
24
+ config.headers["Request-Id"] = 'test';
25
+ return config;
26
+ }, err => Promise.reject(err));
27
+
28
+
29
+ /* 响应拦截器 */
30
+ $http.interceptors.response.use((res) => {
31
+ // 登录过期处理
32
+ if (res.data.statusCode === 401) {
33
+ clearSsoAccessToken();
34
+ // router.push('/sso/login');
35
+ location.href = 'http://localhost:8110/sso-ui-pc/sso/login';
36
+ return Promise.reject(new Error(res.data.message));
37
+ }
38
+ return res;
39
+ }, (error) => {
40
+ return Promise.reject(error);
41
+ });
42
+
43
+
44
+ export default $http
package/lib/index.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export default {};
@@ -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/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "yuang-framework-ui-common",
3
+ "version": "1.0.2",
4
+ "private": false,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
10
+ "test:unit": "vitest",
11
+ "build-only": "vite build",
12
+ "type-check": "vue-tsc --build --force",
13
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
14
+ "format": "prettier --write src/"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "lib"
19
+ ],
20
+ "main": "dist/yuang-framework-ui-common.umd.js",
21
+ "module": "dist/yuang-framework-ui-common.es.js",
22
+ "unpkg": "dist/yuang-framework-ui-common.iife.js",
23
+ "author": "yuang",
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "@wangeditor/editor": "^5.1.23",
27
+ "@wangeditor/editor-for-vue": "^5.1.12",
28
+ "axios": "^1.7.3",
29
+ "element-plus": "^2.7.8",
30
+ "js-cookie": "^3.0.5",
31
+ "moment": "^2.30.1",
32
+ "pinia": "^2.1.7",
33
+ "vue": "^3.4.29",
34
+ "vue-router": "^4.3.3"
35
+ },
36
+ "devDependencies": {
37
+ "@rushstack/eslint-patch": "^1.8.0",
38
+ "@tsconfig/node20": "^20.1.4",
39
+ "@types/js-cookie": "^3.0.6",
40
+ "@types/jsdom": "^21.1.7",
41
+ "@types/node": "^20.14.5",
42
+ "@vitejs/plugin-vue": "^5.0.5",
43
+ "@vitejs/plugin-vue-jsx": "^4.0.0",
44
+ "@vue/eslint-config-prettier": "^9.0.0",
45
+ "@vue/eslint-config-typescript": "^13.0.0",
46
+ "@vue/test-utils": "^2.4.6",
47
+ "@vue/tsconfig": "^0.5.1",
48
+ "eslint": "^8.57.0",
49
+ "eslint-plugin-cypress": "^3.3.0",
50
+ "eslint-plugin-vue": "^9.23.0",
51
+ "jsdom": "^24.1.0",
52
+ "npm-run-all2": "^6.2.0",
53
+ "prettier": "^3.2.5",
54
+ "start-server-and-test": "^2.0.4",
55
+ "typescript": "~5.4.0",
56
+ "vite": "^5.3.1",
57
+ "vite-plugin-vue-devtools": "^7.3.1",
58
+ "vitest": "^1.6.0",
59
+ "vue-tsc": "^2.1.6"
60
+ }
61
+ }