如何跳过nuxt ui pro license 的验证

nuxt ui pro license
前端技术

直接上代码

  1. 在项目根目录下 创建 .env 文件,写入以下内容
NUXT_UI_PRO_LICENSE=test

LICENSE 随便写,主要为了骗过验证程序

  1. 删除验证的逻辑

/node_modules/@nuxt/ui-pro/modules/pro/license.ts
需要修改这个文件validateLicense方法

export async function validateLicense (opts: { key: string, dir: string, theme: { env: string, link: string } }) {
  if (!opts.key) {
    throw _createError(`Missing \`${opts.theme.env}\` license key.\nPurchase Nuxt UI Pro at \`${opts.theme.link}\` to build your app in production.`)
  }

const gitInfo = (opts.key !== 'oss') ? undefined /* privacy */ : 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 as FetchError).status as number / 100) if (statusType === 4) { throw _createError(Invalid \${opts.theme.env}` license key.\nPurchase Nuxt UI Pro at `${opts.theme.link}` to build your app in production.`) } throw _createError('Cannot validate Nuxt UI Pro License: ' + error) } }

主要删除try catch,不再抛出了异常,删除之后

export async function validateLicense (opts: { key: string, dir: string, theme: { env: string, link: string } }) {
  if (!opts.key) {
    throw _createError(`Missing \`${opts.theme.env}\` license key.\nPurchase Nuxt UI Pro at \`${opts.theme.link}\` to build your app in production.`)
  }

const gitInfo = (opts.key !== 'oss') ? undefined /* privacy */ : await _getLocalGitInfo(opts.dir) || _getGitEnv() const projectName = gitInfo ? ${gitInfo.owner || ''}/${gitInfo.name || ''} : await _getPkgName(opts.dir)

}

缺点

  1. 不能更新ui-pro,否则就会覆盖
  2. 编译发布系统,也需要坐上述操作

后文

  1. 有条件的还是支持官方购买链接,毕竟没有支持,就没有创新
bigcong