npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@juzhenfe/page-model

v3.10.5

Published

page—model是一个依赖于element-plus(vue@3)的后台管理页面组件,组件通过config配置驱动渲染。

Downloads

1,482

Readme

介绍

page—model是一个依赖于element-plus(vue@3)的后台管理页面组件,组件通过config配置驱动渲染。

如何引入

// page-model.ts
// 可以导出注册方法在main中进行注册

import { App } from 'vue'
// 引入组件样式
import '@juzhenfe/page-model/dist/index.min.css'
// 引入组件
import PageModel from '@juzhenfe/page-model'
// 引入组件请求实例
import { processdRequest } from '@/utils/request'

// 全局注册组件
export default {
  install(app: App) {
    app.use(PageModel, {
      request: processdRequest
    })
  }
}
// @/utils/request
import { createRequest } from '@juzhenfe/request'

// 构建请求实例
export const processdRequest = createRequest({
  // 请求基础地址
  baseURL: baseURL,
  // 授权头模式 JWT | NORMAL(参数携带)
  auth: 'JWT',
  arrayFormat: 'repeat',
  // 获取token
  getToken() {
    return tokenStorage.get() ?? ''
  },
  // 如何判断请求是成功的
  resolveJudge(response) {
    return successChain.passRequest(response)
  }
}, {
  process: true
}, {
  timeout: 3 * 60 * 1000
})

如何使用


<script setup lang="tsx">
import { ref } from "vue";
import { defineConfig } from "@juzhenfe/page-model";
import APIS from "@/constants/apis";

/**
 * pageModel组件实例
 */
const pageModelRef = ref<any>();

/**
 * 当前选中的数据
 */
let currentSelections: any[] = [];

const config = defineConfig<WorkTypeModel, any>({
  url: APIS.STATION_URL,
  delKey: "id",
  reflect: true,
  isAutoAddButton: false,
  getDataCallback(data) {
    return data;
  },
  searchForm: {
    els: [
      {
        eType: "el-input",
        prop: "name",
        label: "名称",
        props: { placeholder: "名称", clearable: true },
      },
    ],
  },
  table: {
    // el-table属性,参考https://element-plus.gitee.io/zh-CN/component/table.html#table-属性
    props: {
      // 开启斑马纹
      stripe: true,
      // 开启边框
      border: true,
    },
    // el-table事件,参考https://element-plus.gitee.io/zh-CN/component/table.html#table-事件
    events: {
      selectionChange(selections) {
        currentSelections = selections;
      },
    },

    // 是否多选按钮无依赖存活 注:通常开启多选时才会渲染多选按钮数据
    selectableButtonLiveAlone: true,
    // 多选按钮配置
    selectableButtons: [
      {
        text: "新增",
        event: "add",
        props: {
          type: "primary",
        },
      },
    ],
    // 操作栏配置
    operate: {
      width: 120,
      props: {
        fixed: "right",
      },
      els: [
        {
          text: "编辑",
          isEdit: true,
          props: {
            type: "primary",
            link: true,
          },
        },
        {
          text: "删除",
          isDel: true,
          props: {
            type: "primary",
            link: true,
          },
        },
      ],
    },
    els: [
      { label: "名称", prop: "name", minWidth: 100 },
      { label: "创建时间", prop: "createTime", minWidth: 100 },
    ],
  },
  form: {
    // 表单必填字段列表
    required: ["name"],
    // 弹窗模式dialog、全页面模式fullpage
    mode: "dialog",
    dialogProps: {
      width: "500px",
    },
    // 表单el-form的props,参考https://element-plus.gitee.io/zh-CN/component/form.html#form-属性
    props: {
      labelWidth: "100px",
    },
    // 新增表单时的初始化数据,会被bindData捕获到
    initialData: {},
    // 表单组件绑定数据前的处理方法
    async bindData(formData) {
      return formData;
    },
    // 表单组件提交数据前的处理方法
    async beforeSubmit(formData) {
      return formData;
    },
    els: [
      {
        eType: "el-input",
        prop: "name",
        label: "工种名称",
        props: { placeholder: "工种名称", clearable: true },
      }
    ],
  },
});

/**
 * 校验是否选中数据
 */
const selectDataValidate = () => {
  if (!currentSelections.length) {
    ElMessage.warning("请选择一条数据");
    return false;
  }
  return true;
};

/**
 * 刷新列表数据
 * @param clear 是否清空选中数据(默认true)
 */
const refreshTableData = (clear: boolean = true) => {
  pageModelRef.value.refreshTableData();
  clear && pageModelRef.value.clearSelection();
};

/**
 * 监听新增事件
 */
const handleAdd = () => {
  pageModelRef.value.handleAddEvent();
};
</script>

<template>
  <div class="gen-page" style="height: 100%">
    <page-model ref="pageModelRef" :config="config" @add="handleAdd" />
  </div>
</template>