This commit is contained in:
dap
2024-11-25 11:29:58 +08:00
53 changed files with 170 additions and 271 deletions

View File

@@ -1,8 +1,18 @@
# 1.1.2 # 1.1.2
**Features**
- Options转Enum工具函数
**OTHERS** **OTHERS**
- 菜单管理 改为虚拟滚动 - 菜单管理 改为虚拟滚动
- 移除requestClient的一些冗余参数
- 主动退出登录(右上角个人选项)不需要带跳转地址
**BUG FIXES**
- 语言 漏加Content-Language请求头
# 1.1.1 # 1.1.1

View File

@@ -1,75 +1,5 @@
import { isObject, isString } from '@vben/utils';
import { requestClient } from './request'; import { requestClient } from './request';
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export function joinTimestamp<T extends boolean>(
join: boolean,
restful: T,
): T extends true ? string : object;
export function joinTimestamp(join: boolean, restful = false): object | string {
if (!join) {
return restful ? '' : {};
}
const now = Date.now();
if (restful) {
return `?_t=${now}`;
}
return { _t: now };
}
/**
* @description: Format request parameter time
*/
export function formatRequestDate(params: Record<string, any>) {
if (Object.prototype.toString.call(params) !== '[object Object]') {
return;
}
for (const key in params) {
const format = params[key]?.format ?? null;
if (format && typeof format === 'function') {
params[key] = params[key].format(DATE_TIME_FORMAT);
}
if (isString(key)) {
const value = params[key];
if (value) {
try {
params[key] = isString(value) ? value.trim() : value;
} catch (error: any) {
throw new Error(error);
}
}
}
if (isObject(params[key])) {
formatRequestDate(params[key]);
}
}
}
/**
* Add the object as a parameter to the URL
* @param baseUrl url
* @param obj
* @returns {string}
* eg:
* let obj = {a: '3', b: '4'}
* setObjToUrlParams('www.baidu.com', obj)
* ==>www.baidu.com?a=3&b=4
*/
export function setObjToUrlParams(baseUrl: string, obj: any): string {
let parameters = '';
for (const key in obj) {
parameters += `${key}=${encodeURIComponent(obj[key])}&`;
}
parameters = parameters.replace(/&$/, '');
return /\?$/.test(baseUrl)
? baseUrl + parameters
: baseUrl.replace(/\/?$/, '?') + parameters;
}
/** /**
* @description: contentType * @description: contentType
*/ */

View File

