GithubHelp home page GithubHelp logo

kailong321200875 / vue-element-plus-admin Goto Github PK

View Code? Open in Web Editor NEW
2.5K 52.0 585.0 9.09 MB

A backend management system based on vue3, typescript, element-plus, and vite

Home Page: https://element-plus-admin.cn/

License: MIT License

JavaScript 1.32% Shell 0.03% HTML 0.45% TypeScript 45.23% Vue 52.75% Less 0.04% CSS 0.13% Handlebars 0.06%
vite vuejs typescript element-plus admin-template pinia vue-router tsx

vue-element-plus-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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-element-plus-admin's Issues

启动报错,这是什么原因呢?

F:\学灯网录制的视频教程\前端脚手架20220407\vue-element-plus-admin-master\node_modules.pnpm\[email protected][email protected]\node_modules\vite-plugin-html\dist\index.cjs:125
const proxy = viteConfig.server?.proxy ?? {};
^

SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (F:\学灯网录制的视频教程\前端脚手架20220407\vue-element-plus-admin-master\vite.config.ts:46:31)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.require.extensions. [as .ts] (F:\学灯网录制的视频教程\前端脚手架20220407\vue-element-plus-admin-master\node_modules.pnpm\[email protected][email protected]\node_modules\vite\dist\node\chunks\dep-9c153816.js:71416:20)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at loadConfigFromBundledFile (F:\学灯网录制的视频教程\前端脚手架20220407\vue-element-plus-admin-master\node_modules.pnpm\[email protected][email protected]\node_modules\vite\dist\node\chunks\dep-9c153816.js:71424:17)
at loadConfigFromFile (F:\学灯网录制的视频教程\前端脚手架20220407\vue-element-plus-admin-master\node_modules.pnpm\[email protected][email protected]\node_modules\vite\dist\node\chunks\dep-9c153816.js:71343:32)
Waiting for the debugger to disconnect...
 ELIFECYCLE  Command failed with exit code 1.

路由相关的问题

作者您好,我有两个路由问题,向您请教

  1. 生成的嵌套路由的问题
    为什么使用 createRouter 生成二级路由
    // 文件地址:  utils/routerHelper.ts
    

const promoteRouteLevel = (route: AppRouteRecordRaw) => {
let router: Router | null = createRouter({
routes: [route as unknown as RouteRecordNormalized],
history: createWebHashHistory()
})
.....
}

2. 用 createRouter 生成的路由有个问题, 
   二级及更深的路由的 path 属性的设置, 不能 '/menu1', 只能 'menu1'
   如果是 '/menu1' 这样的路径, 生成的路由就不是全路径了,页面就读取不到这个路由了
   这是忘记对这块进行处理了吗?

感谢您看我的问题~

QA : How to us this as a template?

Hi,

How can I use this for a project I'm working on? What are the steps required to use this as a plain template for my use case? I there any specific file I need to remove?

How to clear cache and go to login page when session is expired in backend side?

Hello @kailong321200875
I'm just developing frontend side using this template and have 401 error code in response when the session is expired in backend side.
The backend is not editable so I handle response and logout manually.
I think the code will be here.

// config/axios/index.ts
// response 拦截器
service.interceptors.response.use(
  (response: AxiosResponse<Recordable>) => {
    if (response.data.code === result_code) {
      return response
    } else {
      ElMessage.error(response.data.msg)

      // handle here. Expected code will be here I think.....
      if (response.data.code === 401 && response.data.msg === '登陆过期!') {
        wsCache.clear()
        tagsViewStore.delAllViews()
        resetRouter() // 重置静态路由表
        router.replace('/login')
      }
    }
  },
  (error: AxiosError) => {
    console.log('err' + error) // for debug
    ElMessage.error(error.message)
    return Promise.reject(error)
  }
)

But it's not working.
How can I fix this?
Sorry for asking basic question.

Dialog和Form表单配合使用问题

作者您好,首先非常感谢你的这一套项目,对于我们帮助很大
如今我遇到这样一个问题,就是Dialog组件和Form配合使用时会报错
The form is not registered. Please use the register method to register
按照你给的例子分开,将Form当成一个组件不会报错,但实际在开发中往往有时写在一起会更方便一些,不知道这个问题是设计如此还是存在的问题呢

