umijs/max或者node项目,用npm build生成dist文件夹,把dist文件夹传到宝塔网站wwwroot文件夹下。
宝塔安装nodejs管理器。
网站,node项目,先安装node版本,添加node项目。
项目目录:/www/wwwroot
dist是上传的文件夹名,启动命令:serve dist
项目端口:3000
保存配置,然后点新加的网站,点名称进入网站设置。
模块管理,输入serve,安装模块。
服务状态启动服务就可以访问已绑定的域名了。
umijs/max或者node项目,用npm build生成dist文件夹,把dist文件夹传到宝塔网站wwwroot文件夹下。
宝塔安装nodejs管理器。
网站,node项目,先安装node版本,添加node项目。
项目目录:/www/wwwroot
dist是上传的文件夹名,启动命令:serve dist
项目端口:3000
保存配置,然后点新加的网站,点名称进入网站设置。
模块管理,输入serve,安装模块。
服务状态启动服务就可以访问已绑定的域名了。
获取search参数,问号?后面的参数转对象。
Object.fromEntries(createSearchParams(location.search).entries())
获取projects/id/version/vid的id对象。
useParams()
pgAdmin4、PostgreSql、Sequelize无法修改Enum的Type问题
pgAdmin4的Table里只能Columne只能看到Enum的字段,但是无法修改Type。删掉重新建字段也不行。
重点:不在Table里,在Table下面有个Types,好大的坑。
include下条件查询并且允许为空
添加required: false即可。
const where = {
[Op.and]: [
s && {
[Op.or]: {
name: {
[Op.substring]: s
},
mobile: {
[Op.substring]: s
}
}
},
]
};
include: {
...(!s && {required: false}),
model: Account,
where,
attributes: ['name', 'mobile'],
},
mf-dep____vendor.80125e40.js:263462 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
Uncaught TypeError: Cannot read properties of null (reading ‘useContext’)
根因在某些复杂场景下,React 的代码被打包多份,再运行时产出了多个 React 实例。解法通过 Module Feratation 的 shared
配置来避免多实例的出现。 如果有其他依赖出现多实例的问题,可以通过类似的方式解决。
在config/config.ts文件里加mfsu的配置
mfsu: {
shared: {
react: {
singleton: true,
},
},
},
User里的type字段重命名为type,放到account同级属性下
User的attributes给一个空数组,返回数据格式则不带User的数据。
const account = await Account.findByPk(id, {
attributes: ['id', [Sequelize.col('"User"."type"'), 'type']],
include: {
model: User,
attributes: [],
},
});
重命名modal。
account的modal文件里。
Account.hasOne(models.User, {
as: 'user',
foreignKey: 'id',
sourceKey: 'userId',
});
使用,注意User改成小写user了。
attributes: ['id', 'userId', [Sequelize.col('"user"."type"'), 'type']],
include: {
model: User,
as: 'user',
attributes: [],
},
Sequelize降序排序空值在后面
order: [
['last_access_timed_at', 'DESC NULLS LAST'],
]
Sequelize升序排序空值在前面
order: [
['last_access_timed_at', 'ASC NULLS FIRST'],
]
同理DESC,ASC,FIRST,LAST自由组合。
ReactElement内使用
import { FormattedMessage } from '@umijs/max';
<FormattedMessage id="project.tunnel.label" />
函数内使用
import { useIntl } from '@umijs/max';
const AppLayout = ({ children, version }: any) => {
const intl = useIntl();
const msg = intl.formatMessage({ id: 'project.menu.draw.index' });
}
外部文件使用
import { getIntl, getLocale } from '@umijs/max';
const intl = getIntl(getLocale());
message.error(intl.formatMessage({ id: error.response.data.message}));
injectIntl还没遇到需要的地方,暂时不了解用法。
getinitialState在登陆或者注册页面时不同步currenUser
// 如果是登录页面,不执行
if (/login|register/.test(history.location.pathname))return {};
create-react-app版本过旧,用upm uninstall -g create-react-app卸载下旧版本。
还不行再用yarn global remove create-react-app再卸载下。
再用npx create-react-app my-app就好了