Giter VIP home page Giter VIP logo

rainmango / vue3-composition-admin Goto Github PK

View Code? Open in Web Editor NEW
3.0K 34.0 897.0 19.76 MB

🎉 基于vue3 的管理端模板(Vue3 TS Vuex4 element-plus vue-i18n-next composition-api) vue3-admin vue3-ts-admin

License: MIT License

JavaScript 16.45% TypeScript 26.10% HTML 0.12% Vue 56.34% CSS 0.15% SCSS 0.81% Dockerfile 0.03%
vue3 composition-api vuex4 koa2 element-plus sass typescript echats vue-i18n-next vue-router-next

vue3-composition-admin's Introduction

logo

vue element-plus vuex vue-i18n-next npm gitter

vue3-composition-admin 是一个管理端模板解决方案,它是基于vue3,ts和element-plus,项目都是以composition api风格编写。

简介

项目的基础版本出自于源于花裤衩大佬的 vue-element-admin。

版本:

vue2+js版本:vue-element-admin

vue2+ts版本:vue-typescript-admin-template

vue3 发布之后,性能增强,速度vue2的倍数,打包体积都在减小(treeshaking),composition api 增加了项目可读性。

项目目的:

  • 学习vue3+ts
  • 保持 composition api 风格

在线demo演示地址:https://admin-tmpl-test.rencaiyoujia.cn/

相关项目

功能

- 用户管理
	- 登录(视频背景)
	- 注销
	
- 权限验证
  - 页面权限
  - 指令权限
  - 权限配置
  - 二步登录

- 多环境发布 (对应serve,build)
  - dev
  - test
  - prod
  
- 全局功能
  - iconfont
  - 国际化多语言
  - 多种动态换肤
  - 动态侧边栏(支持多级路由嵌套)
  - 动态面包屑
  - 快捷导航(标签页)
  - 本地/后端 mock 数据
  - Screenfull全屏
  - 自适应收缩侧边栏

- 编辑器
  - 富文本

- Excel
  - 导出excel
  - 导入excel
  - 前端可视化excel
  - 导出zip

- 表格
  - 动态表格
  - 拖拽表格
  - 内联编辑

- 错误页面
  - 401
  - 404

- 組件
  - 头像上传
  - 返回顶部
  - 拖拽Dialog
  - 拖拽Select
  - 拖拽看板
  - 列表拖拽
  - Dropzone
  - Sticky
  - CountTo (to do)

- 综合实例
- 错误日志
- Dashboard
- 引导页
- ECharts 图表
- Clipboard(剪贴复制)

目录结构

admin-tmpl
├─ .env.dev.build     # 开发环境
├─ .env.dev.serve     # 开发本地本地
├─ .env.prod.build    # 生产环境
├─ .env.prod.serve    # 生产环境本地
├─ .env.test.build    # 测试环境
├─ .env.test.serve    # 测试环境本地
├─ .eslintrc.js       # eslint
├─ README.md          
├─ dist               # 打包dist
├─ mock               # mock服务
├─ public             # 静态资源
├─ src                # 源码
│  ├─ @types          # ts 声明
│  ├─ apis            # 接口请求
│  ├─ assets          # webpack打包的资源
│  ├─ components      # 公共组件
│  ├─ config          # 全部配置
│  ├─ constant        # 常量
│  ├─ directives      # 全局指令
│  ├─ layout          # 全局Layout
│  ├─ locales         # 国际化
│  ├─ model           # 全部model存放
│  ├─ plugins         # 插件
│  ├─ router          # 路由
│  ├─ store           # 全局store管理
│  ├─ styles          # 全局样式
│  ├─ utils           # 全局公共方法
│  └─ views           # 所有业务页面
├─ tsconfig.json      # ts 编译配置
└─ vue.config.js      # vue-cli 配置

HighLight

项目均已最新技术实现,Vue3配套升级全家桶和涉及的插件组件等

项目采用技术:

  • vue3 + composition api
  • typescript3.9
  • sass (dart sass)
  • echats5

vue next 系列:

Document

Setup

项目主要是前端和mock server(node)

前后端都启动

  yarn
  yarn start

单独启动 Mock

后台模拟服务器和其他版本不同,采用koa2+Faker进行模拟。

启动mock server:

    yarn mock

mock 需要部署到服务器,单独项目地址:https://github.com/rcyj-FED/admin-tmpl-mock mock在线测试地址:https://admin-tmpl-mock-test.rencaiyoujia.cn/

单独启动 vue admin

    yarn  serve:dev

多环境命令查看package.json script:

    "serve:dev": "cross-env NODE_ENV=development dotenv -e .env.dev.serve vue-cli-service serve",
    "build:dev": "cross-env NODE_ENV=production  dotenv -e .env.dev.build vue-cli-service build",
    "serve:test": "cross-env NODE_ENV=development dotenv -e .env.test.serve vue-cli-service serve",
    "build:test": "cross-env NODE_ENV=production  dotenv -e .env.test.build vue-cli-service build",
    "serve:prod": "cross-env NODE_ENV=development dotenv -e .env.prod.serve vue-cli-service serve",
    "build:prod": "cross-env NODE_ENV=production  dotenv -e .env.prod.build vue-cli-service build",