prettier not work

prettier is not working.

It always tell me that it cannot format 'xxx' files, like the pic below.
prettier

I've try my other projects, and they all work fine, so I do not think it is vscode error or prettier settings error.

Can I exchange position of label and input in schema? and custom size of label?

Hello @kailong321200875
I'd like to use Crud schema for Input component with a label right and custom size. Like in this image.
image

I just tried like this one.

  {
    field: 'hasChild',
    label: '生育情況',
    form: {
      component: 'Select',
      colProps: {
        span: 4
      },
      show: true
    },
    table: {
      show: false
    }
  },
  {
    field: 'boyNum',
    label: '',
    form: {
      component: 'Input',
      colProps: {
        span: 2
      },
      show: true
    },
    table: {
      show: false
    }
  },
  {
    field: 'girlNum',
    label: '',
    form: {
      component: 'Input',
      colProps: {
        span: 2
      },
      show: true
    },
    table: {
      show: false
    }
  },

The result is like this.
image

I should fix this but how can?

'span' in 'select' is not working

Hello @kailong321200875
I use span to set grid in select component in crud schema but is not working.

  {
    field: 'isMarried',
    label: '婚姻狀況',
    form: {
      component: 'Select',
      colProps: {
        span: 8
      },
      show: true
    },
    table: {
      show: false
    }
  },

The result is like this one.
image

Actually it's working well in Input but not others including DatePicker.
How can I fix?

How to use useValidator

Hello @kailong321200875
I tried to use useValidator to validate it's mobile number or not.
Like here.
image

But I'm not sure how I can use this func, especially parameters.

image

How can I fix?

Use Ref in form component

Hello @kailong321200875
Can I use ref in component in CRUD schema?
Like this one.

const my = ref(false)
// Schema
  {
    field: 'my',
    label: '',
    form: { show: false },
    table: { show: false },
    search: {
      show: true,
      component: 'Hidden',
      colProps: { span: 0 },
      value: my
    }
  },
const myOrder = () => {
  my.value = !my.value
}

But the value is not changing along to myOrder() function.
How can I fix?

表格嵌入el-button不展示

你们好,不知道为什么el-table-column 里面添加的按钮并不展示在页面上,单独添加的按钮是可以展示的,不知道是为什么。
页面展示如图:
image

代码:
<el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="260"> <template #action="{ row }"> <el-button>Default</el-button> <el-button type="text" icon="el-icon-edit" @click="handleUpdate(row)">修改</el-button> <el-button type="text" icon="el-icon-circle-check" @click="handleDataScope(row)" >数据权限</el-button > <el-button v-if="row.roleId > 2" type="text" icon="el-icon-delete" @click="handleDelete(row)" >删除</el-button > </template> </el-table-column>

怎么在本地代理配置,vite.config.ts

