25 Commits

Author SHA1 Message Date
JaguarJack
3c4ebb86e7 chore:移除unsignedDecimal类型 2024-04-22 17:36:26 +08:00
JaguarJack
dede7b0ba0 fix:字段无法删除 2024-04-22 17:24:51 +08:00
JaguarJack
d995a8ce0d feat:创建数据表字段,支持拖拽 2024-04-21 13:46:53 +08:00
JaguarJack
898ce1305d fix:修复 Laravel11 获取表栏目 2024-04-15 09:17:33 +08:00
JaguarJack
7362bdd70f chore: update version 2024-04-15 09:05:24 +08:00
JaguarJack
4e104bfd47 chore: update version 2024-04-15 09:04:36 +08:00
JaguarJack
4700990507 chore: update version 2024-04-15 09:02:51 +08:00
JaguarJack
808dd7118d chore: update version 2024-04-15 09:00:17 +08:00
JaguarJack
0f2c2c644f fix:vue router name重复 2024-04-02 17:50:16 +08:00
JaguarJack
118fc1aaab fix:vue router name重复 2024-04-02 17:48:07 +08:00
JaguarJack
6de3edd4fc fix:修复选项卡删除逻辑 2024-04-02 11:01:32 +08:00
JaguarJack
de31bf23cd chore:修复 ElementPlus Select 组件宽度 2024-04-02 10:48:54 +08:00
JaguarJack
817e8ea64d chore:修复菜单唯一key 2024-04-02 10:48:10 +08:00
JaguarJack
8d97ff8867 fix:回退 element plus 版本 2024-04-02 09:20:23 +08:00
JaguarJack
490c573e61 chore 2024-03-28 08:11:33 +08:00
JaguarJack
4ffd3eed52 readme 2024-03-23 21:26:10 +08:00
JaguarJack
d47ccb586f update version 2024-03-23 17:21:52 +08:00
JaguarJack
b81b9b66c8 feat:新增 tagview 导航页 2024-03-23 17:21:39 +08:00
JaguarJack
c3eb2443b6 chore:修改分页错误 2024-03-23 17:21:03 +08:00
JaguarJack
4696461d72 chore:修改 radio api 接口 2024-03-23 17:20:00 +08:00
JaguarJack
aabaf99c1b fix:权限列表错误 2024-03-22 16:17:51 +08:00
JaguarJack
6f28c25a30 chore:调整Dialog内容样式 2024-03-14 10:27:18 +08:00
JaguarJack
667f6353d5 fix:修复生成 Request message 方法 2024-03-13 09:48:21 +08:00
JaguarJack
e69cc0e147 fix:修复页面权限指令 2024-03-07 12:00:05 +08:00
JaguarJack
e5be0ca2f8 fix: 优化提示 2024-03-07 11:28:09 +08:00
31 changed files with 478 additions and 120 deletions

View File