@@ -12,7 +12,6 @@ import {
RequestClient, RequestClient,
} from '@vben/request'; } from '@vben/request';
import { useAccessStore } from '@vben/stores'; import { useAccessStore } from '@vben/stores';
import { isString } from '@vben/utils';
import { message, Modal } from 'ant-design-vue'; import { message, Modal } from 'ant-design-vue';
import { isEmpty, isNull } from 'lodash-es'; import { isEmpty, isNull } from 'lodash-es';
@@ -27,8 +26,6 @@ import {
} from '#/utils/encryption/crypto'; } from '#/utils/encryption/crypto';
import * as encryptUtil from '#/utils/encryption/jsencrypt'; import * as encryptUtil from '#/utils/encryption/jsencrypt';
import { formatRequestDate, joinTimestamp, setObjToUrlParams } from './helper';
const { apiURL, clientId, enableEncrypt } = useAppConfig( const { apiURL, clientId, enableEncrypt } = useAppConfig(
import.meta.env, import.meta.env,
import.meta.env.PROD, import.meta.env.PROD,
@@ -46,16 +43,10 @@ function createRequestClient(baseURL: string) {
baseURL, baseURL,
// 消息提示类型 // 消息提示类型
errorMessageMode: 'message', errorMessageMode: 'message',
// 格式化提交参数时间
formatDate: true,
// 是否返回原生响应 比如:需要获取响应头时使用该属性 // 是否返回原生响应 比如:需要获取响应头时使用该属性
isReturnNativeResponse: false, isReturnNativeResponse: false,
// 需要对返回数据进行处理 // 需要对返回数据进行处理
isTransformResponse: true, isTransformResponse: true,
// post请求的时候添加参数到url
joinParamsToUrl: false,
// 是否加入时间戳
joinTime: false,
}); });
/** /**
@@ -99,54 +90,11 @@ function createRequestClient(baseURL: string) {
*/ */
const language = preferences.app.locale.replace('-', '_'); const language = preferences.app.locale.replace('-', '_');
config.headers['Accept-Language'] = language; config.headers['Accept-Language'] = language;
config.headers['Content-Language'] = language;
// 添加全局clientId // 添加全局clientId
config.headers.clientId = clientId; config.headers.clientId = clientId;
const { encrypt, formatDate, joinParamsToUrl, joinTime = true } = config; const { encrypt } = config;
const params = config.params || {};
const data = config.data || false;
// TODO: 这块要重构 复杂度太高了
formatDate && data && !isString(data) && formatRequestDate(data);
if (config.method?.toUpperCase() === 'GET') {
if (isString(params)) {
// 兼容restful风格
config.url = `${config.url + params}${joinTimestamp(joinTime, true)}`;
config.params = undefined;
} else {
// 给 get 请求加上时间戳参数,避免从缓存中拿数据。
config.params = Object.assign(
params || {},
joinTimestamp(joinTime, false),
);
}
} else {
if (isString(params)) {
// 兼容restful风格
config.url = config.url + params;
config.params = undefined;
} else {
formatDate && formatRequestDate(params);
if (
Reflect.has(config, 'data') &&
config.data &&
(Object.keys(config.data).length > 0 ||
config.data instanceof FormData)
) {
config.data = data;
config.params = params;
} else {
// 非GET请求如果没有提供data则将params视为data
config.data = params;
config.params = undefined;
}
if (joinParamsToUrl) {
config.url = setObjToUrlParams(
config.url as string,
Object.assign({}, config.params, config.data),
);
}
}
}
// 全局开启请求加密功能 && 该请求开启 && 是post/put请求 // 全局开启请求加密功能 && 该请求开启 && 是post/put请求
if ( if (
enableEncrypt && enableEncrypt &&

View File

@@ -48,14 +48,6 @@ function handleChange(info: Record<string, any>) {
const name = file?.name; const name = file?.name;
switch (status) { switch (status) {
case 'uploading': {
if (!uploading) {
emit('uploading', name);
uploading = true;
}
break;
}
case 'done': { case 'done': {
// http 200会走到这里 需要再次判断 // http 200会走到这里 需要再次判断
const { response } = file; const { response } = file;
@@ -77,6 +69,14 @@ function handleChange(info: Record<string, any>) {
break; break;
} }
case 'uploading': {
if (!uploading) {
emit('uploading', name);
uploading = true;
}
break;
}
// No default // No default
} }
} }

View File

@@ -88,7 +88,10 @@ const avatar = computed(() => {
}); });
async function handleLogout() { async function handleLogout() {
await authStore.logout(); /**
* 主动登出不需要带跳转地址
*/
await authStore.logout(false);
resetRoutes(); resetRoutes();
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/web-ele", "name": "@vben/web-ele",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://vben.pro", "homepage": "https://vben.pro",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -15,6 +15,7 @@ import {
ElButton, ElButton,
ElCheckbox, ElCheckbox,
ElCheckboxGroup, ElCheckboxGroup,
ElDatePicker,
ElDivider, ElDivider,
ElInput, ElInput,
ElInputNumber, ElInputNumber,
@@ -79,6 +80,7 @@ async function initComponentAdapter() {
Space: ElSpace, Space: ElSpace,
Switch: ElSwitch, Switch: ElSwitch,
TimePicker: ElTimePicker, TimePicker: ElTimePicker,
DatePicker: ElDatePicker,
TreeSelect: withDefaultPlaceholder(ElTreeSelect, 'select'), TreeSelect: withDefaultPlaceholder(ElTreeSelect, 'select'),
Upload: ElUpload, Upload: ElUpload,
}; };

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/web-naive", "name": "@vben/web-naive",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://vben.pro", "homepage": "https://vben.pro",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -124,7 +124,7 @@ function sidebarCommercial(): DefaultTheme.SidebarItem[] {
return [ return [
{ {
link: 'community', link: 'community',
text: '社区', text: '交流群',
}, },
{ {
link: 'technical-support', link: 'technical-support',
@@ -266,7 +266,7 @@ function nav(): DefaultTheme.NavItem[] {
}, },
{ {
link: '/commercial/community', link: '/commercial/community',
text: '👨‍👦‍👦 社区', text: '👨‍👦‍👦 交流群',
// items: [ // items: [
// { // {
// link: 'https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=22ySzj7pKiw&businessType=9&from=246610&biz=ka&mainSourceId=share&subSourceId=others&jumpsource=shorturl#/pc', // link: 'https://qun.qq.com/qqweb/qunpro/share?_wv=3&_wwv=128&appChannel=share&inviteCode=22ySzj7pKiw&businessType=9&from=246610&biz=ka&mainSourceId=share&subSourceId=others&jumpsource=shorturl#/pc',

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/docs", "name": "@vben/docs",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"scripts": { "scripts": {
"build": "vitepress build", "build": "vitepress build",

View File

@@ -20,7 +20,10 @@
::: tip ::: tip
因为微信群人数有限制,加微信群前,你可以通过[赞助](../sponsor/personal.md)任意金额,主动发送截图给作者,备注`加入微信群`即可。 因为微信群人数有限制,加微信群要求:
- 通过[赞助](../sponsor/personal.md)任意金额。
- 发送赞助`截图`,备注`加入微信群`即可。
::: :::

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/commitlint-config", "name": "@vben/commitlint-config",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/stylelint-config", "name": "@vben/stylelint-config",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/node-utils", "name": "@vben/node-utils",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/tailwind-config", "name": "@vben/tailwind-config",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/tsconfig", "name": "@vben/tsconfig",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/vite-config", "name": "@vben/vite-config",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",

View File

@@ -1,6 +1,6 @@
{ {
"name": "vben-admin-monorepo", "name": "vben-admin-monorepo",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"keywords": [ "keywords": [
"monorepo", "monorepo",
@@ -99,7 +99,7 @@
"node": ">=20.10.0", "node": ">=20.10.0",
"pnpm": ">=9.12.0" "pnpm": ">=9.12.0"
}, },
"packageManager": "pnpm@9.13.2", "packageManager": "pnpm@9.14.2",
"pnpm": { "pnpm": {
"peerDependencyRules": { "peerDependencyRules": {
"allowedVersions": { "allowedVersions": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/design", "name": "@vben-core/design",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/icons", "name": "@vben-core/icons",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/shared", "name": "@vben-core/shared",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {
@@ -81,13 +81,11 @@
"dependencies": { "dependencies": {
"@ctrl/tinycolor": "catalog:", "@ctrl/tinycolor": "catalog:",
"@tanstack/vue-store": "catalog:", "@tanstack/vue-store": "catalog:",
"@types/lodash.get": "catalog:",
"@vue/shared": "catalog:", "@vue/shared": "catalog:",
"clsx": "catalog:", "clsx": "catalog:",
"dayjs": "catalog:", "dayjs": "catalog:",
"defu": "catalog:", "defu": "catalog:",
"lodash.clonedeep": "catalog:", "lodash.clonedeep": "catalog:",
"lodash.get": "catalog:",
"nprogress": "catalog:", "nprogress": "catalog:",
"tailwind-merge": "catalog:", "tailwind-merge": "catalog:",
"theme-colors": "catalog:" "theme-colors": "catalog:"

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/typings", "name": "@vben-core/typings",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/composables", "name": "@vben-core/composables",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/preferences", "name": "@vben-core/preferences",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/form-ui", "name": "@vben-core/form-ui",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/layout-ui", "name": "@vben-core/layout-ui",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/menu-ui", "name": "@vben-core/menu-ui",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/shadcn-ui", "name": "@vben-core/shadcn-ui",
"version": "5.4.7", "version": "5.4.8",
"#main": "./dist/index.mjs", "#main": "./dist/index.mjs",
"#module": "./dist/index.mjs", "#module": "./dist/index.mjs",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",

View File

@@ -23,8 +23,8 @@ defineEmits<{ captchaClick: [] }>();
const modelValue = defineModel({ default: '', type: String }); const modelValue = defineModel({ default: '', type: String });
</script> </script>
<template>
<!-- 图片验证码 --> <!-- 图片验证码 -->
<template>
<div class="flex w-full"> <div class="flex w-full">
<div class="flex-1"> <div class="flex-1">
<VbenInput <VbenInput

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben-core/tabs-ui", "name": "@vben-core/tabs-ui",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/constants", "name": "@vben/constants",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/access", "name": "@vben/access",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/common-ui", "name": "@vben/common-ui",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/hooks", "name": "@vben/hooks",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/layouts", "name": "@vben/layouts",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/plugins", "name": "@vben/plugins",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/request", "name": "@vben/request",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -62,10 +62,6 @@ declare module 'axios' {
* 错误弹窗类型 * 错误弹窗类型
*/ */
errorMessageMode?: ErrorMessageMode; errorMessageMode?: ErrorMessageMode;
/**
* 是否格式化日期
*/
formatDate?: boolean;
/** /**
* 是否返回原生axios响应 * 是否返回原生axios响应
*/ */
@@ -74,14 +70,6 @@ declare module 'axios' {
* 是否需要转换响应 即只获取{code, msg, data}中的data * 是否需要转换响应 即只获取{code, msg, data}中的data
*/ */
isTransformResponse?: boolean; isTransformResponse?: boolean;
/**
* param添加到url后
*/
joinParamsToUrl?: boolean;
/**
* 加入时间戳
*/
joinTime?: boolean;
/** /**
* 成功弹窗类型 * 成功弹窗类型
*/ */

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/icons", "name": "@vben/icons",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/locales", "name": "@vben/locales",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/preferences", "name": "@vben/preferences",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/stores", "name": "@vben/stores",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/styles", "name": "@vben/styles",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/types", "name": "@vben/types",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/utils", "name": "@vben/utils",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://github.com/vbenjs/vue-vben-admin", "homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest';
import { optionsToEnum } from '../enum-options';
describe('optionsToEnum Test', () => {
it('should return an enum object', () => {
const genderOptions = [
{ label: '男', value: 1, enumName: 'GENDER_MALE' },
{ label: '女', value: 2, enumName: 'GENDER_FEMALE' },
] as const;
const enumTest = optionsToEnum(genderOptions);
const male = enumTest.GENDER_MALE;
const female = enumTest.GENDER_FEMALE;
expect(male).toBe(1);
expect(female).toBe(2);
});
});

View File

@@ -0,0 +1,47 @@
/**
* @author dap
* @description 枚举选项
*/
/**
* 定义options类型
*/
export interface EnumsOption {
/**
* 枚举名称 建议使用全大写字母_
*/
enumName: string;
/**
* option的标签
*/
label: string;
/**
* option的值
*/
value: boolean | number | string;
}
export type EnumResult<T extends readonly EnumsOption[]> = {
[key in T[number]['enumName']]: Extract<
T[number],
{ enumName: key }
>['value'];
};
/**
* 将options转为枚举
* 注意自定义的options需要加上as const作为常量处理
* 详见: packages\utils\src\helpers\__tests__\enum-options.test.ts
* @param options 枚举选项
* @returns 转枚举
*/
export function optionsToEnum<T extends readonly EnumsOption[]>(
options: T,
): EnumResult<T> {
type K = T[number]['enumName'];
const result = {} as EnumResult<T>;
options.forEach((item) => {
result[item.enumName as K] = item.value;
});
return result;
}

View File

@@ -1,3 +1,4 @@
export * from './enum-options';
export * from './find-menu-by-path'; export * from './find-menu-by-path';
export * from './generate-menus'; export * from './generate-menus';
export * from './generate-routes-backend'; export * from './generate-routes-backend';

View File

@@ -1,54 +1,6 @@
/** /**
* 一些发送请求 需要用到的工具 * 一些发送请求 需要用到的工具
*/ */
import { isObject, isString } from '@vben-core/shared/utils';
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss';
export function joinTimestamp<T extends boolean>(
join: boolean,
restful: T,
): T extends true ? string : object;
export function joinTimestamp(join: boolean, restful = false): object | string {
if (!join) {
return restful ? '' : {};
}
const now = Date.now();
if (restful) {
return `?_t=${now}`;
}
return { _t: now };
}
/**
* @description: Format request parameter time
*/
export function formatRequestDate(params: Record<string, any>) {
if (Object.prototype.toString.call(params) !== '[object Object]') {
return;
}
for (const key in params) {
const format = params[key]?.format ?? null;
if (format && typeof format === 'function') {
params[key] = params[key].format(DATE_TIME_FORMAT);
}
if (isString(key)) {
const value = params[key];
if (value) {
try {
params[key] = isString(value) ? value.trim() : value;
} catch (error: any) {
throw new Error(error);
}
}
}
if (isObject(params[key])) {
formatRequestDate(params[key]);
}
}
}
/** /**
* Add the object as a parameter to the URL * Add the object as a parameter to the URL

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/playground", "name": "@vben/playground",
"version": "5.4.7", "version": "5.4.8",
"homepage": "https://vben.pro", "homepage": "https://vben.pro",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues", "bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": { "repository": {

View File

@@ -15,42 +15,41 @@ packages:
catalog: catalog:
'@ast-grep/napi': ^0.30.0 '@ast-grep/napi': ^0.30.0
'@changesets/changelog-github': ^0.5.0 '@changesets/changelog-github': ^0.5.0
'@changesets/cli': ^2.27.9 '@changesets/cli': ^2.27.10
'@changesets/git': ^3.0.1 '@changesets/git': ^3.0.2
'@clack/prompts': ^0.8.1 '@clack/prompts': ^0.8.2
'@commitlint/cli': ^19.5.0 '@commitlint/cli': ^19.6.0
'@commitlint/config-conventional': ^19.5.0 '@commitlint/config-conventional': ^19.6.0
'@ctrl/tinycolor': ^4.1.0 '@ctrl/tinycolor': ^4.1.0
'@eslint/js': ^9.15.0 '@eslint/js': ^9.15.0
'@faker-js/faker': ^9.2.0 '@faker-js/faker': ^9.2.0
'@iconify/json': ^2.2.273 '@iconify/json': ^2.2.275
'@iconify/tailwind': ^1.1.3 '@iconify/tailwind': ^1.1.3
'@iconify/vue': ^4.1.2 '@iconify/vue': ^4.1.2
'@intlify/core-base': ^10.0.4 '@intlify/core-base': ^10.0.4
'@intlify/unplugin-vue-i18n': ^6.0.0 '@intlify/unplugin-vue-i18n': ^6.0.0
'@jspm/generator': ^2.4.1 '@jspm/generator': ^2.4.1
'@manypkg/get-packages': ^2.2.2 '@manypkg/get-packages': ^2.2.2
'@nolebase/vitepress-plugin-git-changelog': ^2.9.0 '@nolebase/vitepress-plugin-git-changelog': ^2.10.0
'@playwright/test': ^1.48.2 '@playwright/test': ^1.49.0
'@pnpm/workspace.read-manifest': ^2.2.1 '@pnpm/workspace.read-manifest': ^2.2.1
'@stylistic/stylelint-plugin': ^3.1.1 '@stylistic/stylelint-plugin': ^3.1.1
'@tailwindcss/nesting': 0.0.0-insiders.565cd3e '@tailwindcss/nesting': 0.0.0-insiders.565cd3e
'@tailwindcss/typography': ^0.5.15 '@tailwindcss/typography': ^0.5.15
'@tanstack/vue-query': ^5.60.5 '@tanstack/vue-query': ^5.61.3
'@tanstack/vue-store': ^0.5.7 '@tanstack/vue-store': ^0.5.7
'@types/archiver': ^6.0.3 '@types/archiver': ^6.0.3
'@types/eslint': ^9.6.1 '@types/eslint': ^9.6.1
'@types/html-minifier-terser': ^7.0.2 '@types/html-minifier-terser': ^7.0.2
'@types/jsonwebtoken': ^9.0.7 '@types/jsonwebtoken': ^9.0.7
'@types/lodash.clonedeep': ^4.5.9 '@types/lodash.clonedeep': ^4.5.9
'@types/lodash.get': ^4.4.9 '@types/node': ^22.9.3
'@types/node': ^22.9.0
'@types/nprogress': ^0.2.3 '@types/nprogress': ^0.2.3
'@types/postcss-import': ^14.0.3 '@types/postcss-import': ^14.0.3
'@types/qrcode': ^1.5.5 '@types/qrcode': ^1.5.5
'@types/sortablejs': ^1.15.8 '@types/sortablejs': ^1.15.8
'@typescript-eslint/eslint-plugin': ^8.14.0 '@typescript-eslint/eslint-plugin': ^8.15.0
'@typescript-eslint/parser': ^8.14.0 '@typescript-eslint/parser': ^8.15.0
'@vee-validate/zod': ^4.14.7 '@vee-validate/zod': ^4.14.7
'@vite-pwa/vitepress': ^0.5.3 '@vite-pwa/vitepress': ^0.5.3
'@vitejs/plugin-vue': ^5.2.0 '@vitejs/plugin-vue': ^5.2.0
@@ -58,8 +57,8 @@ catalog:
'@vue/reactivity': ^3.5.13 '@vue/reactivity': ^3.5.13
'@vue/shared': ^3.5.13 '@vue/shared': ^3.5.13
'@vue/test-utils': ^2.4.6 '@vue/test-utils': ^2.4.6
'@vueuse/core': ^11.2.0 '@vueuse/core': ^11.3.0
'@vueuse/integrations': ^11.2.0 '@vueuse/integrations': ^11.3.0
ant-design-vue: ^4.2.6 ant-design-vue: ^4.2.6
archiver: ^7.0.1 archiver: ^7.0.1
autoprefixer: ^10.4.20 autoprefixer: ^10.4.20
@@ -85,18 +84,18 @@ catalog:
echarts: ^5.5.1 echarts: ^5.5.1
element-plus: ^2.8.8 element-plus: ^2.8.8
eslint: ^9.15.0 eslint: ^9.15.0
eslint-config-turbo: ^2.3.0 eslint-config-turbo: ^2.3.1
eslint-plugin-command: ^0.2.6 eslint-plugin-command: ^0.2.6
eslint-plugin-eslint-comments: ^3.2.0 eslint-plugin-eslint-comments: ^3.2.0
eslint-plugin-import-x: ^4.4.2 eslint-plugin-import-x: ^4.4.3
eslint-plugin-jsdoc: ^50.5.0 eslint-plugin-jsdoc: ^50.5.0
eslint-plugin-jsonc: ^2.18.1 eslint-plugin-jsonc: ^2.18.2
eslint-plugin-n: ^17.13.2 eslint-plugin-n: ^17.14.0
eslint-plugin-no-only-tests: ^3.3.0 eslint-plugin-no-only-tests: ^3.3.0
eslint-plugin-perfectionist: ^3.9.1 eslint-plugin-perfectionist: ^3.9.1
eslint-plugin-prettier: ^5.2.1 eslint-plugin-prettier: ^5.2.1
eslint-plugin-regexp: ^2.7.0 eslint-plugin-regexp: ^2.7.0
eslint-plugin-unicorn: ^56.0.0 eslint-plugin-unicorn: ^56.0.1
eslint-plugin-unused-imports: ^4.1.4 eslint-plugin-unused-imports: ^4.1.4
eslint-plugin-vitest: ^0.5.4 eslint-plugin-vitest: ^0.5.4
eslint-plugin-vue: ^9.31.0 eslint-plugin-vue: ^9.31.0
@@ -107,13 +106,12 @@ catalog:
h3: ^1.13.0 h3: ^1.13.0
happy-dom: ^15.11.6 happy-dom: ^15.11.6
html-minifier-terser: ^7.2.0 html-minifier-terser: ^7.2.0
husky: ^9.1.6 husky: ^9.1.7
is-ci: ^3.0.1 is-ci: ^3.0.1
jsonc-eslint-parser: ^2.4.0 jsonc-eslint-parser: ^2.4.0
jsonwebtoken: ^9.0.2 jsonwebtoken: ^9.0.2
lint-staged: ^15.2.10 lint-staged: ^15.2.10
lodash.clonedeep: ^4.5.0 lodash.clonedeep: ^4.5.0
lodash.get: ^4.4.2
lucide-vue-next: ^0.460.0 lucide-vue-next: ^0.460.0
medium-zoom: ^1.1.0 medium-zoom: ^1.1.0
naive-ui: ^2.40.1 naive-ui: ^2.40.1
@@ -123,24 +121,24 @@ catalog:
pinia: 2.2.2 pinia: 2.2.2
pinia-plugin-persistedstate: ^4.1.3 pinia-plugin-persistedstate: ^4.1.3
pkg-types: ^1.2.1 pkg-types: ^1.2.1
playwright: ^1.48.2 playwright: ^1.49.0
postcss: ^8.4.49 postcss: ^8.4.49
postcss-antd-fixes: ^0.2.0 postcss-antd-fixes: ^0.2.0
postcss-html: ^1.7.0 postcss-html: ^1.7.0
postcss-import: ^16.1.0 postcss-import: ^16.1.0
postcss-preset-env: ^10.1.0 postcss-preset-env: ^10.1.1
postcss-scss: ^4.0.9 postcss-scss: ^4.0.9
prettier: ^3.3.3 prettier: ^3.3.3
prettier-plugin-tailwindcss: ^0.6.8 prettier-plugin-tailwindcss: ^0.6.9
publint: ^0.2.12 publint: ^0.2.12
qrcode: ^1.5.4 qrcode: ^1.5.4
radix-vue: ^1.9.9 radix-vue: ^1.9.10
resolve.exports: ^2.0.2 resolve.exports: ^2.0.2
rimraf: ^6.0.1 rimraf: ^6.0.1
rollup: ^4.27.2 rollup: ^4.27.4
rollup-plugin-visualizer: ^5.12.0 rollup-plugin-visualizer: ^5.12.0
sass: 1.80.6 sass: 1.80.6
sortablejs: ^1.15.3 sortablejs: ^1.15.4
stylelint: ^16.10.0 stylelint: ^16.10.0
stylelint-config-recess-order: ^5.1.1 stylelint-config-recess-order: ^5.1.1
stylelint-config-recommended: ^14.0.1 stylelint-config-recommended: ^14.0.1
@@ -149,13 +147,13 @@ catalog:
stylelint-config-standard: ^36.0.1 stylelint-config-standard: ^36.0.1
stylelint-order: ^6.0.4 stylelint-order: ^6.0.4
stylelint-prettier: ^5.0.2 stylelint-prettier: ^5.0.2
stylelint-scss: ^6.9.0 stylelint-scss: ^6.10.0
tailwind-merge: ^2.5.4 tailwind-merge: ^2.5.4
tailwindcss: ^3.4.15 tailwindcss: ^3.4.15
tailwindcss-animate: ^1.0.7 tailwindcss-animate: ^1.0.7
theme-colors: ^0.1.0 theme-colors: ^0.1.0
turbo: ^2.3.0 turbo: ^2.3.1
typescript: ^5.6.3 typescript: 5.6.3
unbuild: ^3.0.0-rc.11 unbuild: ^3.0.0-rc.11
unplugin-element-plus: ^0.8.0 unplugin-element-plus: ^0.8.0
vee-validate: ^4.14.7 vee-validate: ^4.14.7
@@ -174,8 +172,8 @@ catalog:
vue-i18n: ^10.0.4 vue-i18n: ^10.0.4
vue-router: ^4.4.5 vue-router: ^4.4.5
vue-tsc: ^2.1.10 vue-tsc: ^2.1.10
vxe-pc-ui: ^4.2.55 vxe-pc-ui: ^4.3.4
vxe-table: ^4.8.14 vxe-table: ^4.9.5
watermark-js-plus: ^1.5.7 watermark-js-plus: ^1.5.7
zod: ^3.23.8 zod: ^3.23.8
zod-defaults: ^0.1.3 zod-defaults: ^0.1.3

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/turbo-run", "name": "@vben/turbo-run",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@vben/vsh", "name": "@vben/vsh",
"version": "5.4.7", "version": "5.4.8",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",