diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 0014f4c51..614b8cf41 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -13,14 +13,14 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: 18 + node-version: 20 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v3 name: Install pnpm id: pnpm-install with: @@ -33,7 +33,7 @@ jobs: run: | echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - uses: actions/cache@v4 name: Setup pnpm cache with: path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} diff --git a/src/components/ReDialog/index.vue b/src/components/ReDialog/index.vue index e7fb2f108..ba9ba1d00 100644 --- a/src/components/ReDialog/index.vue +++ b/src/components/ReDialog/index.vue @@ -37,6 +37,7 @@ const footerButtons = computed(() => { type: "primary", text: true, bg: true, + popconfirm: options?.popconfirm, btnClick: ({ dialog: { options, index } }) => { const done = () => closeDialog(options, index, { command: "sure" }); @@ -149,19 +150,34 @@ function handleClose( - - {{ btn?.label }} - + diff --git a/src/components/ReDialog/type.ts b/src/components/ReDialog/type.ts index 827e8c7df..4cc747688 100644 --- a/src/components/ReDialog/type.ts +++ b/src/components/ReDialog/type.ts @@ -11,6 +11,13 @@ type ArgsType = { /** `cancel` 点击取消按钮、`sure` 点击确定按钮、`close` 点击右上角关闭按钮或空白页或按下了esc键 */ command: "cancel" | "sure" | "close"; }; +type ButtonType = + | "primary" + | "success" + | "warning" + | "danger" + | "info" + | "text"; /** https://element-plus.org/zh-CN/component/dialog.html#attributes */ type DialogProps = { @@ -58,6 +65,34 @@ type DialogProps = { destroyOnClose?: boolean; }; +//element-plus.org/zh-CN/component/popconfirm.html#attributes +type Popconfirm = { + /** 标题 */ + title?: string; + /** 确认按钮文字 */ + confirmButtonText?: string; + /** 取消按钮文字 */ + cancelButtonText?: string; + /** 确认按钮类型,默认 `primary` */ + confirmButtonType?: ButtonType; + /** 取消按钮类型,默认 `text` */ + cancelButtonType?: ButtonType; + /** 自定义图标,默认 `QuestionFilled` */ + icon?: string | Component; + /** `Icon` 颜色,默认 `#f90` */ + iconColor?: string; + /** 是否隐藏 `Icon`,默认 `false` */ + hideIcon?: boolean; + /** 关闭时的延迟,默认 `200` */ + hideAfter?: number; + /** 是否将 `popover` 的下拉列表插入至 `body` 元素,默认 `true` */ + teleported?: boolean; + /** 当 `popover` 组件长时间不触发且 `persistent` 属性设置为 `false` 时, `popover` 将会被删除,默认 `false` */ + persistent?: boolean; + /** 弹层宽度,最小宽度 `150px`,默认 `150` */ + width?: string | number; +}; + type BtnClickDialog = { options?: DialogOptions; index?: number; @@ -86,6 +121,8 @@ type ButtonProps = { round?: boolean; /** 是否为圆形按钮,默认 `false` */ circle?: boolean; + /** 确认按钮的 `Popconfirm` 气泡确认框相关配置 */ + popconfirm?: Popconfirm; /** 是否为加载中状态,默认 `false` */ loading?: boolean; /** 自定义加载中状态图标组件 */ @@ -123,6 +160,8 @@ interface DialogOptions extends DialogProps { props?: any; /** 是否隐藏 `Dialog` 按钮操作区的内容 */ hideFooter?: boolean; + /** 确认按钮的 `Popconfirm` 气泡确认框相关配置 */ + popconfirm?: Popconfirm; /** * @description 自定义对话框标题的内容渲染器 * @see {@link https://element-plus.org/zh-CN/component/dialog.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%A4%B4%E9%83%A8} diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index f2ecab4c1..e4a78e7c2 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -55,10 +55,8 @@ export const useUserStore = defineStore({ return new Promise((resolve, reject) => { getLogin(data) .then(data => { - if (data) { - setToken(data.data); - resolve(data); - } + if (data?.success) setToken(data.data); + resolve(data); }) .catch(error => { reject(error); diff --git a/src/views/components/dialog/index.vue b/src/views/components/dialog/index.vue index 1a3be82b1..dda1a57c1 100644 --- a/src/views/components/dialog/index.vue +++ b/src/views/components/dialog/index.vue @@ -280,6 +280,16 @@ function onUpdateClick() { }); } +// popconfirm 确认框 +function onPopconfirmClick() { + addDialog({ + width: "30%", + title: "popconfirm确认框示例", + popconfirm: { title: "是否确认修改当前数据" }, + contentRenderer: () =>

点击右下方确定按钮看看效果吧

+ }); +} + // 结合Form表单(第一种方式,弹框关闭立刻恢复初始值)通过 props 属性接收子组件的 prop 并赋值 function onFormOneClick() { addDialog({ @@ -496,6 +506,7 @@ function onBeforeSureClick() { 关闭后的回调 嵌套的弹框 更改弹框自身属性值 + popconfirm确认框 diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 9b59f540a..e5803d09c 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -81,6 +81,8 @@ const onLogin = async (formEl: FormInstance | undefined) => { }) .finally(() => (disabled.value = false)); }); + } else { + message("登录失败", { type: "error" }); } }) .finally(() => (loading.value = false));