largezhou / admin Goto Github PK
View Code? Open in Web Editor NEWlaravel + ant design vue 权限后台
Home Page: http://admin-demo.largezhou.com/admin
License: MIT License
laravel + ant design vue 权限后台
Home Page: http://admin-demo.largezhou.com/admin
License: MIT License
执行命令 php artisan admin:make-resource phone\Group
创建出来的控制器和model filter request 的父级都是有错误,目前我这边的解决方案是 在每个stub文件内手动定义父级
创建出来的vue文件也未能支持二级 目前我这边做了对应的解决方案 您这边可以看下 ,目前我是这样临时做解决的 项目很棒哦 大佬
里面我的todo 都有写 大佬看看吧
<?php
namespace App\Admin\Console\Commands;
use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;
class ResourceMakeCommand extends GeneratorCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = '
admin:make-resource
{name : 短横式命名的资源名称}
{--force : 覆盖已存在文件}
{--model= : 指定模型}
{--test : 生成控制器测试类}
';
/**
* The console command description.
*
* @var string
*/
protected $description = '添加一个资源,包含各种相关文件';
protected $types = [
'model', 'filter', 'request', 'resource', 'controller', 'test',
];
/**
* 当前正在生成的类型
*
* @var string
*/
protected $nowType;
/**
* 各类型对应的完整的类名
*
* @var array
*/
protected $classes = [];
protected $frontendTypePathMap = [
'api' => 'api/dummy-resources.js',
'index' => 'views/dummy-resources/Index.vue',
'form' => 'views/dummy-resources/Form.vue',
];
/**
* Execute the console command.
*/
public function handle()
{
if (!$res = $this->makeBackend()) {
return $res;
}
return $this->makeFrontend();
}
protected function makeBackend()
{
foreach ($this->types as $type) {
$this->nowType = $type;
$this->type = Str::ucfirst($type);
if (($type == 'model') && ($model = $this->option('model'))) {
if (!class_exists($model)) {
$this->error("模型 [ {$model} ] 不存在");
return 0;
} elseif (class_exists($model)) {
$this->classes[$type] = trim($model, '\\');
continue;
}
}
if (($type == 'test') && (!$this->option('test'))) {
continue;
}
if (parent::handle() === false) {
return 0;
}
$this->classes[$type] = $this->qualifyClass($this->getNameInput());
}
return 1;
}
protected function getStub()
{
return __DIR__ . "/stubs/{$this->nowType}.stub";
}
protected function getNameInput()
{
$name = Str::studly(trim($this->argument('name')));
if ($this->nowType == 'test') {
$name = 'Feature\\' . $name . 'ControllerTest';
} elseif ($this->nowType != 'model') {
$name .= $this->type;
}
return $name;
}
protected function rootNamespace()
{
return 'App\\Admin\\' . Str::ucfirst(Str::plural($this->nowType));
}
protected function getPath($name)
{
$name = Str::replaceFirst($this->rootNamespace(), '', $name);
return $this->laravel['path'] .
'/Admin/' .
Str::ucfirst(Str::plural($this->type)) .
str_replace('\\', '/', $name) . '.php';
}
protected function replaceClass($stub, $name)
{
$stub = parent::replaceClass($stub, $name);
if ($this->nowType == 'test') {
$stub = str_replace('NamespacedDummyModel', $this->classes['model'], $stub);
$stub = str_replace('dummy-resource-name', Str::plural($this->argument('name')), $stub);
} elseif ($this->nowType == 'controller') {
foreach (['filter', 'request', 'resource', 'model'] as $type) {
$stub = $this->replaceDummyResource($type, $stub);
}
}
return $stub;
}
protected function replaceDummyResource(string $type, string $stub): string
{
$namespaced = $this->classes[$type];
$class = class_basename($namespaced);
$type = Str::ucfirst($type);
$stub = str_replace("NamespacedDummy{$type}", $namespaced, $stub);
$stub = str_replace("Dummy{$type}", $class, $stub);
if ($type == 'Model') {
$model = '$' . Str::camel($class);
$models = Str::plural($model);
$stub = str_replace('$dummyModel', $model, $stub);
$stub = str_replace('$dummyModels', $models, $stub);
}
return $stub;
}
protected function makeFrontend()
{
//todo 修正做出来临时名称 begin
$name = str_replace('\\', '/', trim($this->argument('name')));
$tmp = explode('/', $name);
//todo 制作临时变量 end
$dummyResource = Str::camel($name);
$ucDummyResource = Str::ucfirst($dummyResource);
$pluralDummyResource = Str::plural($dummyResource);
$ucPluralDummyResource = Str::ucfirst($pluralDummyResource);
reset($tmp);
//todo 兼容vue内文件
$pluralKebabDummyResource = Str::plural(current($tmp) . '/' . strtolower(end($tmp)));
//todo 修正文件
$replaces = [
'PluralDummyResource' => ucfirst(end($tmp)),
'dummy-resources' => $pluralKebabDummyResource,
'DummyResource' => ucfirst(end($tmp)),
'dummyResources' => ucfirst(end($tmp)),
];
foreach (['api', 'index', 'form', 'routes'] as $type) {
$content = $this->files->get(__DIR__ . "/stubs/frontend/{$type}.stub");
foreach ($replaces as $search => $replace) {
$content = str_replace($search, $replace, $content);
}
if ($type == 'routes') {
$this->info('路由配置:');
$this->line($content);
} else {
$relativePath = str_replace('dummy-resources', $pluralKebabDummyResource, $this->frontendTypePathMap[$type]);
$path = $this->laravel['path.resources'] . '/admin/src/' . $relativePath;
if (
!$this->option('force') &&
$this->files->exists($path)
) {
$this->error($relativePath . ' 已存在');
return 0;
}
$this->makeDirectory($path);
$this->files->put($path, $content);
$this->info($relativePath . ' 创建成功');
}
}
return 1;
}
}
focusWhenError(e) {
if (e?.response.status !== 422) {
return
}
}
上传文件接口一直报500错误,配置的nginx按照文档来的。只是前端是用的yarn run watch
nginx配置
server {
listen 80;
server_name xxx.com;
root /xxx/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
error_log /usr/local/etc/nginx/logs/xx_error.log;
access_log /usr/local/etc/nginx/logs/xx_access.log;
index index.php index.html;
charset utf-8;
# yarn dev 或者 yarn watch 之后的路径
location /admin-dev/ {
try_files $uri $uri/ /admin-dev/index.html;
}
location /admin/ {
try_files $uri $uri/ /admin/index.html;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
$ php artisan jwt:sectet
In ProviderRepository.php line 208:
Class 'Overtrue\LaravelLang\TranslationServiceProvider' not found
作者还未提供版本号
无
let matchedRouter = [
{
id: "a",
title: "a-分类",
path: "/a/"
},
{
id: "b",
title: "a-b分类",
path: "/a/b/"
}
];
this.$store.commit("SET_MATCHED_MENUS_CHAIN", matchedRouter);
使用 SET_MATCHED_MENUS_CHAIN
mutation 更新面包屑, 达到手动更新面包屑效果(自定义面包屑)
27 行, 与 41 行代码执行时会操作同一个 Array(引用对象),
即使赋值给了变量m
, 但是实际操作的还是matchedMenusChain
,
导致, 添加首页后, computed 又进行了一次重新的计算
解决方法也比较简单 解构下就行
[...this.matchedMenusChain];
为何不提交 fork?, 写个 issue 吧, 懒得再提交个 fork 了
修改代码后,watch是监控到修改了的,但是浏览器自动刷新后,页面并没有变化,这个问题经常出现
近期有个项目需要用的ant design + laravel ,所以找到这个框架,很接近需求,请问如何引入ant design pro vue 的组件和风格呢?项目已经开始开发,刚看到你更新了代码,请帮助,谢谢拉。
留下联系方式详谈
我在virtualbox的虚拟机中搭建环境来开发,但是我在本机的Chrome上调试界面
我把resources/admin/src/template/index.html中localhost改为虚拟机的地址192.168.33.10以后能加载js了,
ws://192.168.33.10:35729/livereload也能正常连接,且响应看起来是正常的
但是我本地修改任何东西刷新后还是不生效,每次都要重新yarn watch,并且刷新两次才能看到更改的内容
还有哪里需要改的么?我找了半天都没找到
本地 run serve 启动 vue 登录有个提示 messages 未定义
很奇怪 不过此处很好解决 改一些utils 就好
export const getMessage = key => {
/* eslint-disable no-undef */
// return messages[key] || messages.default ide 都可以追到 messages 这个变量 但console提示找不到
console.log(key)
return key
}
调整完毕以后
请求后台接口 时貌似因为前段域名 localhost , 接口域名 xxx.com 就没有携带cookie 就一直401 走不通了 ,不能本地调试 那开发就太费劲了
{
code:
data:
message:
}
有没有接口文档
你好, 有没有计划实现tagView?
`D:\www\admin>php artisan migrate
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter tab
le users
add unique users_email_unique
(email
))
at D:\www\admin\vendor\laravel\framework\src\Illuminate\Database\Connection.php:665
`
master 拉下来的代码, 新建用户,新建权限,角色。 新用户 还是能看到所有菜单, 只是点的时候,提示403 。能不能 没有权限的,都不显示呢 ? 我看官方的demo 是正常的不显示。
我是用 yarn watch 在本地环境开发,然后修改完代码以后页面这时候会自动刷新。然后页面就会 404,这时候就又要充 admin-dev/ 点击菜单进去了。感觉这样好麻烦,请问你是怎么解决的呢。
如果后台有一组管理叫超级编辑 。他拥有对文章的增删改查。是不是 要单独添加个权限叫超级编辑,然后添加路劲 content/*
再有一个普通编辑 他只能对文章进行增加和编辑 要单独添加个权限普通编辑 ,路劲再添加content/add content/edit
还有一个编辑 他只有审核的权限, 再添加一个 路劲 content/audit ?
权限是这样的吗 跟菜单没关系 。权限要添加N个 这种权限好奇怪
还是我理解有问题
我用laravel new admin 然后在里面执行php artisan jwt:secret这个吗?
我执行了会报错的, There are no commands defined in the "jwt" namespace.
安装的流程能给我详细说一下吗
您好,largezhou!
$ yarn run dev
DONE Compiled successfully in 421ms 6:14:57 AM
App running at:
- Local: http://localhost:8080/admin-dev/
It seems you are running Vue CLI inside a container.
Since you are using a non-root publicPath, the hot-reload socket
will not be able to infer the correct URL to connect. You should
explicitly specify the URL via devServer.public.
Access the dev server via http://localhost:<your container's external mapped port>/admin-dev/
我在执行
yarn run dev
启动后,访问http://localhost:8080/admin-dev/
如上图所示,不晓得是哪里出了问题。
是因为 liveload 的链接造成的吗?有些困惑😖,希望您能帮忙解答,感谢!
�
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.