eslint

    yarn  lint

提交自动检测:

 "gitHooks": {
    "pre-commit": "lint-staged"
  },
  "lint-staged": {
    "*.{js,jsx,vue,ts,tsx}": [
      "vue-cli-service lint",
      "git add"
    ]
  }

Browsers support

Modern browsers and Internet Explorer 10+.

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
IE10, IE11, Edge last 2 versions last 2 versions last 2 versions

讨论交流(QQ群:584617908)

qq

License

MIT

Copyright (c) 2021-present

vue3-composition-admin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue3-composition-admin's Issues

打包运行后报错 __INTLIFY_PROD_DEVTOOLS__ is not defined

运行yarn run build:prod
打包成功
dist文件运行在服务器上时报错
core-base.esm-bundler.js:167 Uncaught ReferenceError: INTLIFY_PROD_DEVTOOLS is not defined
at Module.ke (core-base.esm-bundler.js:167)
at F (vue-i18n.cjs.js:207)
at x (vue-i18n.cjs.js:236)
at S (vue-i18n.cjs.js:697)
at z (vue-i18n.cjs.js:1521)
at Object.8a43 (index.ts:47)
at l (bootstrap:89)
at Object.33d6 (state.ts:1)
at l (bootstrap:89)
at Object.eaf6 (app.f227d827.js:1)

启动出现错误,识别不了vue中的组合

[1] ERROR in src/views/zip/Index.vue:74:45
[1] TS2305: Module '"../../../node_modules/vue/dist/vue"' has no exported member 'onMounted'.
[1]     72 | <script lang="ts">
[1]     73 |
[1]   > 74 | import { defineComponent, reactive, toRefs, onMounted } from 'vue'
[1]        |                                             ^^^^^^^^^
[1]     75 | import { getArticles } from '@/apis/articles'
[1]     76 | import { ArticleModel } from '@/model/articleModel'
[1]     77 | import { formatJson } from '@/utils'

关于 快捷导航(标签栏导航)

你这个用vue3 实现 版本非常好。
基本上实现大部分的功能。

在体验中发现导航的地方有些不一样:比如说 多路由缓存
是 花裤衩大佬 在 vue-element-admin 文档说的那些注意事项吗?

使用 keep-alive 和 router-view 的结合, 以及要对一些特殊场景的处理

这种导航的需求因人而异,还是说 计划中?

这不是bug。
再次,这个项目是一个学习vue3 不错的项目。

依赖重复问题

package里面的day和moment重复了,moment依赖很大,建议去掉。

resetRouter是否是多余的函数?

路由模块(\vue3-composition-admin\src\router\index.ts)这个路径下有

export function resetRouter() {
     const newRouter = router;
     (router as any).matcher = (newRouter as any).matcher // reset 
}

这个函数,一直看不懂有啥用 能介绍下么

我找了一下文档也没看到matcher 这个东西 打印也是undefined

Vue 3.2 Support

如果你想使用这位大佬的 minimal 分支,可以使用这份优化后的版本:https://github.com/un-pany/v3-admin
再次感谢这位大佬提供的 vue3 minimal 分支,我们团队基于此分支,进行全面的改造更新,最终才产生了v3-admin

Invalid attempt to iterate non-iterable instance.

运行过程中的错误提示:

Uncaught (in promise) TypeError: Invalid attempt to iterate non-iterable instance.
    In order to be iterable, non-array objects must have a [Symbol.iterator]() method.
        at _createForOfIteratorHelper (createForOfIteratorHelper.js?b85c:30)
        at eval (Index.vue?b1ee:157)
    _createForOfIteratorHelper @ createForOfIteratorHelper.js?b85c:30
    eval @ Index.vue?b1ee:157
    Promise.then (async)
    nextTick @ runtime-core.esm-bundler.js?5c40:245
    moveToCurrentTag @ Index.vue?b1ee:157
    eval @ Index.vue?b1ee:174
    callWithErrorHandling @ runtime-core.esm-bundler.js?5c40:154
    callWithAsyncErrorHandling @ runtime-core.esm-bundler.js?5c40:163
    job @ runtime-core.esm-bundler.js?5c40:2077
    flushPreFlushCbs @ runtime-core.esm-bundler.js?5c40:328
    flushJobs @ runtime-core.esm-bundler.js?5c40:368
    Promise.then (async)
    queueFlush @ runtime-core.esm-bundler.js?5c40:286
    queueCb @ runtime-core.esm-bundler.js?5c40:308
    queuePreFlushCb @ runtime-core.esm-bundler.js?5c40:311
    scheduler @ runtime-core.esm-bundler.js?5c40:2105
    run @ reactivity.esm-bundler.js?a1e9:183
    trigger @ reactivity.esm-bundler.js?a1e9:189
    scheduler @ reactivity.esm-bundler.js?a1e9:820
    run @ reactivity.esm-bundler.js?a1e9:183
    trigger @ reactivity.esm-bundler.js?a1e9:189
    set value @ reactivity.esm-bundler.js?a1e9:730
    finalizeNavigation @ vue-router.esm-bundler.js?6c02:3071
    eval @ vue-router.esm-bundler.js?6c02:2944
    Promise.then (async)
    pushWithRedirect @ vue-router.esm-bundler.js?6c02:2915
    push @ vue-router.esm-bundler.js?6c02:2849
    navigate @ vue-router.esm-bundler.js?6c02:2069
    callWithErrorHandling @ runtime-core.esm-bundler.js?5c40:154
    callWithAsyncErrorHandling @ runtime-core.esm-bundler.js?5c40:163
    invoker @ runtime-dom.esm-bundler.js?830f:308