怎么在本地代理配置,vite.config.ts
以下代码一直在404错误:
server: { proxy: { // 选项写法 '/api': { target: 'http://47.***.***.***', changeOrigin: true, rewrite: path => path.replace(/^\/api/, '') } }, hmr: { overlay: false }, host: '0.0.0.0' },

Router.replace() is not working well

Hello @kailong321200875
I'd like to go to /login when the session is expired in the backend side.
But below code works sometimes but not other times.
In case of not working, router.replace() only changes the value of url in browser link bar, not execute.
How can I fix?

// response 拦截器
service.interceptors.response.use(
  (response: AxiosResponse<Recordable>) => {
    console.log(response.data)
    if (response.data.code === result_code) {
      return response
    } else if (response.data.code === 401 && response.data.msg === '登陆过期!') {
      wsCache.clear()
      tagsViewStore.delAllViews()
      resetRouter() // 重置静态路由表
      router.replace({
        path: '/login'
      })
    } else {
      ElMessage.error(response.data.msg)
    }
  },
  (error: AxiosError) => {
    console.log('err' + error) // for debug
    ElMessage.error(error.message)
    return Promise.reject(error)
  }
)

Can I make select component load its options from api by editing schema?

Hello @kailong321200875
I have search bar with input and select components.
No problems in input but not in select.
Now I'm updating my previous version using this template and it's load options from backend originally.
I'd like to establish this function by editing search schema.

image

Just want to set componentProps using link of api from backend.
Like this one.

componentsProps: '/sys/dict/option-list'

Is this possible?

Proxy api is not working in deployment

Hello @kailong321200875
Thank you for your kind responses.

I tried to deploy my project on vercel and it's done.
But the api is not working.
vite.config.ts
image

src/config/axios/config.ts
image

When I try to make a request in deployed website, 404 error is occured.
image

How can I fix?

define v-model in component in formSchema

Hello @kailong321200875
Actually I used to use React.js and Vue.js is first for me.
And I'd like to declare variable like Ref and v-model in Schema to handle in script setup.
For example there are two components type and list like following
image
The list in the right should be changed along the type.
But I have no solution to do this now.
Only thing I can do is to get value using getFormData() from whole schema when radio is changed and then execute setSchemaOption().
I think this is not the best solution.
How can I fix?

Which format extension should I use in this template?

Hello @kailong321200875
Thank you for your kind response.
Those are the most helpful for me.
Thank you again.

And I got another issue and here is.
It's just code formatting problem.

  1. I enjoy using prettier for code formatting and it's working well in other projects and also checked now.
    but it's not working in this template.
    I can't find that in formatter list, like following.
    image
    How can I fix this?

  2. Why is this error occurred?
    image
    It's just code format error(eslint related) and possible to affect project running?
    What formatter extension should I use fix this formatting error automatically in vscode?

Prepend in AutoComplete

Hello @kailong321200875
I have an issue in using an AutoComplete component.
I need to show dropdown with HEADER like this one.

image

But I can't handle the header like above.

image

How can I fix?

如果路由某子菜单路径(path)名相同,那么菜单点击选择时会出现混乱

2022-05-25_14-18-35
const adminList = [ { path: '/level', component: '#', redirect: '/level/menu1', name: 'Level', meta: { title: 'router.level', icon: 'carbon:skill-level-advanced' }, children: [ { path: 'menu1', name: 'Menu1', component: 'views/Level/Menu2', meta: { title: 'router.menu1' } }, { path: 'menu2', name: 'Menu2Demo', component: 'views/Level/Menu2', meta: { title: 'router.menu2' } } ] }, { path: '/level3', component: '#', redirect: '/level/menu1/menu1-1/menu1-1-1', name: 'Level3', meta: { title: 'router.level', icon: 'carbon:skill-level-advanced' }, children: [ { path: 'menu1', name: 'Menu13', component: 'views/Level/Menu2', meta: { title: 'router.menu1' } }, { path: 'menu2', name: 'Menu23Demo', component: 'views/Level/Menu2', meta: { title: 'router.menu2' } } ] } ]

作者您好

我根据您的模板做了一套, vuecli 并且没有使用 ts 开发的模板,不知道是否有机会, 可以给您看一下?

Response is undefined in api

Hello @kailong321200875
This is amazing open source template with Vite and Elementplus.
Thank you for your effort.

And I have an issue.
I always get undefined response when I make a request in api.

// api/login/index.ts
export const loginApi = async (data: UserLoginType): Promise<IResponse> => {
  const res = await request.post({
    url: '/index/login/system',
    headersType: 'application/x-www-form-urlencoded',
    data
  })
  console.log('in api: ', res)
  // this returns undefined. but there's correct response when I checked in console.
  return res && res.data
}

// vite.config.ts
    ...
    server: {
      port: 4000,
      proxy: {
        // 选项写法
        '/api': {
          target: 'http://35.194.244.237:9998',
          changeOrigin: true,
          rewrite: path => path.replace(/^\/api/, '')
        }
      },
      hmr: {
        overlay: false
      },
      host: '0.0.0.0'
    },
   ...

image

image

image

image

I also tried with sample api link for test.
https://jsonplaceholder.typicode.com/todos/1
But the result is the same.

How can I fix this?

keep-alive

keep-alive好像没效啊= =我每次切换都能执行onMounted

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.