Skip to content

Commit

Permalink
Merge branch 'main' into release/gh-page
Browse files Browse the repository at this point in the history
  • Loading branch information
wenqing committed Aug 31, 2023
2 parents d175c87 + 15fb60b commit 21db0f3
Show file tree
Hide file tree
Showing 21 changed files with 743 additions and 48 deletions.
4 changes: 4 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ declare module 'vue' {
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCascader: typeof import('element-plus/es')['ElCascader']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
Expand All @@ -31,12 +33,14 @@ declare module 'vue' {
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSubmenu: typeof import('element-plus/es')['ElSubmenu']
ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTree: typeof import('element-plus/es')['ElTree']
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
Logicflow: typeof import('./src/components/Logicflow/index.vue')['default']
LogicFlow: typeof import('./src/components/LogicFlow/index.vue')['default']
Expand Down
13 changes: 12 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<template>
<RouterView />
<el-config-provider :locale="locale">
<RouterView />
</el-config-provider>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
import { useAppStore } from '@/stores/app'
const AppStore = useAppStore()
const locale = computed(() => AppStore.elementPlusLocale)
</script>
22 changes: 22 additions & 0 deletions src/api/role/index.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export interface IRoleInfo {
description: string
id: number
name: string
order: number
permissions: number[]
resources: number[]
type: 0 | 1
}

export interface IGetRolesParams {
page: number
page_size: number
name: string
type: 0 | 1 | ''
}

export interface IDataAuthInfo {
group_name: string
id: number
name: string
}
53 changes: 53 additions & 0 deletions src/api/role/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import request from '@/utils/request'
import type { IRoleInfo, IGetRolesParams, IDataAuthInfo } from './index.interface'

// 获取所有角色
export const getRoles = (params: IGetRolesParams) => {
return request<{ data: IRoleInfo[]; total: number }>({
url: '/roles',
method: 'get',
params
})
}

// 删除角色
export const deleteRole = (id: number) => {
return request({
url: `/roles/${id}`,
method: 'delete'
})
}

// 获取单个角色详情
export const getRoleById = (id: number) => {
return request<IRoleInfo>({
url: `/roles/${id}`,
method: 'get'
})
}

// 修改角色
export const updateRole = (id: number, data: Omit<IRoleInfo, 'id'>) => {
return request({
url: `/roles/${id}`,
method: 'put',
data
})
}

// 新增角色
export const addRole = (data: Omit<IRoleInfo, 'id'>) => {
return request({
url: '/roles',
method: 'post',
data
})
}

// 获取所有数据权限
export const getPermissions = () => {
return request<IDataAuthInfo[]>({
url: '/permission',
method: 'get'
})
}
1 change: 1 addition & 0 deletions src/assets/icons/role.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/user.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/assets/logo.svg

This file was deleted.

7 changes: 7 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ export const resource_type = [
{ label: '页面级', value: 3 }
]

/** 是否 */
export const bool_options = [
{ label: '否', value: 0 },
{ label: '是', value: 1 }
]

/** 角色类型 */
export const role_types = [
{ label: '用户', value: 0 },
{ label: '脚本', value: 1 }
]
2 changes: 1 addition & 1 deletion src/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ export const initPermissionGuard = (router: Router) => {
// finish progress bar
tricklingProgress.done()
// set page title
document.title = to.meta?.title || ''
document.title = to.meta.title ? `${settings.title} | ${to.meta.title}` : settings.title
})
}
10 changes: 2 additions & 8 deletions src/plugins/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ import { useAppStore } from '@/stores/app'
import enLocale from '@/locales/en'
import zhLocale from '@/locales/zh'

// element-plus国际化
import enLocaleElementPlus from 'element-plus/dist/locale/en.mjs'
import zhLocaleElementPlus from 'element-plus/dist/locale/zh-cn.mjs'

export const localesConfigs = {
en: {
...enLocale,
...enLocaleElementPlus
...enLocale
},
zh: {
...zhLocale,
...zhLocaleElementPlus
...zhLocale
}
}

Expand Down
18 changes: 18 additions & 0 deletions src/router/staticRoutes/labRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ export const labRoutes: IRouteRecord[] = [
title: '资源管理',
icon: 'resource-config'
}
},
{
path: 'role',
name: 'SystemRole',
component: () => import('@/views/system/role/index.vue'),
meta: {
title: '角色管理',
icon: 'role'
}
},
{
path: 'user',
name: 'SystemUser',
component: () => import('@/views/system/user/index.vue'),
meta: {
title: '用户管理',
icon: 'user'
}
}
]
}
Expand Down
16 changes: 14 additions & 2 deletions src/stores/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { computed, ref } from 'vue'
import type { LocaleType } from '@/plugins/i18n'

// element-plus国际化
import enLocaleElementPlus from 'element-plus/dist/locale/en.mjs'
import zhLocaleElementPlus from 'element-plus/dist/locale/zh-cn.mjs'

export const elmentPlusLocales: Record<LocaleType, any> = {
zh: zhLocaleElementPlus,
en: enLocaleElementPlus
}

export const useAppStore = defineStore(
'app',
() => {
Expand All @@ -19,11 +28,14 @@ export const useAppStore = defineStore(
language.value = lang
}

const elementPlusLocale = computed(() => elmentPlusLocales[language.value])

return {
sidebar,
ToggleSideBar,
language,
setLanguage
setLanguage,
elementPlusLocale
}
},
{
Expand Down
19 changes: 19 additions & 0 deletions src/styles/utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,23 @@

.view-container {
padding: 14px;
}

.color {
&--primary {
color: var(--el-color-primary);
}

&--danger {
color: var(--el-color-danger);
}

&--warning {
color: var(--el-color-warning);
}

&--info {
color: var(--el-color-info);
}

}
Empty file removed src/styles/variables.module.scss
Empty file.
30 changes: 0 additions & 30 deletions src/utils/imageToDataUrl.ts

This file was deleted.

8 changes: 7 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import isEmpty from 'lodash/isEmpty'
/** 验证对象或数组是否为空 */
export const isEmpty = (obj: Object & Array<any>) => {
if (['{}', '[]', 'null', undefined].includes(JSON.stringify(obj))) {
return true
}
return false
}

/**
* 筛选请求参数
Expand Down
8 changes: 4 additions & 4 deletions src/views/system/resource/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import { paramsVerify } from '@/utils'
import { filterResourceTypeLabel, filterBoolToText } from '@/filters'
import ResourceEditor from './ResourceEditor.vue'
import { ElMessageBox, ElMessage } from 'element-plus'
import { usePermissionStore } from '@/stores/permission'
defineOptions({
name: 'SystemResource'
Expand Down Expand Up @@ -129,12 +130,11 @@ const getTableData = async () => {
}
}
const PermissionStore = usePermissionStore()
const allResources = ref<IRouteResourceInfo[]>([])
const cacheAllResources = async () => {
const { status, data } = await getAllResource()
if (status === 200) {
allResources.value = data
}
allResources.value = await PermissionStore.allResources({ force: true })
}
const handleQuery = () => {
Expand Down
Loading

0 comments on commit 21db0f3

Please sign in to comment.