Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lang/enUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const enUS = {
description: 'Unlock AI, ER diagrams, bulk import/export, cross-engine migration, SSH tunnels and the MCP bridge.',
cta: 'Upgrade',
refresh: 'Refresh entitlements',
startFree: 'Start free',
versionPermanent: 'Subscribed versions are permanently usable, even offline.',
versionLockedOut: 'This release requires an active subscription to unlock. Renew to unlock it permanently.',
},
Expand Down
1 change: 1 addition & 0 deletions src/lang/zhCN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const zhCN = {
description: '解锁 AI、ER 图、批量导入导出、跨引擎迁移、SSH 隧道与 MCP bridge。',
cta: '升级',
refresh: '刷新权益',
startFree: '免费开始',
versionPermanent: '订阅期内发布的版本永久可用,支持离线。',
versionLockedOut: '当前版本需要有效订阅解锁,续订后可永久解锁。',
},
Expand Down
10 changes: 2 additions & 8 deletions src/utils/authService.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { openUrl } from '@tauri-apps/plugin-opener'

const GEEKFUN_BASE_URL = 'https://console-geekfun.wentsen.com'
const GEEKFUN_LOCAL_URL = 'http://localhost:5174'

function getGeekfunUrl(): string {
const isDev = import.meta.env.DEV
return isDev ? GEEKFUN_LOCAL_URL : GEEKFUN_BASE_URL
}

export async function openLoginUrl(): Promise<void> {
const loginUrl = `${getGeekfunUrl()}/login?source=sqlkit`
const loginUrl = `${GEEKFUN_BASE_URL}/login?source=sqlkit`
await openUrl(loginUrl)
}

export async function openRegisterUrl(): Promise<void> {
const registerUrl = `${getGeekfunUrl()}/register?source=sqlkit`
const registerUrl = `${GEEKFUN_BASE_URL}/register?source=sqlkit`
await openUrl(registerUrl)
}
36 changes: 31 additions & 5 deletions src/views/setting/plan-section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { openUpgradeDialog } from '@/components/upgrade'
import { useAccountStore } from '@/store/accountStore'
import { useDeviceStore } from '@/store/deviceStore'
import { useEntitlementStore } from '@/store/entitlementStore'
import { openLoginUrl } from '@/utils/authService'
import { openLoginUrl, openRegisterUrl } from '@/utils/authService'

const { t } = useI18n()
const entitlementStore = useEntitlementStore()
Expand All @@ -18,7 +18,8 @@ const deviceStore = useDeviceStore()
const refreshing = ref(false)

onMounted(() => {
entitlementStore.refreshEntitlement(false)
if (accountStore.isLoggedIn)
entitlementStore.refreshEntitlement(false)
})

const versionStateText = computed(() => {
Expand Down Expand Up @@ -52,6 +53,10 @@ async function handleLogin() {
await openLoginUrl()
}

async function handleStartFree() {
await openRegisterUrl()
}

// Entitlements are account-scoped: the cached view and the device lease must
// never outlive the account session on this machine.
async function handleLogout() {
Expand Down Expand Up @@ -83,18 +88,39 @@ async function handleLogout() {
<p v-if="entitlementStore.cancelScheduled" class="text-xs text-amber-600">
{{ t('plan.section.cancelScheduled') }}
</p>
<p v-if="entitlementStore.hasEntitlementError" class="text-xs text-destructive">
<p
v-if="entitlementStore.hasEntitlementError && accountStore.isLoggedIn"
class="text-xs text-destructive"
>
{{ t('plan.section.checkFailed') }}
</p>
</div>
<div class="flex gap-2 items-center">
<Button variant="outline" size="sm" :disabled="refreshing" @click="handleRefresh">
<Button
v-if="accountStore.isLoggedIn"
variant="outline"
size="sm"
:disabled="refreshing"
@click="handleRefresh"
>
<RefreshCw v-if="refreshing" class="mr-2 h-4 w-4 animate-spin" />
{{ t('plan.section.refresh') }}
</Button>
<Button v-if="!entitlementStore.isLocalUltimate" size="sm" @click="openUpgradeDialog()">
<Button
v-if="accountStore.isLoggedIn && !entitlementStore.isLocalUltimate"
size="sm"
@click="openUpgradeDialog()"
>
{{ t('plan.upgrade.cta') }}
</Button>
<template v-if="!accountStore.isLoggedIn">
<Button variant="outline" size="sm" @click="openUpgradeDialog()">
{{ t('plan.upgrade.cta') }}
</Button>
<Button size="sm" @click="handleStartFree">
{{ t('plan.upgrade.startFree') }}
</Button>
</template>
<Button
v-if="accountStore.isLoggedIn"
variant="ghost"
Expand Down
Loading