Commit 5b376bbf by 王立鹏

Merge branch '优化/打包优化' into 'master'

优化/打包优化

See merge request !24
parents a1251cdc 5b1e8736
...@@ -4,8 +4,8 @@ import { useUserStore } from '@/stores' ...@@ -4,8 +4,8 @@ import { useUserStore } from '@/stores'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import type { UploadFileResponseItem, ChunkCheckResponse } from './types' import type { UploadFileResponseItem, ChunkCheckResponse } from './types'
// 'https://oa.yswg.com.cn:8085'
const OA_UPLOAD_CHUNK_BASE_URL = 'https://oa.yswg.com.cn:8085' const OA_UPLOAD_CHUNK_BASE_URL = 'http://nas1.yswg.top:8088'
const OA_UPLOAD_COMMON_BASE_URL = 'http://47.112.96.71:8082' const OA_UPLOAD_COMMON_BASE_URL = 'http://47.112.96.71:8082'
const CHUNK_UPLOAD_THRESHOLD = 10 * 1024 * 1024 const CHUNK_UPLOAD_THRESHOLD = 10 * 1024 * 1024
const CHUNK_SIZE = 5 * 1024 * 1024 const CHUNK_SIZE = 5 * 1024 * 1024
......
import * as XLSX from 'xlsx'
import { push } from 'notivue' import { push } from 'notivue'
/** /**
* 导出 Excel * 导出 Excel
...@@ -21,13 +20,15 @@ export interface ExportOptions<T> { ...@@ -21,13 +20,15 @@ export interface ExportOptions<T> {
sheetName?: string sheetName?: string
} }
export function exportExcel<T>({ export async function exportExcel<T>({
data, data,
columns, columns,
fileName = '导出数据', fileName = '导出数据',
sheetName = 'Sheet1', sheetName = 'Sheet1',
}: ExportOptions<T>) { }: ExportOptions<T>) {
if (!data || !data.length) return push.warning('没有可导出的数据') if (!data || !data.length) return push.warning('没有可导出的数据')
// 文件比较大 切非首屏加载 可以选择动态引入 避免首屏加载过慢
const XLSX = await import('xlsx')
const header = columns.map((col) => col.title) const header = columns.map((col) => col.title)
......
import CryptoJS from 'crypto-js'
/**
* 使用 MD5 加密字符串
* @param input - 要加密的字符串
* @returns 加密后的 MD5 字符串
*/
export function md5Hash(input: string): string {
return CryptoJS.MD5(input).toString()
}
/**
* AES 加密方法
* @param plaintext 要加密的明文
* @param key 密钥 (16, 24 或 32 字节长度的字符串)
* @returns 加密后的字符串
*/
export function aesEncrypt(plaintext: string, key: string): string {
if (![16, 24, 32].includes(key.length)) {
throw new Error('秘钥长度必须为 16, 24 或 32 字节。')
}
// 加密数据
const encrypted = CryptoJS.AES.encrypt(plaintext, CryptoJS.enc.Utf8.parse(key), {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7,
})
return encrypted.toString()
}
...@@ -82,7 +82,8 @@ export default defineConfig(({ mode }) => { ...@@ -82,7 +82,8 @@ export default defineConfig(({ mode }) => {
// }, // },
}, },
build: { build: {
minify: true, // 'esbuild' minify: true,
// minify: false,
chunkSizeWarningLimit: 1000, chunkSizeWarningLimit: 1000,
rollupOptions: { rollupOptions: {
output: { output: {
...@@ -90,9 +91,12 @@ export default defineConfig(({ mode }) => { ...@@ -90,9 +91,12 @@ export default defineConfig(({ mode }) => {
chunkFileNames: 'assets/js/[name]-[hash].js', chunkFileNames: 'assets/js/[name]-[hash].js',
codeSplitting: { codeSplitting: {
groups: [ groups: [
{ name: 'elementPlus-vendor', test: /node_modules[\\/]element-plus/, priority: 9 },
{ name: 'vue-vendor', test: /node_modules[\\/]vue/, priority: 10 }, { name: 'vue-vendor', test: /node_modules[\\/]vue/, priority: 10 },
{ name: 'elementPlus-vendor', test: /node_modules[\\/]element-plus/, priority: 9 },
{ name: 'wangeditor-vendor', test: /node_modules[\\/]@wangeditor/, priority: 8 }, { name: 'wangeditor-vendor', test: /node_modules[\\/]@wangeditor/, priority: 8 },
{ name: 'xlsx-vendor', test: /node_modules[\\/]xlsx/, priority: 7 },
{ name: 'crypto-js-vendor', test: /node_modules[\\/]crypto-js/, priority: 6 },
{ name: 'vue-use-vendor', test: /node_modules[\\/]@vueuse/, priority: 5 },
{ {
name: 'common', name: 'common',
minShareCount: 2, minShareCount: 2,
......
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 to comment