@@ -12,13 +12,13 @@
我深信,付费后台管理系统将为您带来更多的价值和便利,帮助您提升工作效率 我深信,付费后台管理系统将为您带来更多的价值和便利,帮助您提升工作效率
## 其他版本
- [tp8 新版本](https://gitee.com/catchamin/catchadmin-tp)
- [webman 高性能版本](https://gitee.com/catchamin/catchadmin-webman)
## ⚠Thinkphp 用户注意 ## ⚠Thinkphp 用户注意
由于新版本使用 `Laravel` 开发,所以请使用 `thinkphp` 分支或者 tag2.6.2thinkphp 版本已经非常稳定了。 由于新版本使用 `Laravel` 开发,所以请使用 `thinkphp` 分支或者 tag2.6.2thinkphp 版本已经非常稳定了。
## 为什么是 Laravel
`V2` 版本使用`Thinkphp`,但从其社区来看,从我个人角度来看开发组的心思已经不在维护框架上,因为据观察,每一次小版本发布都会引发一些小问题,虽然不大,但给人一种不够稳定的感觉,所以思索再三,使用 `Laravel``Laravel` 社区非常繁荣,他们每周都会发布新版本,以及围绕`Laravel`构建的生态也非常完善,有 `Horizon` 队列管理工具, `Telescope` 调试工具,`Octane`(基于 `Swoole``RoadRunner` 提高性能)等等一系列的工具,而且都是免费的。
## 功能 ## 功能
- [x] 用户管理 后台用户管理 - [x] 用户管理 后台用户管理
- [x] 部门管理 配置公司的部门结构,支持树形结构 - [x] 部门管理 配置公司的部门结构,支持树形结构

View File

@@ -11,19 +11,18 @@
], ],
"license": "MIT", "license": "MIT",
"require": { "require": {
"php": "^8.1", "php": "^8.2",
"ext-pdo": "*", "ext-pdo": "*",
"ext-zip": "*", "ext-zip": "*",
"doctrine/dbal": "^3.4", "guzzlehttp/guzzle": "^7.8.1",
"guzzlehttp/guzzle": "^7.2", "laravel/framework": "^11.0",
"laravel/framework": "^10.0", "laravel/tinker": "^v2.9.0",
"laravel/tinker": "^2.8", "catchadmin/core": "^0.3.2"
"catchadmin/core": "^0.2.7"
}, },
"require-dev": { "require-dev": {
"fakerphp/faker": "^1.9.1", "fakerphp/faker": "^v1.23.1",
"mockery/mockery": "^1.4.4", "mockery/mockery": "^1.6.9",
"pestphp/pest": "^1.22" "pestphp/pest": "^v2.34.2"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

Submodule modules/Cms deleted from 36e9e66e38

View File

@@ -20,23 +20,27 @@ class Components implements OptionInterface
public function get(): array public function get(): array
{ {
if ($module = request()->get('module')) { try {
$components = File::glob(CatchAdmin::getModuleViewsPath($module).'*'.DIRECTORY_SEPARATOR.'*.vue'); if ($module = request()->get('module')) {
$components = File::glob(CatchAdmin::getModuleViewsPath($module) . '*' . DIRECTORY_SEPARATOR . '*.vue');
foreach ($components as $component) { foreach ($components as $component) {
$_component = Str::of($component) $_component = Str::of($component)
->replace(CatchAdmin::moduleRootPath(), '') ->replace(CatchAdmin::moduleRootPath(), '')
->explode(DIRECTORY_SEPARATOR); ->explode(DIRECTORY_SEPARATOR);
$_component->shift(2); $_component->shift(2);
$this->components[] = [ $this->components[] = [
'label' => Str::of($_component->implode('/'))->replace('.vue', ''), 'label' => Str::of($_component->implode('/'))->replace('.vue', ''),
'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/') 'value' => Str::of($component)->replace(CatchAdmin::moduleRootPath(), '')->prepend('/')
]; ];
}
} }
}
return $this->components; return $this->components;
} catch (\Throwable $exception) {
return [];
}
} }
} }

View File

