diff --git a/.dockerignore b/.dockerignore index 6bac7ddea..54adfc695 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ .DS_Store node_modules/ dist/ +.vscode/ npm-debug.log* yarn-debug.log* @@ -15,6 +16,4 @@ tests/**/coverage/ *.ntvs* *.njsproj *.sln - -# env -.env.* + \ No newline at end of file diff --git a/.env.production b/.env.production index 2d979dba5..7aad938e0 100644 --- a/.env.production +++ b/.env.production @@ -3,6 +3,7 @@ ENV = 'production' # base api url VITE_BASE_API_URL = 'https://nest-api.buqiyuan.site' +# VITE_BASE_API_URL = 'http://127.0.0.1:7001' VITE_BASE_SOCKET_PATH = '/ws-api' VITE_BASE_SOCKET_NSP = 'wss://nest-api.buqiyuan.site/admin' diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml new file mode 100644 index 000000000..3e21931cc --- /dev/null +++ b/.github/workflows/release-package.yml @@ -0,0 +1,46 @@ +name: Publish Package + +permissions: + id-token: write + contents: write + +on: + push: + branches: [main] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + + - name: Use Node.js v18 + uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + cache: pnpm + + - run: pnpm install + - run: pnpm run --filter \"./packages/**\" build + + - name: Publish + if: success() + uses: author/action-publish@stable + with: + # Optionally specify the directories to scan + # for modules. If this is not specified, the + # root directory is scanned. + scan: './packages' + # Optionally force publishing as a public + # module. We don't recommend setting this, + # unless you have a very specific use case. + force: true + env: + REGISTRY_TOKEN: '${{ secrets.NPM_TOKEN }}' diff --git a/Dockerfile b/Dockerfile index 1540032ac..9bd9b47df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,29 @@ -FROM node:lts-alpine as builder -ENV PROJECT_DIR=/vue3-antdv-admin +# https://stackoverflow.com/questions/53681522/share-variable-in-multi-stage-dockerfile-arg-before-from-not-substituted +ARG PROJECT_DIR=/vue3-antdv-admin +FROM node:20-slim as builder +ARG PROJECT_DIR WORKDIR $PROJECT_DIR # 安装pnpm RUN npm install -g pnpm +COPY . ./ # 安装依赖 -COPY package.json $PROJECT_DIR # 若网络不通,可以使用淘宝源 -RUN pnpm config set registry https://registry.npmmirror.com +# RUN pnpm config set registry https://registry.npmmirror.com RUN pnpm install # 构建项目 -COPY ./ $PROJECT_DIR -RUN rm -rf .env.* && pnpm build +ENV VITE_BASE_URL=/ +RUN pnpm build FROM nginx:alpine as production +ARG PROJECT_DIR -# 后端 API 端口 -ENV SERVER_PORT 7001 -# websocket 服务端口 -ENV WS_PORT 7002 - -COPY --from=builder /vue3-antdv-admin/dist/ /usr/share/nginx/html -COPY ./default.conf.template /etc/nginx/templates/ +COPY --from=builder $PROJECT_DIR/dist/ /usr/share/nginx/html +# COPY --from=builder $PROJECT_DIR/nginx.conf /etc/nginx/nginx.conf EXPOSE 80 diff --git a/README.md b/README.md index 4ac95b775..c2aa5b6df 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ - 在线预览( [gitee](http://buqiyuan.gitee.io/vue3-antdv-admin/) / [vercel](https://vue3-antdv-admin.vercel.app/) ) - [swagger 文档](https://nest-api.buqiyuan.site/swagger-api/) - [后台地址](https://github.com/buqiyuan/nest-admin) -- [vue-cli版](https://github.com/buqiyuan/vue3-antd-admin/tree/vue-cli) +- [vue-cli版](https://github.com/buqiyuan/vue3-antdv-admin/tree/vue-cli) - [gitee 地址](https://gitee.com/buqiyuan/vue3-antdv-admin) - 根据 JSON 生成 typescript 的工具:[http://json2ts.com/](http://json2ts.com/) diff --git a/default.conf.template b/default.conf.template deleted file mode 100644 index 8173607c8..000000000 --- a/default.conf.template +++ /dev/null @@ -1,54 +0,0 @@ -map $http_upgrade $connection_upgrade { - default upgrade; - '' close; -} - -server { - listen 80; - absolute_redirect off; #取消绝对路径的重定向 - sendfile on; - default_type application/octet-stream; - - gzip on; - gzip_http_version 1.1; - gzip_disable "MSIE [1-6]\."; - gzip_min_length 256; - gzip_vary on; - gzip_proxied expired no-cache no-store private auth; - gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; - gzip_comp_level 9; - - root /usr/share/nginx/html; - - location / { - # same docker config - root /usr/share/nginx/html; - index index.html; - # support history mode - try_files $uri $uri/ /index.html; - } - - # 后端服务 - location ^~ /api/ { - proxy_pass http://nest-admin-server:$SERVER_PORT/; # 转发规则 - proxy_set_header Host $proxy_host; # 修改转发请求头,让目标应用可以受到真实的请求 - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - - # websocket服务 - location ^~ /ws-api/ { - proxy_pass http://nest-admin-server:$WS_PORT/; - proxy_read_timeout 300s; - proxy_send_timeout 300s; - - proxy_set_header Host $host; - proxy_set_header X-real-ip $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - } - -} diff --git a/docker-compose.yml b/docker-compose.yml index 318bb86a4..5ae49e8b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,12 +1,15 @@ version: '3' services: - eoapi: + vue3-antdv-admin: # 从当前路径构建镜像 build: context: . dockerfile: Dockerfile target: production image: buqiyuan/vue3-antdv-admin:latest + ports: + - '80:80' env_file: - .env + - .env.production diff --git a/mocks/index.ts b/mocks/index.ts index d87a55548..6db0bd34f 100644 --- a/mocks/index.ts +++ b/mocks/index.ts @@ -1,4 +1,4 @@ -import { enableMocking } from '@admin-pkg/mock-server'; +import { enableMocking } from '@admin-pkg/vite-plugin-msw'; import { HttpHandler } from 'msw'; const modules = import.meta.glob('./**/*.ts', { diff --git a/package.json b/package.json index fd21d8ea6..a48473a0e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "deploy": "bash deploy.sh", "openapi": "npx tsx openapi.config.ts", "clean:cache": "npx rimraf node_modules/.cache/ && npx rimraf node_modules/.vite", - "clean:lib": "npx rimraf node_modules", + "clean:lib": "npx rimraf node_modules packages/*/node_modules", "format": "prettier --write .", "lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json --max-warnings 0 && pretty-quick --check --branch main", "lint:fix": "eslint --fix . --ext .vue,.js,.ts,.jsx,.tsx,.md,.json && pretty-quick --branch main", @@ -33,12 +33,12 @@ "test:br": "npx http-server dist --cors --brotli -c-1" }, "dependencies": { - "@admin-pkg/mock-server": "workspace:*", + "@admin-pkg/vite-plugin-msw": "workspace:*", "@ant-design/icons-vue": "~7.0.1", "@iconify/vue": "^4.1.1", "@tinymce/tinymce-vue": "^5.1.1", "@vueuse/core": "~10.7.2", - "ant-design-vue": "~4.1.1", + "ant-design-vue": "~4.1.2", "axios": "~1.6.7", "dayjs": "~1.11.10", "echarts": "^5.4.3", @@ -84,7 +84,7 @@ "eslint-define-config": "~2.1.0", "eslint-plugin-import": "~2.29.1", "eslint-plugin-prettier": "~5.1.3", - "eslint-plugin-vue": "~9.20.1", + "eslint-plugin-vue": "~9.21.0", "husky": "~9.0.7", "less": "~4.2.0", "lightningcss": "^1.23.0", @@ -136,7 +136,7 @@ }, "target": "web", "dependenciesMeta": { - "@admin-pkg/mock-server": { + "@admin-pkg/vite-plugin-msw": { "injected": true } }, diff --git a/packages/mock-server/package.json b/packages/mock-server/package.json deleted file mode 100644 index ec24f83f2..000000000 --- a/packages/mock-server/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "@admin-pkg/mock-server", - "version": "0.0.1", - "description": "", - "module": "./dist/browser/index.mjs", - "main": "./dist/browser/index.mjs", - "exports": { - ".": { - "import": "./dist/browser/index.mjs", - "require": "./dist/browser/index.mjs" - }, - "./vite": { - "import": "./dist/index.mjs", - "require": "./dist/index.js" - } - }, - "scripts": { - "prepare": "npm run build", - "dev": "rimraf dist && tsup --watch", - "build": "rimraf dist && tsup" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "@mswjs/interceptors": "^0.25.14", - "headers-polyfill": "^4.0.2", - "strict-event-emitter": "^0.5.1" - }, - "devDependencies": { - "tsup": "^8.0.1" - }, - "peerDependencies": { - "msw": "^2.0.0" - } -} diff --git a/packages/vite-plugin-msw/README.md b/packages/vite-plugin-msw/README.md new file mode 100644 index 000000000..b7461a4d0 --- /dev/null +++ b/packages/vite-plugin-msw/README.md @@ -0,0 +1,99 @@ +# @admin-pkg/vite-plugin-msw + +Mock Service Worker browser and node integration for Vite. + +## Usage + +### Install + +```sh +npm install --save-dev @admin-pkg/vite-plugin-msw +# yarn add --dev @admin-pkg/vite-plugin-msw +# pnpm add --save-dev @admin-pkg/vite-plugin-msw +``` + +### Define mocks + +https://mswjs.io/docs/getting-started/mocks + +--- + +## Config + +```ts +interface VitePluginMswOptions { + handlers?: RequestHandler[]; + mode?: 'browser' | 'node'; + build?: boolean; +} +``` + +### Handlers + +- Optional + +MSW handlers. More information on how to define these: https://mswjs.io/docs/getting-started/mocks + +### Mode + +- Optional +- Default: `browser` + +#### Browser + +To start MSW in the client, please follow the [Configure worker step](https://mswjs.io/docs/getting-started/integrate/browser#configure-worker) and [Start worker step](https://mswjs.io/docs/getting-started/integrate/browser#start-worker) in the MSW docs. The `mockServiceWorker.js` file will be provided by the Vite Dev Server. + +##### Example vite application + +```ts +import { enableMocking } from '@admin-pkg/vite-plugin-msw'; +import { HttpHandler } from 'msw'; + +const modules = import.meta.glob('./**/*.ts', { + eager: true, +}); + +export const setupMock = async () => { + const handlers = Object.values(modules).reduce((prev, curr) => { + const arr = curr?.default; + if (Array.isArray(arr)) { + arr.forEach((item) => { + if (item instanceof HttpHandler) { + prev.push(item); + } + }); + } + return prev; + }, []); + // console.log('handlers', handlers); + await enableMocking(handlers); +}; +``` + +#### Node + +This will handle the mocked service worker handlers via a Vite Dev Server plugin. + +##### Add to Vite config + +```ts +// Import plugin +import msw from '@admin-pkg/vite-plugin-msw'; + +// Import msw handlers +import { handlers } from '../mocks/handlers'; + +// Pass them to plugin +export default defineConfig({ + plugins: [msw({ handlers })], +}); +``` + +### Build + +- Optional +- Default: `false` + +A true value will output MSW's `mockServiceWorker.js` file to the Vite build directory, in case if MSW is needed in production. + +--- diff --git a/packages/vite-plugin-msw/package.json b/packages/vite-plugin-msw/package.json new file mode 100644 index 000000000..74934f8d2 --- /dev/null +++ b/packages/vite-plugin-msw/package.json @@ -0,0 +1,56 @@ +{ + "name": "@admin-pkg/vite-plugin-msw", + "version": "0.0.3", + "description": "", + "module": "./dist/browser/index.mjs", + "main": "./dist/browser/index.mjs", + "files": [ + "dist" + ], + "exports": { + ".": { + "import": "./dist/browser/index.mjs", + "require": "./dist/browser/index.mjs" + }, + "./vite": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } + }, + "scripts": { + "prepare": "npm run build", + "dev": "rimraf dist && tsup --watch", + "build": "rimraf dist && tsup" + }, + "keywords": [ + "msw", + "mock", + "vite" + ], + "author": { + "name": "buqiyuan", + "email": "1743369777@qq.com", + "url": "https://github.com/buqiyuan" + }, + "repository": { + "type": "git", + "url": "https://github.com/buqiyuan/vue3-antdv-admin/tree/main/packages/vite-plugin-msw", + "directory": "packages/vite-plugin-msw" + }, + "homepage": "https://buqiyuan.github.io/vue3-antdv-admin/tree/main/packages/vite-plugin-msw#readme", + "license": "MIT", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@mswjs/interceptors": "^0.25.15", + "headers-polyfill": "^4.0.2", + "strict-event-emitter": "^0.5.1" + }, + "devDependencies": { + "tsup": "^8.0.1" + }, + "peerDependencies": { + "msw": "^2.0.0" + } +} diff --git a/packages/mock-server/src/browser/enableMocking.ts b/packages/vite-plugin-msw/src/browser/enableMocking.ts similarity index 98% rename from packages/mock-server/src/browser/enableMocking.ts rename to packages/vite-plugin-msw/src/browser/enableMocking.ts index 61582d87e..b07fe1629 100644 --- a/packages/mock-server/src/browser/enableMocking.ts +++ b/packages/vite-plugin-msw/src/browser/enableMocking.ts @@ -23,7 +23,7 @@ const postMsg = (registration: ServiceWorkerRegistration, handlers: HttpHandler[ }; export const enableMocking = async (handlers: HttpHandler[]) => { - const scriptURL = `${import.meta.env.BASE_URL || ''}/mockServiceWorker.mjs`.replace( + const scriptURL = `${import.meta.env.BASE_URL || ''}/mockServiceWorker.js`.replace( /\/{2,}/g, '/', ); diff --git a/packages/mock-server/src/browser/index.ts b/packages/vite-plugin-msw/src/browser/index.ts similarity index 100% rename from packages/mock-server/src/browser/index.ts rename to packages/vite-plugin-msw/src/browser/index.ts diff --git a/packages/mock-server/src/browser/vitePlugin.ts b/packages/vite-plugin-msw/src/browser/vitePlugin.ts similarity index 95% rename from packages/mock-server/src/browser/vitePlugin.ts rename to packages/vite-plugin-msw/src/browser/vitePlugin.ts index 1292f4026..84f2fb5f3 100644 --- a/packages/mock-server/src/browser/vitePlugin.ts +++ b/packages/vite-plugin-msw/src/browser/vitePlugin.ts @@ -2,7 +2,7 @@ import { readFile, copyFile } from 'node:fs/promises'; import { resolve } from 'node:path'; import type { Connect } from 'vite'; -const swFileName = 'mockServiceWorker.mjs'; +const swFileName = 'mockServiceWorker.js'; const localMswDistPath = resolve(__dirname, swFileName); export const createBrowserMiddleware = (): Connect.NextHandleFunction => { diff --git a/packages/mock-server/src/buildLocalMswFile.ts b/packages/vite-plugin-msw/src/buildLocalMswFile.ts similarity index 93% rename from packages/mock-server/src/buildLocalMswFile.ts rename to packages/vite-plugin-msw/src/buildLocalMswFile.ts index 8eb6547a4..c8c4d0482 100644 --- a/packages/mock-server/src/buildLocalMswFile.ts +++ b/packages/vite-plugin-msw/src/buildLocalMswFile.ts @@ -16,7 +16,7 @@ const replaceCodeParts = [ { from: 'const INTEGRITY_CHECKSUM = ', to: ` -// Inject by @admin-pkg/mock-server +// Inject by @admin-pkg/vite-plugin-msw import { isMatchHandler } from './utils/isMatchHandler'; const INTEGRITY_CHECKSUM = `, }, @@ -24,7 +24,7 @@ const INTEGRITY_CHECKSUM = `, from: `self.addEventListener('message', async function (event) {`, to: ` self.addEventListener('message', async function (event) { - // Inject by @admin-pkg/mock-server + // Inject by @admin-pkg/vite-plugin-msw if (event.data?.type === 'updateMockHeaders') { globalThis.mockHeaders = event.data.mockHeaders || []; // console.log('globalThis.mockHeaders', globalThis.mockHeaders); @@ -39,7 +39,7 @@ self.addEventListener('fetch', function (event) { self.addEventListener('fetch', function (event) { const { request } = event - // Inject by @admin-pkg/mock-server + // Inject by @admin-pkg/vite-plugin-msw const isMockRequest = isMatchHandler(request); // console.log('isMockRequest', request.url, isMockRequest); if (isMockRequest === false) { diff --git a/packages/mock-server/src/index.ts b/packages/vite-plugin-msw/src/index.ts similarity index 100% rename from packages/mock-server/src/index.ts rename to packages/vite-plugin-msw/src/index.ts diff --git a/packages/mock-server/src/mockServiceWorker.js b/packages/vite-plugin-msw/src/mockServiceWorker.js similarity index 98% rename from packages/mock-server/src/mockServiceWorker.js rename to packages/vite-plugin-msw/src/mockServiceWorker.js index 1d2e58557..3a21716e3 100644 --- a/packages/mock-server/src/mockServiceWorker.js +++ b/packages/vite-plugin-msw/src/mockServiceWorker.js @@ -2,13 +2,13 @@ /* tslint:disable */ /** - * Mock Service Worker (2.1.3). + * Mock Service Worker (2.1.5). * @see https://github.com/mswjs/msw * - Please do NOT modify this file. * - Please do NOT serve this file on production. */ -// Inject by @admin-pkg/mock-server +// Inject by @admin-pkg/vite-plugin-msw import { isMatchHandler } from './utils/isMatchHandler'; const INTEGRITY_CHECKSUM = '223d191a56023cd36aa88c802961b911'; const IS_MOCKED_RESPONSE = Symbol('isMockedResponse'); @@ -23,7 +23,7 @@ self.addEventListener('activate', function (event) { }); self.addEventListener('message', async function (event) { - // Inject by @admin-pkg/mock-server + // Inject by @admin-pkg/vite-plugin-msw if (event.data?.type === 'updateMockHeaders') { globalThis.mockHeaders = event.data.mockHeaders || []; // console.log('globalThis.mockHeaders', globalThis.mockHeaders); @@ -96,7 +96,7 @@ self.addEventListener('message', async function (event) { self.addEventListener('fetch', function (event) { const { request } = event; - // Inject by @admin-pkg/mock-server + // Inject by @admin-pkg/vite-plugin-msw const isMockRequest = isMatchHandler(request); // console.log('isMockRequest', request.url, isMockRequest); if (isMockRequest === false) { diff --git a/packages/mock-server/src/node/index.ts b/packages/vite-plugin-msw/src/node/index.ts similarity index 100% rename from packages/mock-server/src/node/index.ts rename to packages/vite-plugin-msw/src/node/index.ts diff --git a/packages/mock-server/src/utils/isMatchHandler.ts b/packages/vite-plugin-msw/src/utils/isMatchHandler.ts similarity index 100% rename from packages/mock-server/src/utils/isMatchHandler.ts rename to packages/vite-plugin-msw/src/utils/isMatchHandler.ts diff --git a/packages/mock-server/src/utils/log.ts b/packages/vite-plugin-msw/src/utils/log.ts similarity index 100% rename from packages/mock-server/src/utils/log.ts rename to packages/vite-plugin-msw/src/utils/log.ts diff --git a/packages/mock-server/tsconfig.json b/packages/vite-plugin-msw/tsconfig.json similarity index 100% rename from packages/mock-server/tsconfig.json rename to packages/vite-plugin-msw/tsconfig.json diff --git a/packages/mock-server/tsup.config.ts b/packages/vite-plugin-msw/tsup.config.ts similarity index 92% rename from packages/mock-server/tsup.config.ts rename to packages/vite-plugin-msw/tsup.config.ts index 20e0b49de..8c52cbd1b 100644 --- a/packages/mock-server/tsup.config.ts +++ b/packages/vite-plugin-msw/tsup.config.ts @@ -37,6 +37,11 @@ export default defineConfig(async () => { platform: 'browser', minify: false, noExternal: ['msw', '@mswjs/interceptors', 'strict-event-emitter'], + outExtension() { + return { + js: `.js`, + }; + }, }, ]; }); diff --git a/packages/mock-server/types/module.d.ts b/packages/vite-plugin-msw/types/module.d.ts similarity index 100% rename from packages/mock-server/types/module.d.ts rename to packages/vite-plugin-msw/types/module.d.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1c9a73e67..d2f8fbad8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,9 @@ importers: .: dependencies: - '@admin-pkg/mock-server': + '@admin-pkg/vite-plugin-msw': specifier: workspace:* - version: file:packages/mock-server(msw@2.1.5) + version: file:packages/vite-plugin-msw(msw@2.1.5) '@ant-design/icons-vue': specifier: ~7.0.1 version: 7.0.1(vue@3.4.15) @@ -24,8 +24,8 @@ importers: specifier: ~10.7.2 version: 10.7.2(vue@3.4.15) ant-design-vue: - specifier: ~4.1.1 - version: 4.1.1(vue@3.4.15) + specifier: ~4.1.2 + version: 4.1.2(vue@3.4.15) axios: specifier: ~1.6.7 version: 1.6.7 @@ -157,8 +157,8 @@ importers: specifier: ~5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.56.0)(prettier@3.2.4) eslint-plugin-vue: - specifier: ~9.20.1 - version: 9.20.1(eslint@8.56.0) + specifier: ~9.21.0 + version: 9.21.0(eslint@8.56.0) husky: specifier: ~9.0.7 version: 9.0.7 @@ -247,20 +247,20 @@ importers: specifier: ~1.8.27 version: 1.8.27(typescript@5.3.3) dependenciesMeta: - '@admin-pkg/mock-server': + '@admin-pkg/vite-plugin-msw': injected: true - packages/mock-server: + packages/vite-plugin-msw: dependencies: '@mswjs/interceptors': - specifier: ^0.25.14 - version: 0.25.14 + specifier: ^0.25.15 + version: 0.25.15 headers-polyfill: specifier: ^4.0.2 version: 4.0.2 msw: specifier: ^2.0.0 - version: 2.1.3(typescript@5.3.3) + version: 2.1.5(typescript@5.3.3) strict-event-emitter: specifier: ^0.5.1 version: 0.5.1 @@ -1649,12 +1649,6 @@ packages: dependencies: cookie: 0.5.0 - /@bundled-es-modules/js-levenshtein@2.0.1: - resolution: {integrity: sha512-DERMS3yfbAljKsQc0U2wcqGKUWpdFjwqWuoMugEJlqBnKO180/n+4SR/J8MRDt1AN48X1ovgoD9KrdVXcaa3Rg==} - dependencies: - js-levenshtein: 1.1.6 - dev: false - /@bundled-es-modules/statuses@1.0.1: resolution: {integrity: sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==} dependencies: @@ -2322,18 +2316,6 @@ packages: resolution: {integrity: sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw==} engines: {node: '>=18'} - /@mswjs/interceptors@0.25.14: - resolution: {integrity: sha512-2dnIxl+obqIqjoPXTFldhe6pcdOrqiz+GcLaQQ6hmL02OldAF7nIC+rUgTWm+iF6lvmyCVhFFqbgbapNhR8eag==} - engines: {node: '>=18'} - dependencies: - '@open-draft/deferred-promise': 2.2.0 - '@open-draft/logger': 0.3.0 - '@open-draft/until': 2.1.0 - is-node-process: 1.2.0 - outvariant: 1.4.2 - strict-event-emitter: 0.5.1 - dev: false - /@mswjs/interceptors@0.25.15: resolution: {integrity: sha512-s4jdyxmq1eeftfDXJ7MUiK/jlvYaU8Sr75+42hHCVBrYez0k51RHbMitKIKdmsF92Q6gwhp8Sm1MmvdA9llpcg==} engines: {node: '>=18'} @@ -2610,10 +2592,6 @@ packages: '@types/node': 20.10.8 dev: true - /@types/js-levenshtein@1.1.3: - resolution: {integrity: sha512-jd+Q+sD20Qfu9e2aEXogiO3vpOC1PYJOUdyN9gvs4Qrvkg4wF43L5OhqrPeokdv8TL0/mXoYfpkcoGZMNN2pkQ==} - dev: false - /@types/json-schema@7.0.15: resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} dev: true @@ -3645,8 +3623,8 @@ packages: engines: {node: '>=12'} dev: true - /ant-design-vue@4.1.1(vue@3.4.15): - resolution: {integrity: sha512-YLhDHhGvegGEczxDqIiiZIJsTHh3dge5Rf94n17sp24gAcey0hDaLtYWM0Z/+N8EheAcM0w3fePvYGMxwGxSDg==} + /ant-design-vue@4.1.2(vue@3.4.15): + resolution: {integrity: sha512-ynFkDJLlHgumeK6Hr1UZ7PvQNZ1uBcri/pmejBdS3kRqHeA5VRsxneYDwa8YxA+uYB5YfT2jpYsSHsiMiCjRGg==} engines: {node: '>=12.22.0'} peerDependencies: vue: '>=3.2.0' @@ -5489,8 +5467,8 @@ packages: - supports-color dev: true - /eslint-plugin-vue@9.20.1(eslint@8.56.0): - resolution: {integrity: sha512-GyCs8K3lkEvoyC1VV97GJhP1SvqsKCiWGHnbn0gVUYiUhaH2+nB+Dv1uekv1THFMPbBfYxukrzQdltw950k+LQ==} + /eslint-plugin-vue@9.21.0(eslint@8.56.0): + resolution: {integrity: sha512-B3NgZRtbi9kSl7M0x/PqhSMk7ULJUwWxQpTvM8b2Z6gNTORK0YSt5v1vzwY84oMs/2+3BWH5XmTepaQebcJwfA==} engines: {node: ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.2.0 || ^7.0.0 || ^8.0.0 @@ -7096,11 +7074,6 @@ packages: resolution: {integrity: sha512-pZe//GGmwJndub7ZghVHz7vjb2LgC1m8B07Au3eYqeqv9emhESByMXxaEgkUkEqJe87oBbSniGYoQNIBklc7IQ==} dev: true - /js-levenshtein@1.1.6: - resolution: {integrity: sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==} - engines: {node: '>=0.10.0'} - dev: false - /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -7945,41 +7918,6 @@ packages: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: true - /msw@2.1.3(typescript@5.3.3): - resolution: {integrity: sha512-ZYOpBIxwnGkYKeGqkk9tI87OgOqYXeRpk5ZBTxJILOTyglVwzSde7E2TOoUlma4Kwu2cwgBEGlZnz0RbZPJuoA==} - engines: {node: '>=18'} - hasBin: true - requiresBuild: true - peerDependencies: - typescript: '>= 4.7.x <= 5.3.x' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@bundled-es-modules/cookie': 2.0.0 - '@bundled-es-modules/js-levenshtein': 2.0.1 - '@bundled-es-modules/statuses': 1.0.1 - '@mswjs/cookies': 1.1.0 - '@mswjs/interceptors': 0.25.14 - '@open-draft/until': 2.1.0 - '@types/cookie': 0.6.0 - '@types/js-levenshtein': 1.1.3 - '@types/statuses': 2.0.4 - chalk: 4.1.2 - chokidar: 3.5.3 - graphql: 16.8.1 - headers-polyfill: 4.0.2 - inquirer: 8.2.6 - is-node-process: 1.2.0 - js-levenshtein: 1.1.6 - outvariant: 1.4.2 - path-to-regexp: 6.2.1 - strict-event-emitter: 0.5.1 - type-fest: 4.9.0 - typescript: 5.3.3 - yargs: 17.7.2 - dev: false - /msw@2.1.5(typescript@5.3.3): resolution: {integrity: sha512-r39AZk4taMmUEYwtzDAgFy38feqJy1yaKykvo0QE8q7H7c28yH/WIlOmE7oatjkC3dMgpTYfND8MaxeywgU+Yg==} engines: {node: '>=18'} @@ -11475,14 +11413,14 @@ packages: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} dev: true - file:packages/mock-server(msw@2.1.5): - resolution: {directory: packages/mock-server, type: directory} - id: file:packages/mock-server - name: '@admin-pkg/mock-server' + file:packages/vite-plugin-msw(msw@2.1.5): + resolution: {directory: packages/vite-plugin-msw, type: directory} + id: file:packages/vite-plugin-msw + name: '@admin-pkg/vite-plugin-msw' peerDependencies: msw: ^2.0.0 dependencies: - '@mswjs/interceptors': 0.25.14 + '@mswjs/interceptors': 0.25.15 headers-polyfill: 4.0.2 msw: 2.1.5(typescript@5.3.3) strict-event-emitter: 0.5.1 diff --git a/src/components/basic/excel/src/ImportExcel.vue b/src/components/basic/excel/src/ImportExcel.vue index 3163242fb..5a085591a 100644 --- a/src/components/basic/excel/src/ImportExcel.vue +++ b/src/components/basic/excel/src/ImportExcel.vue @@ -103,26 +103,27 @@ */ function readerData(rawFile: File) { loadingRef.value = true; - return new Promise((resolve, reject) => { - const reader = new FileReader(); - reader.onload = async (e) => { - try { - const data = e.target && e.target.result; - const workbook = read(data, { type: 'array', cellDates: true }); - // console.log(workbook); - /* DO SOMETHING WITH workbook HERE */ - const excelData = getExcelData(workbook); - emit('success', excelData); - resolve(''); - } catch (error) { - reject(error); - emit('error'); - } finally { - loadingRef.value = false; - } - }; - reader.readAsArrayBuffer(rawFile); - }); + const { promise, resolve, reject } = Promise.withResolvers(); + const reader = new FileReader(); + + reader.onload = async (e) => { + try { + const data = e.target && e.target.result; + const workbook = read(data, { type: 'array', cellDates: true }); + // console.log(workbook); + /* DO SOMETHING WITH workbook HERE */ + const excelData = getExcelData(workbook); + emit('success', excelData); + resolve(''); + } catch (error) { + reject(error); + emit('error'); + } finally { + loadingRef.value = false; + } + }; + reader.readAsArrayBuffer(rawFile); + return promise; } async function upload(rawFile: File) { diff --git a/src/components/core/dynamic-table/src/components/editable-cell/index.vue b/src/components/core/dynamic-table/src/components/editable-cell/index.vue index 3324296f1..68485121c 100644 --- a/src/components/core/dynamic-table/src/components/editable-cell/index.vue +++ b/src/components/core/dynamic-table/src/components/editable-cell/index.vue @@ -1,13 +1,13 @@ -