const moveToCurrentTag = () => {
      const tags = instance?.refs.tag as any[]
      nextTick(() => {
        // 此处添加数组类型判断能解决,不过目前对这个项目不太了解,为临时解决方案
        if (tags === null || tags === undefined || !(tags instanceof Array)) { return }
        for (const tag of tags) {
          if ((tag.to as TagView).path === currentRoute.path) {
            (scrollPaneRef.value as any).moveToCurrentTag(tag)
            // When query is different then update
            if ((tag.to as TagView).fullPath !== currentRoute.fullPath) {
              store.dispatch(TagsActionTypes.ACTION_UPDATE_VISITED_VIEW, currentRoute)
            }
          }
        }
      })
    }

是否支持 babel7的可选链配置?

写代码经常遇到,需要用到可选链,但是可选链配置是基于 babel7 在网上找了很多文档都无法检测出,这个项目的babel是不是7的,想问一下作者这个babel属于哪本版本的

i18n相关的问题

我有注意到你在permission.ts中定义的有如下代码:

// const getPageTitle = (key: string) => {
//   const i18n = useI18n()
//   const title = settings.title
//   const hasKey = i18n.te(`route.${key}`)
//   if (hasKey) {
//     const pageName = i18n.t(`route.${key}`)
//     return `${pageName} - ${title}`
//   }
//   return `${title}`
// }

我其实在vue-element-admin中的utils/get-page-title.js的基础上修改

import defaultSettings from '@/settings'
import i18n from'@/locales'

const title = defaultSettings.title || 'Vue3 Admin Template'

export default function getPageTitle(key) {
  const hasKey = i18n.te(`route.${key}`)
  if (hasKey) {
    const pageName = i18n.t(`route.${key}`)
    return `${pageName} - ${title}`
  }
  return `${title}`
}

遇到如下问题:

vue-router.esm-bundler.js?6c02:3248 TypeError: _locales__WEBPACK_IMPORTED_MODULE_2__.default.te is not a function
    at getPageTitle (get-page-title.js?036d:7)
    at _callee$ (permission.js?223d:19)
    at tryCatch (runtime.js?96cf:63)
    at Generator.invoke [as _invoke] (runtime.js?96cf:293)
    at Generator.eval [as next] (runtime.js?96cf:118)
    at asyncGeneratorStep (asyncToGenerator.js?1da1:3)
    at _next (asyncToGenerator.js?1da1:25)
    at eval (asyncToGenerator.js?1da1:32)
    at new Promise (<anonymous>)
    at eval (asyncToGenerator.js?1da1:21)

icon是在项目哪里

我看项目中没有看到icon的存放地方或引入地方,如果我想替换,我该怎么替换呢

构建特别慢

拉下来代码, yarn run build:test 构建速度非常慢, 经常卡在93%
after chunk asset optimization (93%) SourceMapDevTool
关闭了terser的parallel,依然很慢, 不知道作者有什么考虑?

文档

文档怎么打不开了?

element-variables.scss 修改配色无效

$--color-primary: #0984e3;
$--color-success: #00b894;
$--color-warning: #fdcb6e;
$--color-danger: #e17055;
$--color-info: #00cec9;

修改了element-variables.scss 的配色,为什么不生效,求帮助。

Vuex Modules 里怎么使用 namespaced

// TODO: With namespaced option turned on, having problem how to use dispatch with action types...
// But without it, a bigger store might have clashes in namings
// namespaced: true,

求指教

基于node@15+,vuex-module-decorators 依赖相关问题

如题,npm install 命令报错如下:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/vuex
npm ERR! vuex@"^4.0.0-0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vuex@"3" from [email protected]
npm ERR! node_modules/vuex-module-decorators
npm ERR! vuex-module-decorators@"^1.0.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/letsbug/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/letsbug/.npm/_logs/2021-07-28T14_10_26_756Z-debug.log

不知道 "vuex-class-modules" 依赖是否可以,作者有尝试过吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.