@@ -6,8 +6,8 @@ use Catch\Base\CatchModel;
use Catch\Enums\Status; use Catch\Enums\Status;
use Exception; use Exception;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Modules\Develop\Support\Generate\Create\Schema; use Modules\Develop\Support\Generate\Create\Schema;
use Illuminate\Support\Facades\Schema as SchemaFacade;
class Schemas extends CatchModel class Schemas extends CatchModel
{ {
@@ -90,16 +90,13 @@ class Schemas extends CatchModel
{ {
$schema = parent::firstBy($id); $schema = parent::firstBy($id);
$columns = []; foreach (SchemaFacade::getColumns($schema->name) as $column) {
foreach (getTableColumns($schema->name) as $columnString) {
$column = DB::connection()->getDoctrineColumn(DB::connection()->getTablePrefix().$schema->name, $columnString);
$columns[] = [ $columns[] = [
'name' => $column->getName(), 'name' => $column['name'],
'type' => $column->getType()->getName(), 'type' => $column['type_name'],
'nullable' => ! $column->getNotnull(), 'nullable' => $column['nullable'],
'default' => $column->getDefault(), 'default' => $column['default'],
'comment' => $column->getComment() 'comment' => $column['comment'],
]; ];
} }

View File

@@ -21,7 +21,7 @@ class {request} extends Request
* *
* @return array * @return array
*/ */
public function message(): array public function messages(): array
{ {
return []; return [];
} }

View File

@@ -0,0 +1,11 @@
<script setup lang="ts">
</script>
<template>
$END$
</template>
<style scoped lang="scss">
</style>

View File

@@ -8,7 +8,7 @@
{ label: 'ZIP 安装', value: 2 }, { label: 'ZIP 安装', value: 2 },
]" ]"
:key="item.value" :key="item.value"
:label="item.value" :value="item.value"
name="type" name="type"
>{{ item.label }} >{{ item.label }}
</el-radio-button> </el-radio-button>

View File

@@ -1,27 +1,29 @@
<template> <template>
<div> <div>
<el-table :data="structures" class="draggable"> <VueDraggable v-model="structures" target=".el-table__body tbody" animation="150" @end="onEnd">
<el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" /> <el-table :data="structures" class="draggable" :lazy="false">
<el-table-column prop="type" :label="$t('generate.schema.structure.type.name')"> <el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" />
<template #default="scope"> <el-table-column prop="type" :label="$t('generate.schema.structure.type.name')">
<el-tag type="success">{{ scope.row.type }}</el-tag> <template #default="scope">
</template> <el-tag type="success">{{ scope.row.type }}</el-tag>
</el-table-column> </template>
<el-table-column prop="nullable" :label="$t('generate.schema.structure.nullable')" width="90px"> </el-table-column>
<template #default="scope"> <el-table-column prop="nullable" :label="$t('generate.schema.structure.nullable')" width="90px">
<el-tag v-if="scope.row.nullable">{{ $t('system.yes') }}</el-tag> <template #default="scope">
<el-tag v-else type="info">{{ $t('system.no') }}</el-tag> <el-tag v-if="scope.row.nullable">{{ $t('system.yes') }}</el-tag>
</template> <el-tag v-else type="info">{{ $t('system.no') }}</el-tag>
</el-table-column> </template>
<el-table-column prop="default" :label="$t('generate.schema.structure.default')" /> </el-table-column>
<!--<el-table-column prop="comment" label="注释" />--> <el-table-column prop="default" :label="$t('generate.schema.structure.default')" />
<el-table-column prop="id" :label="$t('generate.schema.structure.operate')" width="120px"> <!--<el-table-column prop="comment" label="注释" />-->
<template #default="scope"> <el-table-column prop="id" :label="$t('generate.schema.structure.operate')" width="120px">
<el-button type="primary" :icon="Edit" @click="updateField(scope.row.id)" size="small" /> <template #default="scope">
<el-button type="danger" :icon="Delete" @click="deleteField(scope.row.id)" size="small" /> <el-button type="primary" :icon="Edit" @click="updateField(scope.row.id)" size="small" />
</template> <el-button type="danger" :icon="Delete" @click="deleteField(scope.row.id)" size="small" />
</el-table-column> </template>
</el-table> </el-table-column>
</el-table>
</VueDraggable>
<div class="flex justify-end mt-4"> <div class="flex justify-end mt-4">
<el-button type="success" :icon="Plus" @click="addField">{{ $t('system.add') }}</el-button> <el-button type="success" :icon="Plus" @click="addField">{{ $t('system.add') }}</el-button>
@@ -88,21 +90,21 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, Ref, ref } from 'vue' import { Ref, ref } from 'vue'
import { useSchemaStore, Structure } from '../store' import { useSchemaStore, Structure } from '../store'
import { Delete, Plus, Edit } from '@element-plus/icons-vue' import { Delete, Plus, Edit } from '@element-plus/icons-vue'
import type { FormInstance } from 'element-plus' import type { FormInstance } from 'element-plus'
import Message from '/admin/support/message' import Message from '/admin/support/message'
import http from '/admin/support/http' import http from '/admin/support/http'
import { Code } from '/admin/enum/app' import { Code } from '/admin/enum/app'
import { VueDraggable } from 'vue-draggable-plus'
const schemaStore = useSchemaStore() const schemaStore = useSchemaStore()
const emits = defineEmits(['prev', 'next']) const emits = defineEmits(['prev', 'next'])
const visible = ref(false) const visible = ref(false)
const structures = computed(() => { // 初始化
return schemaStore.getStructures const structures = ref(schemaStore.getStructures)
})
const structure: Ref<Structure> = ref(schemaStore.initStructure()) const structure: Ref<Structure> = ref(schemaStore.initStructure())
// structure // structure
@@ -117,6 +119,8 @@ const updateField = (id: number) => {
structure.value = s structure.value = s
} }
}) })
schemaStore.setStructures(structures.value)
} }
const form = ref<FormInstance>() const form = ref<FormInstance>()
@@ -134,7 +138,10 @@ const submitStructure = (formEl: FormInstance | undefined) => {
} }
const deleteField = (id: number) => { const deleteField = (id: number) => {
schemaStore.filterStructures(id) structures.value = structures.value.filter((s: Structure) => {
return !(s.id === id)
})
schemaStore.setStructures(structures.value)
} }
const next = () => { const next = () => {
@@ -149,7 +156,10 @@ const next = () => {
}) })
} }
} }
// 调整数据结构
const onEnd = () => {
schemaStore.setStructures(structures.value)
}
const types: string[] = [ const types: string[] = [
'id', 'id',
'smallIncrements', 'smallIncrements',
@@ -201,7 +211,6 @@ const types: string[] = [
'tinyIncrements', 'tinyIncrements',
'tinyInteger', 'tinyInteger',
'tinyText', 'tinyText',
'unsignedDecimal',
'uuid', 'uuid',
'year', 'year',
] ]

View File

@@ -28,7 +28,9 @@ class PermissionsController extends Controller
public function index(Request $request): mixed public function index(Request $request): mixed
{ {
if ($request->get('from') == 'role') { if ($request->get('from') == 'role') {
return $this->model->getList(); return $this->model->setBeforeGetList(function ($query){
return $query->orderByDesc('sort');
})->getList();
} }
return $this->model->setBeforeGetList(function ($query) { return $this->model->setBeforeGetList(function ($query) {

View File

@@ -8,7 +8,7 @@
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status"> <el-radio-group v-model="formData.status">
<el-radio v-for="item in options" :key="item.value" :label="item.value" name="status">{{ item.label }}</el-radio> <el-radio v-for="item in options" :key="item.value" :value="item.value" name="status">{{ item.label }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="排序" prop="sort"> <el-form-item label="排序" prop="sort">
@@ -30,7 +30,7 @@ import { useShow } from '/admin/composables/curd/useShow'
import { onMounted } from 'vue' import { onMounted } from 'vue'
const props = defineProps({ const props = defineProps({
primary: String | Number, primary: [Number, String],
api: String, api: String,
}) })

View File

@@ -11,7 +11,7 @@
{ label: '按钮', value: 3 }, { label: '按钮', value: 3 },
]" ]"
:key="item.value" :key="item.value"
:label="item.value" :value="item.value"
name="type" name="type"
>{{ item.label }} >{{ item.label }}
</el-radio-button> </el-radio-button>
@@ -63,7 +63,7 @@
{ label: '隐藏', value: 2 }, { label: '隐藏', value: 2 },
]" ]"
:key="item.value" :key="item.value"
:label="item.value" :value="item.value"
name="hidden" name="hidden"
>{{ item.label }}</el-radio >{{ item.label }}</el-radio
> >
@@ -77,7 +77,7 @@
{ label: '禁用', value: 2 }, { label: '禁用', value: 2 },
]" ]"
:key="item.value" :key="item.value"
:label="item.value" :value="item.value"
name="keepalive" name="keepalive"
>{{ item.label }} >{{ item.label }}
</el-radio> </el-radio>
@@ -110,7 +110,7 @@ import http from '/admin/support/http'
import { MenuType } from '/admin/enum/app' import { MenuType } from '/admin/enum/app'
const props = defineProps({ const props = defineProps({
primary: String | Number, primary: [String,Number],
api: String, api: String,
}) })

View File

@@ -18,9 +18,9 @@
<el-tag v-for="action in scope.row.actions" class="cursor-pointer min-w-fit" @click="open(action.id)" closable @close="destroy(api, action.id)">{{ action.permission_name }}</el-tag> <el-tag v-for="action in scope.row.actions" class="cursor-pointer min-w-fit" @click="open(action.id)" closable @close="destroy(api, action.id)">{{ action.permission_name }}</el-tag>
</div> </div>
<div v-else> <div v-else>
<el-popconfirm confirm-button-text="确认" title="添加基础actions" @confirm="actionGenerate(scope.row.id)" placement="top"> <el-popconfirm v-if="scope.row.type === MenuType.PAGE_TYPE" confirm-button-text="确认" title="添加基础actions" @confirm="actionGenerate(scope.row.id)" placement="top">
<template #reference> <template #reference>
<el-tag class="cursor-pointer w-8" v-if="scope.row.type === MenuType.PAGE_TYPE"> <el-tag class="cursor-pointer w-8">
<Icon name="cog-6-tooth" class="animate-spin w-5 h-5" v-if="generateId === scope.row.id" /> <Icon name="cog-6-tooth" class="animate-spin w-5 h-5" v-if="generateId === scope.row.id" />
<Icon name="plus" className="w-4 h-4" v-else /> <Icon name="plus" className="w-4 h-4" v-else />
</el-tag> </el-tag>

View File

@@ -2,8 +2,8 @@
<div class="table-default"> <div class="table-default">
<div class="w-full flex justify-end"> <div class="w-full flex justify-end">
<el-radio-group v-model="query.scope" size="small" @change="search"> <el-radio-group v-model="query.scope" size="small" @change="search">
<el-radio-button label="self">只看自己</el-radio-button> <el-radio-button value="self">只看自己</el-radio-button>
<el-radio-button label="all">全部</el-radio-button> <el-radio-button value="all">全部</el-radio-button>
</el-radio-group> </el-radio-group>
</div> </div>
<el-table :data="tableData" class="mt-3" v-loading="loading"> <el-table :data="tableData" class="mt-3" v-loading="loading">

View File

@@ -8,48 +8,49 @@
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"@heroicons/vue": "^2.1.1", "@heroicons/vue": "^2.1.3",
"@tinymce/tinymce-vue": "^5.1.1", "@tinymce/tinymce-vue": "^5.1.1",
"@vueuse/core": "^10.1.2", "@vueuse/core": "^10.9.0",
"element-plus": "^2.5.3", "element-plus": "^2.6.3",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"pinia": "^2.1.7", "pinia": "^2.1.7",
"terser": "^5.16.6", "terser": "^5.29.2",
"vue": "^3.4.15", "vue": "^3.4.21",
"vue-draggable-plus": "^0.4.0",
"vue-i18n": "9", "vue-i18n": "9",
"vue-router": "4.2.5", "vue-router": "4.3.0",
"vuedraggable": "^2.24.3" "vuedraggable": "^2.24.3"
}, },
"devDependencies": { "devDependencies": {
"@iconify-json/logos": "^1.1.31", "@iconify-json/logos": "^1.1.42",
"@rollup/plugin-alias": "^5.0.0", "@rollup/plugin-alias": "^5.1.0",
"@types/mockjs": "^1.0.7", "@types/mockjs": "^1.0.7",
"@types/node": "^20.2.3", "@types/node": "^20.11.30",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@typescript-eslint/eslint-plugin": "^6.19.1", "@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.19.1", "@typescript-eslint/parser": "^6.21.0",
"@vitejs/plugin-vue": "^5.0.3", "@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0", "@vitejs/plugin-vue-jsx": "^3.1.0",
"autoprefixer": "^10.4.17", "autoprefixer": "^10.4.19",
"axios": "^1.5.1", "axios": "^1.6.8",
"eslint": "^8.41.0", "eslint": "^8.57.0",
"eslint-config-standard": "^17.0.0", "eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.27.5", "eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.0", "eslint-plugin-n": "^16.0.0",
"eslint-plugin-promise": "^6.1.1", "eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.19.2", "eslint-plugin-vue": "^9.23.0",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"postcss": "^8.4.33", "postcss": "^8.4.38",
"prettier": "2.8.8", "prettier": "3.2.5",
"sass": "^1.62.1", "sass": "^1.72.0",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",
"typescript": "^5.1.6", "typescript": "^5.4.3",
"unplugin-auto-import": "^0.17.3", "unplugin-auto-import": "^0.17.5",
"unplugin-icons": "^0.18.2", "unplugin-icons": "^0.18.5",
"unplugin-vue-components": "^0.25.2", "unplugin-vue-components": "^0.26.0",
"vite": "^5.0.12", "vite": "^5.2.3",
"vite-plugin-html": "^3.2.0", "vite-plugin-html": "^3.2.0",
"vite-plugin-mock": "^3.0.0", "vite-plugin-mock": "^3.0.0",
"vue-tsc": "^1.6.5" "vue-tsc": "^2.0.7"
} }
} }

View File

@@ -12,7 +12,9 @@
</div> </div>
</div> </div>
</template> </template>
<slot /> <div class="pt-4">
<slot />
</div>
<template #footer v-if="showFooter"> <template #footer v-if="showFooter">
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="close">{{ $t('system.cancel') }}</el-button> <el-button @click="close">{{ $t('system.cancel') }}</el-button>

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="flex justify-end pt-5"> <div class="flex justify-end pt-5">
<el-pagination background :layout="layout" :current-page="page" :page-size="limit" @current-change="changePage" @size-change="changeLimit" :total="total" :page-sizes="pageSizes" /> <el-pagination background :layout="layout" :current-page="page" :page-size="limit" @current-change="changePage" @size-change="changeLimit" :total="parseInt(total)" :page-sizes="pageSizes" />
</div> </div>
</template> </template>
@@ -14,12 +14,10 @@ const pageSizes = [10, 20, 30, 50]
interface paginate { interface paginate {
page: number page: number
limit: number limit: number
total: number total: string
changePage: number changePage: number
changeLimit: number changeLimit: number
} }
const { page, limit, total, changePage, changeLimit } = inject('paginate') as paginate const { page, limit, total, changePage, changeLimit } = inject('paginate') as paginate
</script> </script>
<style scoped></style>

View File

@@ -30,4 +30,8 @@ defineProps({
}) })
</script> </script>
<style scoped></style> <style scoped>
:deep(.el-form-item) {
min-width: 240px;
}
</style>

