133 lines
3.2 KiB
Markdown
133 lines
3.2 KiB
Markdown
---
|
||
title: Nuxt UI Pro
|
||
description: Nuxt 被收购后,预计在9月发布 Nuxt UI Pro v4,并且全免费
|
||
date: 2025-07-25
|
||
img: https://lijue-me.oss-cn-chengdu.aliyuncs.com/20250723114628628.png
|
||
navigation:
|
||
icon: simple-icons:nuxtdotjs
|
||
---
|
||
|
||
Nuxt 被收购后,预计在9月发布 Nuxt UI Pro v4,并且全免费。
|
||
于是把最近在做的项目 UI 组件换成了 Nuxt UI Pro。
|
||
不过9月才免费,现在就忍不住上了组件,总不至于去缴几百美元的费用吧。
|
||

|
||
|
||
于是先绕过一些验证过程,体验一下“学习版”。
|
||
|
||
做一个 shell 脚本,在项目根目录下执行即可完成跳过。pnpm i 安装完或者更新完依赖就执行一次即可。
|
||
|
||
|
||
```bash [.shell]
|
||
# 绕过 UI Pro 的 License 验证
|
||
set -euo pipefail
|
||
# 1. 禁用 module.mjs 的调用
|
||
MODULE="node_modules/@nuxt/ui-pro/dist/module.mjs"
|
||
if [[ -f $MODULE ]]; then
|
||
sed -i.bak '/await validateLicense({.*rootDir })/s/^/\/\//; /^await validateLicense({.*rootDir })/s/^/\/\//' "$MODULE"
|
||
rm -f "$MODULE.bak"
|
||
echo "✅ module.mjs 已屏蔽"
|
||
fi
|
||
# 2. 直接“替换函数” fake 200
|
||
SHARED="node_modules/@nuxt/ui-pro/dist/shared"
|
||
JS=$(find "$SHARED" -maxdepth 1 -name 'ui-pro.*.mjs' | head -n1)
|
||
[[ -z $JS || ! -f $JS ]] && { echo "⚠️ ui-pro.*.mjs 未找到"; exit 0; }
|
||
cat <<'EOF' > tmp_func.mjs
|
||
async function validateLicense(opts) {
|
||
/* --- patched --- */
|
||
return { status: 200 }
|
||
}
|
||
EOF
|
||
sed -i.bak '/^async function validateLicense[^(]*(/,/^\}$/c\
|
||
async function validateLicense(opts) {\
|
||
/* --- patched --- */\
|
||
return { status: 200 }\
|
||
}\
|
||
' "$JS"
|
||
rm -f "$JS.bak" tmp_func.mjs
|
||
echo "✅ $JS 已 mock 完成"
|
||
echo "🎉 License ⛔ Done!"
|
||
```
|
||
|
||
### 以上脚本是自动化完成以下操作:
|
||
|
||
修改 `node_modules\@nuxt\ui-pro\dist\module.mjs`
|
||
|
||
```js
|
||
|
||
nuxt.hook("build:before", async () => {
|
||
// 注释掉这行
|
||
// await validateLicense({ key, theme: theme$1, dir: nuxt.options.rootDir });
|
||
|
||
});
|
||
```
|
||
|
||
修改 `node_modules/@nuxt/ui-pro/dist/shared/ui-pro.CsgJ05mi.mjs`
|
||
此目录下 ui-pro.xxx.mjs 名称是随机生成
|
||
```js
|
||
async function validateLicense(opts) {
|
||
|
||
//注释下方代码
|
||
// if (!opts.key) {
|
||
|
||
// throw _createError(`Missing \`${opts.theme.env}\` license key.
|
||
|
||
// Purchase Nuxt UI Pro at \`${opts.theme.link}\` to build your app in production.`);
|
||
|
||
// }
|
||
|
||
// const gitInfo = opts.key !== "oss" ? void 0 : await _getLocalGitInfo(opts.dir) || _getGitEnv();
|
||
|
||
// const projectName = gitInfo ? `${gitInfo.owner || ""}/${gitInfo.name || ""}` : await _getPkgName(opts.dir);
|
||
|
||
// try {
|
||
|
||
// await ofetch("https://api.nuxtlabs.com/ui-pro/verify", {
|
||
|
||
// headers: {
|
||
|
||
// "Authorization": `key ${opts.key}`,
|
||
|
||
// "x-nuxt-project": projectName
|
||
|
||
// },
|
||
|
||
// params: gitInfo ? {
|
||
|
||
// gitRepo: gitInfo.name,
|
||
|
||
// gitOrg: gitInfo.owner,
|
||
|
||
// gitUrl: gitInfo.url
|
||
|
||
// } : {}
|
||
|
||
// });
|
||
|
||
// } catch (error) {
|
||
|
||
// const statusType = Math.round(error.status / 100);
|
||
|
||
// if (statusType === 4) {
|
||
|
||
// throw _createError(`Invalid \`${opts.theme.env}\` license key.
|
||
|
||
// Purchase Nuxt UI Pro at \`${opts.theme.link}\` to build your app in production.`);
|
||
|
||
// }
|
||
|
||
// throw _createError("Cannot validate Nuxt UI Pro License: " + error);
|
||
|
||
// }
|
||
|
||
/手动添加返回 200 状态值
|
||
const response = {
|
||
|
||
status: 200,
|
||
|
||
};
|
||
|
||
return response;
|
||
|
||
}
|
||
```
|