Coder Social home page Coder Social logo

largezhou / admin Goto Github PK

View Code? Open in Web Editor NEW
448.0 448.0 139.0 2.28 MB

laravel + ant design vue 权限后台

Home Page: http://admin-demo.largezhou.com/admin

License: MIT License

PHP 66.41% Vue 29.03% HTML 0.11% Shell 0.18% Less 0.43% Blade 3.85%
admin laravel vue

admin's Introduction

Hi there 👋

IMG_20220811_081813

admin's People

Contributors

largezhou avatar

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

admin's Issues

报错提示

$ php artisan jwt:sectet
In ProviderRepository.php line 208:
Class 'Overtrue\LaravelLang\TranslationServiceProvider' not found

yarn serve启动后访问404

您好,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/

image

我在执行yarn run dev启动后,访问http://localhost:8080/admin-dev/如上图所示,不晓得是哪里出了问题。

  • 控制台报错

image

是因为 liveload 的链接造成的吗?有些困惑😖,希望您能帮忙解答,感谢!

创建resource的时候如果是二级控制器会出错

执行命令 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;
    }
}

上传文件接口一直报500错误

上传文件接口一直报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;
    }
}

本地 run serve的时候 请求后台域名 貌似host 问题不携带 cookie

本地 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

这个 messages 是 未定义的,是不是应该写成 message
code2

在虚拟机里面开发,在宿主机上浏览,livereload要怎么配置?

我在virtualbox的虚拟机中搭建环境来开发,但是我在本机的Chrome上调试界面

我把resources/admin/src/template/index.html中localhost改为虚拟机的地址192.168.33.10以后能加载js了,
ws://192.168.33.10:35729/livereload也能正常连接,且响应看起来是正常的

但是我本地修改任何东西刷新后还是不生效,每次都要重新yarn watch,并且刷新两次才能看到更改的内容
还有哪里需要改的么?我找了半天都没找到

权限路由问题

master 拉下来的代码, 新建用户,新建权限,角色。 新用户 还是能看到所有菜单, 只是点的时候,提示403 。能不能 没有权限的,都不显示呢 ? 我看官方的demo 是正常的不显示。

数据迁移报错! 能给一份数据库文件吗?想直接导入

`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
`

前端面包屑组件, 逻辑问题

版本

作者还未提供版本号

BUG 复现地址

复现步骤

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 了

权限的问题

如果后台有一组管理叫超级编辑 。他拥有对文章的增删改查。是不是 要单独添加个权限叫超级编辑,然后添加路劲 content/*

再有一个普通编辑 他只能对文章进行增加和编辑 要单独添加个权限普通编辑 ,路劲再添加content/add content/edit

还有一个编辑 他只有审核的权限, 再添加一个 路劲 content/audit ?

权限是这样的吗 跟菜单没关系 。权限要添加N个 这种权限好奇怪

还是我理解有问题

请问安装的流程能不能详细点啊

我用laravel new admin 然后在里面执行php artisan jwt:secret这个吗?
我执行了会报错的, There are no commands defined in the "jwt" namespace.
安装的流程能给我详细说一下吗

修改代码后不生效

修改代码后,watch是监控到修改了的,但是浏览器自动刷新后,页面并没有变化,这个问题经常出现

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.