yuang-framework-ui-pc 1.0.0

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
package/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ button[data-v-a6bc3172]{width:100px;height:50px;display:flex;align-items:center;justify-content:center;border:none;border-radius:10px;cursor:pointer}
@@ -0,0 +1,23 @@
1
+ import { openBlock as s, createElementBlock as a, pushScopeId as r, popScopeId as p, createElementVNode as _ } from "vue";
2
+ const d = (t, o) => {
3
+ const e = t.__vccOpts || t;
4
+ for (const [c, n] of o)
5
+ e[c] = n;
6
+ return e;
7
+ }, u = {
8
+ name: "YuButton"
9
+ //组件名
10
+ }, l = (t) => (r("data-v-a6bc3172"), t = t(), p(), t), i = /* @__PURE__ */ l(() => /* @__PURE__ */ _("button", null, "我是测试按钮", -1)), f = [
11
+ i
12
+ ];
13
+ function m(t, o, e, c, n, B) {
14
+ return s(), a("div", null, f);
15
+ }
16
+ const h = /* @__PURE__ */ d(u, [["render", m], ["__scopeId", "data-v-a6bc3172"]]), v = [h], $ = function(t) {
17
+ v.forEach((o) => {
18
+ t.component(o.name, o);
19
+ });
20
+ };
21
+ export {
22
+ $ as default
23
+ };
@@ -0,0 +1 @@
1
+ (function(e,n){typeof exports=="object"&&typeof module<"u"?module.exports=n(require("vue")):typeof define=="function"&&define.amd?define(["vue"],n):(e=typeof globalThis<"u"?globalThis:e||self,e["yuang-framework-ui-pc"]=n(e.Vue))})(this,function(e){"use strict";const n=(t,o)=>{const c=t.__vccOpts||t;for(const[s,i]of o)c[s]=i;return c},u={name:"YuButton"},d=[(t=>(e.pushScopeId("data-v-a6bc3172"),t=t(),e.popScopeId(),t))(()=>e.createElementVNode("button",null,"我是测试按钮",-1))];function p(t,o,c,s,i,h){return e.openBlock(),e.createElementBlock("div",null,d)}const r=[n(u,[["render",p],["__scopeId","data-v-a6bc3172"]])];return function(t){r.forEach(o=>{t.component(o.name,o)})}});
package/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <link rel="icon" href="/favicon.ico">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Vite App</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "yuang-framework-ui-pc",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vite build",
9
+ "preview": "vite preview",
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
+ "build-only": "vite build",
14
+ "type-check": "vue-tsc --build --force",
15
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
16
+ "format": "prettier --write src/"
17
+ },
18
+ "author": "yuang",
19
+ "license": "ISC",
20
+ "dependencies": {
21
+ "@wangeditor/editor": "^5.1.23",
22
+ "@wangeditor/editor-for-vue": "^5.1.12",
23
+ "axios": "^1.7.3",
24
+ "element-plus": "^2.7.8",
25
+ "js-cookie": "^3.0.5",
26
+ "pinia": "^2.1.7",
27
+ "vue": "^3.4.29",
28
+ "vue-router": "^4.3.3"
29
+ },
30
+ "devDependencies": {
31
+ "@rushstack/eslint-patch": "^1.8.0",
32
+ "@tsconfig/node20": "^20.1.4",
33
+ "@types/js-cookie": "^3.0.6",
34
+ "@types/jsdom": "^21.1.7",
35
+ "@types/node": "^20.14.5",
36
+ "@vitejs/plugin-vue": "^5.0.5",
37
+ "@vitejs/plugin-vue-jsx": "^4.0.0",
38
+ "@vue/eslint-config-prettier": "^9.0.0",
39
+ "@vue/eslint-config-typescript": "^13.0.0",
40
+ "@vue/test-utils": "^2.4.6",
41
+ "@vue/tsconfig": "^0.5.1",
42
+ "cypress": "^13.12.0",
43
+ "eslint": "^8.57.0",
44
+ "eslint-plugin-cypress": "^3.3.0",
45
+ "eslint-plugin-vue": "^9.23.0",
46
+ "jsdom": "^24.1.0",
47
+ "npm-run-all2": "^6.2.0",
48
+ "prettier": "^3.2.5",
49
+ "start-server-and-test": "^2.0.4",
50
+ "typescript": "~5.4.0",
51
+ "vite": "^5.3.1",
52
+ "vite-plugin-vue-devtools": "^7.3.1",
53
+ "vitest": "^1.6.0",
54
+ "vue-tsc": "^2.0.21"
55
+ }
56
+ }
Binary file
package/src/App.vue ADDED
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <RouterView/>
3
+ <yu-button></yu-button>
4
+ </template>
5
+ <script setup lang="ts">
6
+ import {RouterView} from 'vue-router'
7
+
8
+ import YuButton from '@/packages/YuButton/index.vue'
9
+
10
+ </script>
11
+
12
+
13
+ <style scoped>
14
+
15
+ </style>
@@ -0,0 +1,102 @@
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
+ }
@@ -0,0 +1,47 @@
1
+ import axios from "axios"
2
+ import router from "@/router/index";
3
+
4
+
5
+ const $http = axios.create({
6
+ baseURL: '/sso-api/',
7
+ timeout: 5000,
8
+ headers: {'Authorization': 'none'}
9
+ })
10
+
11
+
12
+ /* 请求拦截 */
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
+
25
+
26
+ return config;
27
+ },
28
+ err => Promise.reject(err)
29
+ );
30
+
31
+
32
+ /* 响应拦截器 */
33
+ $http.interceptors.response.use((res) => {
34
+ // 登录过期处理
35
+ if (res.data.statusCode === 401) {
36
+ localStorage.removeItem('ssoAccessToken');
37
+ localStorage.removeItem('ssoRefreshToken');
38
+ router.push('/sso/login');
39
+ return Promise.reject(new Error(res.data.message));
40
+ }
41
+ return res;
42
+ }, (error) => {
43
+ return Promise.reject(error);
44
+ });
45
+
46
+
47
+ export default $http
package/src/main.ts ADDED
@@ -0,0 +1,34 @@
1
+
2
+ import { createApp } from 'vue'
3
+ import { createPinia } from 'pinia'
4
+
5
+ import App from './App.vue'
6
+ import router from './router'
7
+
8
+
9
+ import ElementPlus from 'element-plus'
10
+ import 'element-plus/dist/index.css'
11
+ import { ElMessage } from 'element-plus'
12
+
13
+
14
+
15
+ const app = createApp(App)
16
+
17
+
18
+ import http from '@/config/http';
19
+
20
+ app.config.globalProperties.$http = http;
21
+ app.config.globalProperties.$message = ElMessage
22
+
23
+
24
+ app.use(createPinia())
25
+ app.use(router)
26
+
27
+ app.use(ElementPlus)
28
+
29
+ app.mount('#app')
30
+
31
+
32
+ // https://blog.csdn.net/qq_34569497/article/details/133643863
33
+ // npm config set registry=https://registry.npmjs.org
34
+ // npm config set registry=https://registry.npmmirror.com
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <div>
3
+ <button>我是测试按钮</button>
4
+ </div>
5
+ </template>
6
+ <script>
7
+ export default {
8
+ name: "YuButton", //组件名
9
+ };
10
+ </script>
11
+ <style scoped>
12
+ button {
13
+ width: 100px;
14
+ height: 50px;
15
+ display: flex;
16
+ align-items: center;
17
+ justify-content: center;
18
+ border: none;
19
+ border-radius: 10px;
20
+ cursor: pointer;
21
+ }
22
+ </style>
@@ -0,0 +1,13 @@
1
+ // 引入封装好的组件
2
+ import YuButton from "../packages/YuButton/index.vue";
3
+ // 将来如果有其它组件,都可以写到这个数组里
4
+ const components = [ YuButton ];
5
+
6
+ // 批量组件注册
7
+ const install = function (Vue) {
8
+ components.forEach((component) => {
9
+ Vue.component(component.name, component);
10
+ });
11
+ };
12
+
13
+ export default install;
@@ -0,0 +1,19 @@
1
+ import {createRouter, createWebHistory} from 'vue-router'
2
+
3
+ import ssoClient from '../common/ssoClient';
4
+
5
+ const router = createRouter({
6
+ history: createWebHistory(import.meta.env.BASE_URL),
7
+ routes: [
8
+
9
+ ]
10
+ })
11
+
12
+
13
+ /* 路由守卫 */
14
+ router.beforeEach(async (to, from, next) => {
15
+ next();
16
+ });
17
+
18
+
19
+ export default router
@@ -0,0 +1,12 @@
1
+ import { ref, computed } from 'vue'
2
+ import { defineStore } from 'pinia'
3
+
4
+ export const useCounterStore = defineStore('counter', () => {
5
+ const count = ref(0)
6
+ const doubleCount = computed(() => count.value * 2)
7
+ function increment() {
8
+ count.value++
9
+ }
10
+
11
+ return { count, doubleCount, increment }
12
+ })
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
3
+ "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
4
+ "exclude": ["src/**/__tests__/*"],
5
+ "compilerOptions": {
6
+ "composite": true,
7
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
8
+
9
+ "baseUrl": ".",
10
+ "paths": {
11
+ "@/*": ["./src/*"]
12
+ }
13
+ }
14
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.node.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.app.json"
9
+ },
10
+ {
11
+ "path": "./tsconfig.vitest.json"
12
+ }
13
+ ],
14
+ "compilerOptions": {
15
+ "module": "NodeNext"
16
+ }
17
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "@tsconfig/node20/tsconfig.json",
3
+ "include": [
4
+ "vite.config.*",
5
+ "vitest.config.*",
6
+ "cypress.config.*",
7
+ "nightwatch.conf.*",
8
+ "playwright.config.*"
9
+ ],
10
+ "compilerOptions": {
11
+ "composite": true,
12
+ "noEmit": true,
13
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
14
+
15
+ "module": "ESNext",
16
+ "moduleResolution": "Bundler",
17
+ "types": ["node"]
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.app.json",
3
+ "exclude": [],
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
7
+
8
+ "lib": [],
9
+ "types": ["node", "jsdom"]
10
+ }
11
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+
3
+ import { defineConfig } from 'vite'
4
+ import vue from '@vitejs/plugin-vue'
5
+ import vueJsx from '@vitejs/plugin-vue-jsx'
6
+
7
+ // https://vitejs.dev/config/
8
+ export default defineConfig({
9
+ base: "/framework-ui-pc",
10
+ server: {
11
+ port: 8110,
12
+ proxy: {
13
+ '/sso-api': {
14
+ target: 'http://localhost:8150/sso-api', // 目标服务器的地址
15
+ changeOrigin: true,
16
+ rewrite: (path) => path.replace(/^\/sso-api/, '') // 将请求路径中的'/api'替换为空字符串
17
+ }
18
+ }
19
+ },
20
+ plugins: [
21
+ vue(),
22
+ vueJsx(),
23
+ ],
24
+ resolve: {
25
+ alias: {
26
+ '@': fileURLToPath(new URL('./src', import.meta.url))
27
+ }
28
+ },
29
+ build: {
30
+ lib: {
31
+ entry: './src/packages/index.js',
32
+ name: 'yuang-framework-ui-pc',
33
+ fileName: (format) => `yuang-framework-ui-pc.${format}.js`,
34
+ },
35
+ rollupOptions: {
36
+ // 确保外部化处理依赖
37
+ external: ['vue'],
38
+ output: {
39
+ globals: {
40
+ vue: 'Vue',
41
+ },
42
+ },
43
+ },
44
+ },
45
+ })
@@ -0,0 +1,14 @@
1
+ import { fileURLToPath } from 'node:url'
2
+ import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
3
+ import viteConfig from './vite.config'
4
+
5
+ export default mergeConfig(
6
+ viteConfig,
7
+ defineConfig({
8
+ test: {
9
+ environment: 'jsdom',
10
+ exclude: [...configDefaults.exclude, 'e2e/**'],
11
+ root: fileURLToPath(new URL('./', import.meta.url))
12
+ }
13
+ })
14
+ )