admin.net

5 篇文章 6 订阅
5 篇文章 0 订阅

前端代码




权限设置

  • 在后台增加按钮权限,设置不重复的常量
  • 菜单可见不可见由Admin.net的权限系统控制
  • 按钮与部分界面可视性控制:
    另似下面的代码:

    <x-card v-if="hasPerm('sysTenant:page')">
    
  • 按钮权限控制

    if (this.hasPerm('sysTenant:edit') || this.hasPerm('sysTenant:delete')) {
    //dosth.
    }
    
  • 点击按钮出现:“403 禁止访问,没有权限” 的问题解决
    产生错误的原因:Action的路由要与按钮权限配置时要对应上,如:
    按钮权限代码写着: Test:page
    对应的action的路由应该为:/Test/page




查询、列表、增加、修改、删除

  • 查询与重置
    //查询代码
    <a-button type="primary" @click="$ref.table.refresh(true)">查询</a-button>
    
    //重置代码
    <a-button type="primary" @click="()=>queryParm = {}">重置</button>
    
  • 前台刷新
    this.$refs.table.refresh() //刷新
    this.$refs.table.refresh(true) //强制刷新到第一页




前端获取用户等信息的方法

  • 方法一:使用this.$store.state.[modules名字].状态名
    如:

    this.$store.state.app.crumbsState
    this.$store.state.user.token
    

    可以用的状态名:

      token: '',
      name: '',
      welcome: '',
      avatar: '',
      buttons: [], // 按钮权限
      admintype: '', // 是否是超管
      roles: [],
      info: {}
    
  • 方法二:使用getter方法
    如:

    this.$store.getters.userInfo
    

    getter公布出来的属性:

const getters = {
  device: state => state.app.device,
  theme: state => state.app.theme,
  color: state => state.app.color,
  token: state => state.user.token,
  avatar: state => state.user.avatar,
  nickname: state => state.user.name,
  welcome: state => state.user.welcome,
  roles: state => state.user.roles,
  buttons: state => state.user.buttons,
  admintype: state => state.user.admintype,
  userInfo: state => state.user.info,
  addRouters: state => state.permission.addRouters,
  multiTab: state => state.app.multiTab,
  lang: state => state.i18n.lang
}

export default getters




怎么复制?

vue 使用clipboard实现复制功能




前端验证码在linux下显示不出来或者不全的坑

这里有两个问题,按下面链接解决:
.NET Core 图片操作在 Linux/Docker 下的坑 - 晓晨Master - 博客园
.net core在linux下图片中文乱码 - 没有星星的夏季 - 博客园




前端nginx发布所碰到的坑

大部分在nginx配置这里,正确的配置如下:

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;
    root   /usr/share/nginx/html;
    index index.html index.htm;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

  location /api {
    proxy_set_header Host $http_host;
    proxy_set_header  X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    rewrite ^/api/(.*)$ /$1 break;
    proxy_pass http://172.17.0.11;
  }

    location /hubs/ {
    proxy_pass http://172.17.0.11;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
  }

关于SignalR配置,还需要配置两个变量:

http {
    map $http_upgrade $connection_upgrade {
       default          keep-alive;
       'websocket'      upgrade;
    }
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}




后端代码




获取用户数据的密秘:

— 通过静态变量App可以得到众多的用户需要的信息:
使用步骤:

  1. var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
    ClaimConst常量如下:

    public class ClaimConst
    {
        /// <summary>
        /// 用户Id
        /// </summary>
        public const string CLAINM_USERID = "UserId";
    
        /// <summary>
        /// 账号
        /// </summary>
        public const string CLAINM_ACCOUNT = "Account";
    
        /// <summary>
        /// 名称
        /// </summary>
        public const string CLAINM_NAME = "Name";
    
        /// <summary>
        /// 是否超级管理
        /// </summary>
        public const string CLAINM_SUPERADMIN = "SuperAdmin";
    
        /// <summary>
        /// 租户Id
        /// </summary>
        public const string TENANT_ID = "TenantId";
    }
    




记录常见错误

  • 后端id号经常变化的问题
    解决办法:由于furion默认的id号是long,而我设置成int,所以导致转换时精度变化;

  • SignalR的后台dotnet run下的出错:

    [2021-08-17T18:19:58.533Z] Information: Normalizing '/hubs/chathub' to 'http://localhost:81/hubs/chathub'.
    [2021-08-17T18:19:59.051Z] Error: Failed to start the connection: Error: There was an error with the transport.
    

    错误表现:在IIS express下没有错误,而在dotnet run下有错误;
    错误原因:dotnet run下使用的web服务器为:kestrel,与iis express不一样,只需要将kestrel服务配置改正确就好;
    错误办法:将Admin.NET.Web.Entry项目的launchSettings.json的Admin.NET.Web.Entry—>applicationUrl—》修改成:”applicationUrl”: “http://localhost:8899




几个重要的议题

1、如何用界面生成器;
—》可以自动生成界面代码,拷贝就可以使用,但是好象只能生成k-form-build代码,不能生成ant-dv控件;

2、如何上传文件;
3、菜单的其他用法;

4、signalR前后端;

5、前端、后端代码的精华及Furion的精通;

 2021-10-14

.env、.env.preview、.env.development、.env.production的使用

  • 各文件使用环境:
    .env: 不管如何,定义的变量都会存在,但是会被不同环境的变量所覆盖;
    .env.preview: 预览环境
    .env.development: 开发环境
    .env.production: 生产环境
  • 不用手工指定,系统根据运行的命令来自动选择配置文件.
  • 特别注意:文件里面的变量命名一定要以:VUEAPP开头 ,这种变量命名方式才能被读到。
  • 文件里面定义的变量都是全局的;
  • 使用方式:
    process.env.NODE_ENV
    


栅格布局

如下图所示:

注意:

  • Ant Design 采用 24 栅格体系。对内容区域进行 24 栅格的划分;
  • Gutter:间隔值,固定不变,一般为8的倍数;
  • 一栅格 = 1列 = 1column+1gutter,总共分为24列,其实是:23列+1column
  • 1列 = 1column+1gutter
  • 浏览器在一定范围扩大或缩小,栅格的 Column 宽度会随之扩大或缩小,但 Gutter 的宽度值固定不变,不管浏览器怎么变,gutter的值是不变化的,而column宽度会变化,但是总共列为24列。
  • :span 跨度多少栅格,即多少列;
  • :offset 偏移位置,一个位置一栅格,从左面开始计算;

  • 响应式布局
    xs < 768px
    sm ≥768px
    md ≥992
    lg ≥1200

  • 一个好资料
    不懂栅格系统,页面元素和区域间距很难统一 - 知乎

错误:TypeError: Cannot read property ‘validateFields’ of undefined

写成:

      const {
        from: { validateFields }
      } = this

枚举定义 

默认实体可以用枚举字段,但是传参查询用int或者string

原文: ShowDoc一个非常适合IT团队的在线API文档、技术文档工具。你可以使用Showdoc来编写在线API文档、技术文档、数据字典、在线手册https://www.showdoc.com.cn/p/8fb957fe518e10dceb0864df2ed65f8e

ShowDoc  https://www.showdoc.com.cn/p/a7fc4495f88a1219cbe548f91ac60484 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值