View File

@@ -0,0 +1,85 @@
import { ref } from 'vue'
import { getFileExt, getFilename } from '@/form/support/helper'
import { Code } from '@/form/enum/app'
import Message from '@/form/support/message'
import { genFileId } from 'element-plus'
import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus'
// 上传文件
export function uploadFile(action: string, ext: Array<String>, isValidate: boolean = true) {
const upload = ref<UploadInstance>()
const file = ref<string>('')
const filename = ref<string>('')
const fileExtensions = ext.join('|')
// 上传前的钩子 判断文件类型
const beforeUpload = (file: UploadRawFile) => {
if (isValidate) {
const isCanUpload = ext.indexOf(getFileExt(file.name).substring(1)) > -1
if (!isCanUpload) {
Message.error('不符合上传文件类型,仅支持' + fileExtensions)
}
return isCanUpload
} else {
return true
}
}
const handleExceed: UploadProps['onExceed'] = files => {
upload.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
upload.value!.handleStart(file)
upload.value!.submit()
}
const handleSuccess = (response: any, uploadFile: any) => {
if (response.code === Code.SUCCESS) {
file.value = response.data.path
filename.value = getFilename(file.value)
} else {
Message.error(response.message)
}
}
return { upload, beforeUpload, handleExceed, handleSuccess, file, filename, fileExtensions }
}
// 上传图片
// 上传文件
export function uploadImage(action: string, extensions: Array<String>) {
const upload = ref<UploadInstance>()
const file = ref<string>('')
const filename = ref<string>('')
const fileExtensions = extensions
// 上传前的钩子 判断文件类型
const beforeUpload = (file: UploadRawFile) => {
const isCanUpload = fileExtensions.indexOf(getFileExt(file.name).substring(1)) > -1
if (!isCanUpload) {
Message.error('不符合上传文件类型,仅支持' + fileExtensions)
}
return isCanUpload
}
const handleExceed: UploadProps['onExceed'] = files => {
upload.value!.clearFiles()
const file = files[0] as UploadRawFile
file.uid = genFileId()
upload.value!.handleStart(file)
upload.value!.submit()
}
const handleSuccess = (response: any, uploadFile: any) => {
if (response.code === Code.SUCCESS) {
file.value = response.data.path
filename.value = getFilename(file.value)
} else {
Message.error(response.message)
}
}
return { upload, beforeUpload, handleExceed, handleSuccess, file, filename, fileExtensions }
}

