Nest JS 权限控制 rabc 0 的一种实现文章更多的是在于记录。有看不懂的评论
2.1 RBAC 0 https://juejin.cn/post/6844904109863075853#heading-3
最简单的用户、角色、权限模型。这里面又包含了2种:
用户和角色是多对一关系,即:一个用户只充当一种角色,一种角色可以有多个用户担当。
用户和角色是多对多关系,即:一个用户可同时充当多种角色,一种角色可以有多个用户担当。
jwt依赖包
@nestjs/jwt passport-jwt
构建 jwt 策略
这是用来对 token 进行处理的。他会在 request
jwt.strategy.ts
12345678import { Injectable } from '@nestjs/common';import { ConfigService } from '@nestjs/config';import { PassportStrategy } from '@n ...
Vue defineReactive核心原理
123456789101112function defineReactive(target, key, value) { Object.defineProperty(target, key, { get() { console.log('getter key = ', key) return value }, set(newV) { console.log(`setter ${key} = ${value}`) if (newV === value) return value = newV return value } })}
对于数组和对象有不同的处理方式, 外面套一层
1234567891011function Observer(value) { if (Array.isArray(value)) ...
Vue-Challenges2. ref 全家桶https://github.com/webfansplz/vuejs-challenges/blob/main/questions/2-ref-family/README.zh-CN.md
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061<script setup lang="ts">import { ref, Ref, reactive, isRef, unref, toRef } from "vue"const initial = ref(10)const count = ref(0)// Challenge 1: Update reffunction update(value) { count.value = value}/** * Challenge 2: Ch ...
Web: 一个跨页面动画的 API我目前知道的跨页面动画需要用到 JS。通过 FLIP思想来做。
现在看到了一个新的 API。copy 过来给大家看看https://developer.chrome.com/docs/web-platform/view-transitions/#api-reference
Smooth and simple transitions with the View Transitions API
Published on Tuesday, August 17, 2021 • Updated on Tuesday, November22, 2022
Jake Archibald Jake Archibald Human boy working on web standards atGoogle
Website Twitter This feature was previously called “Shared ElementTransitions”, and is sometimes referred to as “page transitions”.
The ...
class-transform 执行两次 debug没有什么技术含量, 只是记录一下过程。
具体问题在这里
[nestjs
class-transfrom @Transform execute twice and return null -Stack Overflow](https://stackoverflow.com/questions/75673361/class-transfrom-transform-execute-twice-and-return-null)
1. vscode debug
在这里打一个断点, vscode attach端口。请求对应接口。 vscode会自动中断于断点处
调试
查看调用堆栈。 发现被调用了两次 class-transfrom。 第二次调用的时候是nest 调用的, 但是nest 并没有依赖class-transfrom。所以就想到了是不是做了一层全局的序列化。 到main.ts里面找到了相关代码。 去掉全局序列化就行了。
1app.useGlobalInterceptors(new ClassSerializerInterceptor ...
element scrollBar 使用项目架构
1{ "dependencies": { "element-ui": "^2.4.5", "vue": "^2.6.11", }, "devDependencies": { "@vue/cli-plugin-typescript": "^4.5.0", "typescript": "~3.9.3", }}
定义 ScrollBar组件的 .d.ts123456import type { ElementUIComponent } from 'element-ui/types/component';declare class ElScrollbar extends ElementUIComponent & ...
eslinteslint-plugin-import 排序配置这是官方的排序配置的文档
eslint-plugin-import/order.mdat main · import-js/eslint-plugin-import · GitHub
我自己配置的时候注意到一个点
Withthe [groups](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md#groups-array) optionsetto ["builtin", "external", "internal", "parent", "sibling", "index", "object", "type"] theorder is as shown in the following example:
一个是groups 的 type 类 ...
linux自定义命令我在服务器上运行的,centos 8
首先 cd ~/.bashrc
如果你使用cd ~, 发现里面没有任何一个文件, 不用担心,因为里面的文件都是隐藏文件, 在 cd ~的前提下输入ll -a就可以看到当前文件夹下的隐藏文件。
然后编辑这个文件vim ~/.bashrc
在我的服务器里面已经存在这些命令
123alias rm='rm -i'alias cp='cp -i'alias mv='mv -i'
alias表示定义mv表示自定义的名字,等号后面的就是执行的命令
现在我想创建一个dp命令用来部署vue项目。
于是可以这样编写
1alias dp='cd / && cd www && cd $1 && git pull && npm install && npm run build'
其中, dp是我自定义的名字,等号后面就是我要执行的命令,我一般会把项目放在www下面,在这里,你可以看到有这样一 ...
localStorage设置过期时间需要些什么
数据
过期时间
1{ "data": "any", "expire": "Date"}
如何判断过期时间比较存的时间与Date.now
还需要些什么刷新时间, 时间过期处理
完整代码123456789101112131415const oneHour = 1 * 60 * 60 * 1000export function expireSet(key: string, data: any, expireTime = 1) { const obj = { value: data, expire: expireTime * oneHour + Date.now(), hour: expireTime, } localStorage.setItem(key, JSON.stringify(obj))}export function expireGet(key: string) ...


