This commit is contained in:
dap 2024-09-12 07:47:12 +08:00
commit e1a1a23923
22 changed files with 697 additions and 244 deletions

View File

@ -20,7 +20,13 @@ permissions:
jobs: jobs:
post-update: post-update:
# if: ${{ github.actor == 'dependabot[bot]' }} # if: ${{ github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
- windows-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4

View File

@ -32,9 +32,13 @@
body, body,
html { html {
@apply size-full overscroll-none; @apply size-full overscroll-none;
/* scrollbar-gutter: stable; */
} }
body { body {
@apply !pointer-events-auto;
min-height: 100vh; min-height: 100vh;
/* overflow: overlay; */ /* overflow: overlay; */
@ -90,6 +94,7 @@
} }
/* 只有非mac下才进行调整mac下使用默认滚动条 */ /* 只有非mac下才进行调整mac下使用默认滚动条 */
html:not([data-platform='macOs']) { html:not([data-platform='macOs']) {
::-webkit-scrollbar { ::-webkit-scrollbar {
@apply h-[10px] w-[10px]; @apply h-[10px] w-[10px];

View File

@ -71,6 +71,7 @@
"dependencies": { "dependencies": {
"@ctrl/tinycolor": "^4.1.0", "@ctrl/tinycolor": "^4.1.0",
"@tanstack/vue-store": "^0.5.5", "@tanstack/vue-store": "^0.5.5",
"@vue/reactivity": "^3.5.4",
"@vue/shared": "^3.5.4", "@vue/shared": "^3.5.4",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"defu": "^6.1.4", "defu": "^6.1.4",

View File

@ -5,6 +5,7 @@ export * from './inference';
export * from './letter'; export * from './letter';
export * from './merge'; export * from './merge';
export * from './nprogress'; export * from './nprogress';
export * from './reactivity';
export * from './state-handler'; export * from './state-handler';
export * from './to'; export * from './to';
export * from './tree'; export * from './tree';

View File

@ -0,0 +1,26 @@
import { isProxy, isReactive, isRef, toRaw } from '@vue/reactivity';
function deepToRaw<T extends Record<string, any>>(sourceObj: T): T {
const objectIterator = (input: any): any => {
if (Array.isArray(input)) {
return input.map((item) => objectIterator(item));
}
if (isRef(input) || isReactive(input) || isProxy(input)) {
return objectIterator(toRaw(input));
}
if (input && typeof input === 'object') {
const result = {} as T;
for (const key in input) {
if (Object.prototype.hasOwnProperty.call(input, key)) {
result[key as keyof T] = objectIterator(input[key]);
}
}
return result;
}
return input;
};
return objectIterator(sourceObj);
}
export { deepToRaw };

View File

@ -41,6 +41,7 @@ export class ModalApi {
isOpen: false, isOpen: false,
loading: false, loading: false,
modal: true, modal: true,
openAutoFocus: false,
showCancelButton: true, showCancelButton: true,
showConfirmButton: true, showConfirmButton: true,
title: '', title: '',

View File

@ -75,6 +75,10 @@ export interface ModalProps {
* @default true * @default true
*/ */
modal?: boolean; modal?: boolean;
/**
*
*/
openAutoFocus?: boolean;
/** /**
* *
* @default true * @default true

View File

@ -68,6 +68,7 @@ const {
header, header,
loading: showLoading, loading: showLoading,
modal, modal,
openAutoFocus,
showCancelButton, showCancelButton,
showConfirmButton, showConfirmButton,
title, title,
@ -133,6 +134,13 @@ function escapeKeyDown(e: KeyboardEvent) {
e.preventDefault(); e.preventDefault();
} }
} }
function handerOpenAutoFocus(e: Event) {
if (!openAutoFocus.value) {
e?.preventDefault();
}
}
// pointer-down-outside // pointer-down-outside
function pointerDownOutside(e: Event) { function pointerDownOutside(e: Event) {
const target = e.target as HTMLElement; const target = e.target as HTMLElement;
@ -166,6 +174,7 @@ function pointerDownOutside(e: Event) {
close-class="top-3" close-class="top-3"
@escape-key-down="escapeKeyDown" @escape-key-down="escapeKeyDown"
@interact-outside="interactOutside" @interact-outside="interactOutside"
@open-auto-focus="handerOpenAutoFocus"
@pointer-down-outside="pointerDownOutside" @pointer-down-outside="pointerDownOutside"
> >
<DialogHeader <DialogHeader

View File

@ -40,6 +40,7 @@
"@vben-core/composables": "workspace:*", "@vben-core/composables": "workspace:*",
"@vben-core/icons": "workspace:*", "@vben-core/icons": "workspace:*",
"@vben-core/shadcn-ui": "workspace:*", "@vben-core/shadcn-ui": "workspace:*",
"@vben-core/shared": "workspace:*",
"@vben-core/typings": "workspace:*", "@vben-core/typings": "workspace:*",
"@vueuse/core": "^11.0.3", "@vueuse/core": "^11.0.3",
"vue": "^3.5.4" "vue": "^3.5.4"

View File

@ -7,6 +7,7 @@ import { computed, ref } from 'vue';
import { Pin, X } from '@vben-core/icons'; import { Pin, X } from '@vben-core/icons';
import { VbenContextMenu, VbenIcon } from '@vben-core/shadcn-ui'; import { VbenContextMenu, VbenIcon } from '@vben-core/shadcn-ui';
import { deepToRaw } from '@vben-core/shared/utils';
interface Props extends TabsProps {} interface Props extends TabsProps {}
@ -40,7 +41,8 @@ const style = computed(() => {
}); });
const tabsView = computed((): TabConfig[] => { const tabsView = computed((): TabConfig[] => {
return props.tabs.map((tab) => { return props.tabs.map((_tab) => {
const tab = deepToRaw(_tab);
return { return {
...tab, ...tab,
affixTab: !!tab.meta?.affixTab, affixTab: !!tab.meta?.affixTab,

View File

@ -7,6 +7,7 @@ import { computed } from 'vue';
import { Pin, X } from '@vben-core/icons'; import { Pin, X } from '@vben-core/icons';
import { VbenContextMenu, VbenIcon } from '@vben-core/shadcn-ui'; import { VbenContextMenu, VbenIcon } from '@vben-core/shadcn-ui';
import { deepToRaw } from '@vben-core/shared/utils';
interface Props extends TabsProps {} interface Props extends TabsProps {}
@ -46,7 +47,8 @@ const typeWithClass = computed(() => {
}); });
const tabsView = computed((): TabConfig[] => { const tabsView = computed((): TabConfig[] => {
return props.tabs.map((tab) => { return props.tabs.map((_tab) => {
const tab = deepToRaw(_tab);
return { return {
...tab, ...tab,
affixTab: !!tab.meta?.affixTab, affixTab: !!tab.meta?.affixTab,

View File

@ -22,6 +22,18 @@ interface Props {
* @zh_CN 登陆路径 * @zh_CN 登陆路径
*/ */
loginPath?: string; loginPath?: string;
/**
* @zh_CN 标题
*/
title?: string;
/**
* @zh_CN 描述
*/
subTitle?: string;
/**
* @zh_CN 按钮文本
*/
submitButtonText?: string;
} }
defineOptions({ defineOptions({
@ -31,6 +43,9 @@ defineOptions({
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
loading: false, loading: false,
loginPath: '/auth/login', loginPath: '/auth/login',
submitButtonText: '',
subTitle: '',
title: '',
}); });
const emit = defineEmits<{ const emit = defineEmits<{
@ -69,16 +84,22 @@ function goToLogin() {
<template> <template>
<div> <div>
<Title> <Title>
{{ $t('authentication.welcomeBack') }} 📲 <slot name="title">
{{ title || $t('authentication.welcomeBack') }} 📲
</slot>
<template #desc> <template #desc>
<span class="text-muted-foreground"> <span class="text-muted-foreground">
{{ $t('authentication.codeSubtitle') }} <slot name="subTitle">
{{ subTitle || $t('authentication.codeSubtitle') }}
</slot>
</span> </span>
</template> </template>
</Title> </Title>
<Form /> <Form />
<VbenButton :loading="loading" class="w-full" @click="handleSubmit"> <VbenButton :loading="loading" class="w-full" @click="handleSubmit">
{{ $t('common.login') }} <slot name="submitButtonText">
{{ submitButtonText || $t('common.login') }}
</slot>
</VbenButton> </VbenButton>
<VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()"> <VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()">
{{ $t('common.back') }} {{ $t('common.back') }}

View File

@ -11,6 +11,7 @@ import { VbenButton } from '@vben-core/shadcn-ui';
import Title from './auth-title.vue'; import Title from './auth-title.vue';
interface Props { interface Props {
formSchema: VbenFormSchema[];
/** /**
* @zh_CN 是否处于加载处理状态 * @zh_CN 是否处于加载处理状态
*/ */
@ -19,8 +20,18 @@ interface Props {
* @zh_CN 登陆路径 * @zh_CN 登陆路径
*/ */
loginPath?: string; loginPath?: string;
/**
formSchema: VbenFormSchema[]; * @zh_CN 标题
*/
title?: string;
/**
* @zh_CN 描述
*/
subTitle?: string;
/**
* @zh_CN 按钮文本
*/
submitButtonText?: string;
} }
defineOptions({ defineOptions({
@ -30,6 +41,9 @@ defineOptions({
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
loading: false, loading: false,
loginPath: '/auth/login', loginPath: '/auth/login',
submitButtonText: '',
subTitle: '',
title: '',
}); });
const emit = defineEmits<{ const emit = defineEmits<{
@ -65,16 +79,22 @@ function goToLogin() {
<template> <template>
<div> <div>
<Title> <Title>
{{ $t('authentication.forgetPassword') }} 🤦🏻 <slot name="title">
{{ title || $t('authentication.forgetPassword') }} 🤦🏻
</slot>
<template #desc> <template #desc>
{{ $t('authentication.forgetPasswordSubtitle') }} <slot name="subTitle">
{{ subTitle || $t('authentication.forgetPasswordSubtitle') }}
</slot>
</template> </template>
</Title> </Title>
<Form /> <Form />
<div> <div>
<VbenButton class="mt-2 w-full" @click="handleSubmit"> <VbenButton class="mt-2 w-full" @click="handleSubmit">
{{ $t('authentication.sendResetLink') }} <slot name="submitButtonText">
{{ submitButtonText || $t('authentication.sendResetLink') }}
</slot>
</VbenButton> </VbenButton>
<VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()"> <VbenButton class="mt-4 w-full" variant="outline" @click="goToLogin()">
{{ $t('common.back') }} {{ $t('common.back') }}

View File

@ -38,6 +38,7 @@ const props = withDefaults(defineProps<Props>(), {
showRegister: true, showRegister: true,
showRememberMe: true, showRememberMe: true,
showThirdPartyLogin: true, showThirdPartyLogin: true,
submitButtonText: '',
subTitle: '', subTitle: '',
title: '', title: '',
}); });
@ -94,10 +95,14 @@ defineExpose({ setFieldValue });
<div @keydown.enter.prevent="handleSubmit"> <div @keydown.enter.prevent="handleSubmit">
<slot name="title"> <slot name="title">
<Title> <Title>
<slot name="title">
{{ title || `${$t('authentication.welcomeBack')} 👋🏻` }} {{ title || `${$t('authentication.welcomeBack')} 👋🏻` }}
</slot>
<template #desc> <template #desc>
<span class="text-muted-foreground"> <span class="text-muted-foreground">
<slot name="subTitle">
{{ subTitle || $t('authentication.loginSubtitle') }} {{ subTitle || $t('authentication.loginSubtitle') }}
</slot>
</span> </span>
</template> </template>
</Title> </Title>
@ -109,8 +114,12 @@ defineExpose({ setFieldValue });
v-if="showRememberMe || showForgetPassword" v-if="showRememberMe || showForgetPassword"
class="mb-6 flex justify-between" class="mb-6 flex justify-between"
> >
<div v-if="showRememberMe" class="flex-center"> <div class="flex-center">
<VbenCheckbox v-model:checked="rememberMe" name="rememberMe"> <VbenCheckbox
v-if="showRememberMe"
v-model:checked="rememberMe"
name="rememberMe"
>
{{ $t('authentication.rememberMe') }} {{ $t('authentication.rememberMe') }}
</VbenCheckbox> </VbenCheckbox>
</div> </div>
@ -124,7 +133,7 @@ defineExpose({ setFieldValue });
</span> </span>
</div> </div>
<VbenButton :loading="loading" class="w-full" @click="handleSubmit"> <VbenButton :loading="loading" class="w-full" @click="handleSubmit">
{{ $t('common.login') }} {{ submitButtonText || $t('common.login') }}
</VbenButton> </VbenButton>
<div <div

View File

@ -18,6 +18,22 @@ interface Props {
* @zh_CN 登陆路径 * @zh_CN 登陆路径
*/ */
loginPath?: string; loginPath?: string;
/**
* @zh_CN 标题
*/
title?: string;
/**
* @zh_CN 描述
*/
subTitle?: string;
/**
* @zh_CN 按钮文本
*/
submitButtonText?: string;
/**
* @zh_CN 描述
*/
description?: string;
} }
defineOptions({ defineOptions({
@ -25,8 +41,12 @@ defineOptions({
}); });
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
description: '',
loading: false, loading: false,
loginPath: '/auth/login', loginPath: '/auth/login',
submitButtonText: '',
subTitle: '',
title: '',
}); });
const router = useRouter(); const router = useRouter();
@ -46,10 +66,14 @@ function goToLogin() {
<template> <template>
<div> <div>
<Title> <Title>
{{ $t('authentication.welcomeBack') }} 📱 <slot name="title">
{{ title || $t('authentication.welcomeBack') }} 📱
</slot>
<template #desc> <template #desc>
<span class="text-muted-foreground"> <span class="text-muted-foreground">
{{ $t('authentication.qrcodeSubtitle') }} <slot name="subTitle">
{{ subTitle || $t('authentication.qrcodeSubtitle') }}
</slot>
</span> </span>
</template> </template>
</Title> </Title>
@ -57,7 +81,9 @@ function goToLogin() {
<div class="flex-col-center mt-6"> <div class="flex-col-center mt-6">
<img :src="qrcode" alt="qrcode" class="w-1/2" /> <img :src="qrcode" alt="qrcode" class="w-1/2" />
<p class="text-muted-foreground mt-4 text-sm"> <p class="text-muted-foreground mt-4 text-sm">
{{ $t('authentication.qrcodePrompt') }} <slot name="description">
{{ description || $t('authentication.qrcodePrompt') }}
</slot>
</p> </p>
</div> </div>

View File

@ -22,6 +22,18 @@ interface Props {
* @zh_CN 登陆路径 * @zh_CN 登陆路径
*/ */
loginPath?: string; loginPath?: string;
/**
* @zh_CN 标题
*/
title?: string;
/**
* @zh_CN 描述
*/
subTitle?: string;
/**
* @zh_CN 按钮文本
*/
submitButtonText?: string;
} }
defineOptions({ defineOptions({
@ -32,6 +44,9 @@ const props = withDefaults(defineProps<Props>(), {
formSchema: () => [], formSchema: () => [],
loading: false, loading: false,
loginPath: '/auth/login', loginPath: '/auth/login',
submitButtonText: '',
subTitle: '',
title: '',
}); });
const emit = defineEmits<{ const emit = defineEmits<{
@ -66,13 +81,21 @@ function goToLogin() {
<template> <template>
<div> <div>
<Title> <Title>
{{ $t('authentication.createAnAccount') }} 🚀 <slot name="title">
<template #desc> {{ $t('authentication.signUpSubtitle') }} </template> {{ title || $t('authentication.createAnAccount') }} 🚀
</slot>
<template #desc>
<slot name="subTitle">
{{ subTitle || $t('authentication.signUpSubtitle') }}
</slot>
</template>
</Title> </Title>
<Form /> <Form />
<VbenButton :loading="loading" class="mt-2 w-full" @click="handleSubmit"> <VbenButton :loading="loading" class="mt-2 w-full" @click="handleSubmit">
{{ $t('authentication.signUp') }} <slot name="submitButtonText">
{{ submitButtonText || $t('authentication.signUp') }}
</slot>
</VbenButton> </VbenButton>
<div class="mt-4 text-center text-sm"> <div class="mt-4 text-center text-sm">
{{ $t('authentication.alreadyHaveAccount') }} {{ $t('authentication.alreadyHaveAccount') }}

View File

@ -63,6 +63,10 @@ interface AuthenticationProps {
* @zh_CN * @zh_CN
*/ */
title?: string; title?: string;
/**
* @zh_CN
*/
submitButtonText?: string;
} }
/** /**

View File

@ -31,9 +31,9 @@ const showTheme = computed(() => props.toolbarList.includes('theme'));
<template> <template>
<div <div
:class="{ :class="{
'bg-accent z-10 rounded-3xl px-3 py-1': toolbarList.length > 1, 'bg-accent rounded-3xl px-3 py-1': toolbarList.length > 1,
}" }"
class="flex-center absolute right-2 top-4" class="flex-center absolute right-2 top-4 z-10"
> >
<!-- Only show on medium and larger screens --> <!-- Only show on medium and larger screens -->
<div class="hidden md:flex"> <div class="hidden md:flex">

View File

@ -11,7 +11,7 @@ import {
usePreferences, usePreferences,
} from '@vben/preferences'; } from '@vben/preferences';
import { useLockStore, useUserStore } from '@vben/stores'; import { useLockStore, useUserStore } from '@vben/stores';
import { mapTree } from '@vben/utils'; import { deepToRaw, mapTree } from '@vben/utils';
import { VbenAdminLayout } from '@vben-core/layout-ui'; import { VbenAdminLayout } from '@vben-core/layout-ui';
import { Toaster, VbenBackTop, VbenLogo } from '@vben-core/shadcn-ui'; import { Toaster, VbenBackTop, VbenLogo } from '@vben-core/shadcn-ui';
@ -113,7 +113,7 @@ const {
function wrapperMenus(menus: MenuRecordRaw[]) { function wrapperMenus(menus: MenuRecordRaw[]) {
return mapTree(menus, (item) => { return mapTree(menus, (item) => {
return { ...item, name: $t(item.name) }; return { ...deepToRaw(item), name: $t(item.name) };
}); });
} }

View File

@ -5,7 +5,7 @@ import type { MenuProps } from '@vben-core/menu-ui';
import { Menu } from '@vben-core/menu-ui'; import { Menu } from '@vben-core/menu-ui';
interface Props extends MenuProps { interface Props extends MenuProps {
menus?: MenuRecordRaw[]; menus: MenuRecordRaw[];
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {

View File

@ -27,6 +27,19 @@ const [Form, formApi] = useVbenForm({
label: '字段2', label: '字段2',
rules: 'required', rules: 'required',
}, },
{
component: 'Select',
componentProps: {
options: [
{ label: '选项1', value: '1' },
{ label: '选项2', value: '2' },
],
placeholder: '请输入',
},
fieldName: 'field3',
label: '字段3',
rules: 'required',
},
], ],
showDefaultActions: false, showDefaultActions: false,
}); });

File diff suppressed because it is too large Load Diff