View File

@@ -8,7 +8,7 @@ function checkAction(el: any, action: any) {
action = action.value.replace('@', '.').toLowerCase() action = action.value.replace('@', '.').toLowerCase()
const hasAction = permissions?.some(permission => { const hasAction = permissions?.some(permission => {
if (permission.type === MenuType.Button_Type) { if (permission.type === MenuType.Button_Type) {
const a: string = permission.module + '.' + permission.permission_mark.replace('@', '.') const a: string = permission.module + '.' + permission.permission_mark.replaceAll('@', '.')
return action === a.toLowerCase() return action === a.toLowerCase()
} }
}) })

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-sub-menu :index="menu?.path" :class="subMenuClass" v-if="menu?.children?.length"> <el-sub-menu :index="menu?.path" :class="subMenuClass" v-if="menu?.children?.length" :key="menu?.path">
<template #title> <template #title>
<el-icon> <el-icon>
<Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" /> <Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" />
@@ -9,7 +9,7 @@
<slot /> <slot />
</el-sub-menu> </el-sub-menu>
<el-menu-item v-else class="ct-menu-item" :index="menu?.path" @click="isMiniScreen() && store.changeExpaned()"> <el-menu-item v-else class="ct-menu-item" :index="menu?.path" @click="isMiniScreen() && store.changeExpaned()" :key="menu?.path">
<el-icon> <el-icon>
<Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" /> <Icon :name="menu?.meta?.icon" v-if="menu?.meta?.icon" class="text-sm" />
</el-icon> </el-icon>

View File

@@ -14,8 +14,25 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { useAppStore } from '/admin/stores/modules/app' import { useAppStore } from '/admin/stores/modules/app'
import { watch } from 'vue'
import router from '/admin/router'
import { useNavTabStore } from '/admin/stores/modules/tabs'
const appStore = useAppStore() const appStore = useAppStore()
const navTabStore = useNavTabStore()
watch(() => router.currentRoute, (to, from) => {
const tab: any = {
name: to.value.name,
fullPath: to.value.fullPath,
path: to.value.path,
is_active: true,
meta: {
title: to.value.meta.title,
affix: false,
}
}
navTabStore.addTabs(tab)
}, {deep:true, immediate:true})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -0,0 +1,70 @@
<template>
<div @contextmenu.prevent="handleContextMenu" class="flex gap-x-2">
<slot></slot>
<!-- 右击菜单 -->
<div v-if="showMenu" class="absolute z-[1000] bg-white dark:bg-regal-dark shadow-xl rounded border border-gray-200" :style="{ top: `${position.y}px`, left: `${position.x}px` }">
<ul class="w-20 text-center py-1">
<li v-for="(item, index) in menuItems" :key="index" @click="item.action()" class="hover:bg-gray-50 px-2 py-1 hover:cursor-pointer text-[12px]">
{{ item.label }}
</li>
</ul>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, reactive, onUnmounted } from 'vue';
import { useNavTabStore } from '/admin/stores/modules/tabs';
const navTabStore = useNavTabStore();
interface MenuItem {
label: string;
action: Function;
}
const position = reactive({ x: 0, y: 0 });
const showMenu = ref(false);
const menuItems = ref<Array<MenuItem>>([
{ label: '刷新', action: () => {
navTabStore.refreshCurrentTab();
}
},
{ label: '关闭', action: () => {
navTabStore.removeCurrentTab();
}
},
{ label: '关闭其他', action: () => { navTabStore.removeOtherTabs() } },
{ label: '关闭所有', action: () => { navTabStore.removeAllTabs() } },
]);
const handleContextMenu = (event: MouseEvent) => {
event.preventDefault();
position.x = event.clientX;
position.y = event.clientY;
showMenu.value = true;
};
const handleClickOutside = () => {
showMenu.value = false;
};
window.addEventListener('click', handleClickOutside);
onUnmounted(() => {
window.removeEventListener('click', handleClickOutside);
});
const handleMenuItemClick = (action: string) => {
console.log('执行操作:', action);
};
</script>
<style>
.context-menu {
position: absolute;
background-color: #fff;
border: 1px solid #ccc;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
z-index: 1000;
}
</style>

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="flex flex-row h-16 w-full drop-shadow border-l dark:border-l-0 border-gray-200" style="background-color: var(--header-bg-color)"> <div class="flex flex-row h-14 w-full drop-shadow border-l border-gray-200" style="background-color: var(--header-bg-color)">
<div class="flex flex-row justify-between w-full h-16"> <div class="flex flex-row justify-between w-full h-14">
<div class="flex flex-row min-w-[17rem]"> <div class="flex flex-row min-w-[17rem]">
<div class="h-full flex items-center w-8 ml-2 hover:cursor-pointer" @click="store.changeExpaned"> <div class="h-full flex items-center w-8 ml-2 hover:cursor-pointer" @click="store.changeExpaned">
<Icon name="list-bullet" class="w-6 h-8" /> <Icon name="list-bullet" class="w-6 h-8" />
@@ -24,11 +24,12 @@
</div> </div>
</div> </div>
</div> </div>
<Tabs/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useAppStore } from '/admin/stores/modules/app' import { useAppStore } from '/admin/stores/modules/app'
import Notification from './notification.vue' import Notification from './notification.vue'
import MenuSearch from './menuSearch.vue' import MenuSearch from './menuSearch.vue'
import Tabs from './tabs.vue'
const store = useAppStore() const store = useAppStore()
</script> </script>

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="w-10 h-10 grid place-items-center rounded-full mt-3 hover:cursor-pointer"> <div class="w-10 h-10 grid place-items-center rounded-full mt-2 hover:cursor-pointer">
<div class="flex hover:cursor-pointer pl-1 pr-1"> <div class="flex hover:cursor-pointer pl-1 pr-1">
<el-dropdown size="large" class="flex items-center justify-center hover:cursor-pointer w-full" @command="selectLanguage"> <el-dropdown size="large" class="flex items-center justify-center hover:cursor-pointer w-full" @command="selectLanguage">
<Icon name="language" /> <Icon name="language" />

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="w-10 h-10 grid place-items-center rounded-full mt-3 hover:cursor-pointer"> <div class="w-10 h-10 grid place-items-center rounded-full mt-2 hover:cursor-pointer">
<div class="flex flex-row w-96"> <div class="flex flex-row w-96">
<Icon name="magnifying-glass" class="hidden sm:block" @click="searchMenuVisiable = true" /> <Icon name="magnifying-glass" class="hidden sm:block" @click="searchMenuVisiable = true" />

View File

@@ -1,6 +1,6 @@
<template> <template>
<!-- 通知 --> <!-- 通知 -->
<div class="w-10 h-10 grid place-items-center rounded-full mt-3 hover:cursor-pointer" ref="messageRef" v-click-outside="onClickOutside"> <div class="w-10 h-10 grid place-items-center rounded-full mt-2 hover:cursor-pointer" ref="messageRef" v-click-outside="onClickOutside">
<el-badge :value="3"> <el-badge :value="3">
<Icon name="bell" /> <Icon name="bell" />
</el-badge> </el-badge>

View File

@@ -0,0 +1,29 @@
<script setup lang="ts">
import { useNavTabStore } from '/admin/stores/modules/tabs'
import ContextMenu from './contextMenu.vue'
import { computed, ref, onMounted,onBeforeUnmount, watch } from 'vue'
const navTabStore = useNavTabStore()
const tabs = computed(() => navTabStore.getNavTabs)
</script>
<template>
<div class="h-10 bg-white dark:bg-regal-dark px-1 sm:px-3 w-full flex gap-x-2" ref="container" v-if="tabs.length > 0">
<ContextMenu>
<el-tag
class="mt-1.5 hover:cursor-pointer"
v-for="(tag, index) in tabs" :key="index"
:closable="!tag.meta.affix"
:disable-transitions="false"
:effect="tag.is_active ? 'dark' : 'plain'"
@click.prevent="navTabStore.selectTab(tag)"
@close="navTabStore.removeTab(index)"
>
{{ tag.meta.title }}
</el-tag>
</ContextMenu>
</div>
</template>
<style scoped>
</style>

View File

@@ -1,5 +1,5 @@
<template> <template>
<div class="w-10 h-10 grid place-items-center rounded-full mt-3 hover:cursor-pointer"> <div class="w-10 h-10 grid place-items-center rounded-full mt-2 hover:cursor-pointer">
<Icon name="moon" @click="changeTheme()" v-if="isDark" /> <Icon name="moon" @click="changeTheme()" v-if="isDark" />
<Icon name="sun" @click="changeTheme()" v-else /> <Icon name="sun" @click="changeTheme()" v-else />
</div> </div>

View File

@@ -0,0 +1,130 @@
import { defineStore } from 'pinia'
import router from '/admin/router'
interface meta {
title: string
affix: boolean
}
interface tab {
name: string
fullPath: string
path: string
is_active:boolean,
meta: meta
}
const defaultTab: tab = {
name: 'Dashboard',
fullPath: '/dashboard',
path: '/dashboard',
is_active: true,
meta: {
title: 'Dashboard',
affix: true,
},
}
export const useNavTabStore = defineStore('nav_tabs', {
state: ()=> {
return {
tabs: [defaultTab] as Array<tab>,
}
},
getters: {
getNavTabs(state): Array<tab> {
return state.tabs
},
},
actions: {
addTabs(Tab: tab): void {
if (this.tabs.length >= 20) {
console.log('最多添加 20 个 tab 标签');
return;
}
let isExist = false
this.tabs.map(t => {
if (t.name === Tab.name) {
isExist = true
t.is_active = true
} else {
t.is_active = false
}
})
if (!isExist) {
this.tabs.push(Tab)
}
},
getActiveTabIndex(): number|null {
for (let i = 0; i < this.tabs.length; i++) {
if (this.tabs[i].is_active) {
return i
}
}
return null;
},
selectTab(tab: tab): void {
this.tabs.map(t => {
if (t.name === tab.name) {
t.is_active = true
} else {
t.is_active = false
}
})
router.push(tab.fullPath)
},
removeTab(index: number): void {
const activeIndex = this.getActiveTabIndex()
if (index === activeIndex) {
this.tabs = this.tabs.filter((_, idx) => idx !== index);
router.push(this.tabs[index - 1].fullPath)
} else {
const goPath = activeIndex ? this.tabs[activeIndex].fullPath : this.tabs[index - 1].fullPath
this.tabs = this.tabs.filter((_, idx) => idx !== index);
router.push(goPath)
}
},
// 右击菜单操作
// 刷新
refreshCurrentTab() {
const index = this.getActiveTabIndex()
if (index) {
router.replace({ path: this.tabs[index].fullPath });
// router.push({ path: this.tabs[index].fullPath });
}
},
// 关闭当前
removeCurrentTab() {
const index = this.getActiveTabIndex()
if (index) {
if (this.tabs[index].meta.affix) {
return
}
this.removeTab(index)
}
},
// 关闭所有
removeAllTabs() {
this.tabs = [defaultTab]
router.push('/dashboard')
},
// 关闭其他
removeOtherTabs() {
const index = this.getActiveTabIndex()
if (index) {
this.tabs = this.tabs.filter((_, idx) => idx === index || idx === 0)
}
}
},
})

View File

@@ -135,7 +135,7 @@ export const usePermissionsStore = defineStore('PermissionsStore', {
} }
const menu: Menu = Object.assign({ const menu: Menu = Object.assign({
path: this.resolveRoutePathRoutePath(permission.route, path), path: this.resolveRoutePathRoutePath(permission.route, path),
name: permission.module + '_' + permission.permission_mark, name: permission.module + '_' + permission.permission_mark + permission.route.replace('/', '_'),
component: importComponent, component: importComponent,
redirect: permission.redirect, redirect: permission.redirect,
meta: Object.assign({ title: permission.permission_name, icon: permission.icon, hidden: permission.hidden, active_menu: permission.active_menu }), meta: Object.assign({ title: permission.permission_name, icon: permission.icon, hidden: permission.hidden, active_menu: permission.active_menu }),