Skip to content

Commit

Permalink
Merge branch 'release/3.62.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
purocean committed Oct 8, 2023
2 parents eb12d89 + 0aecf31 commit 46096a6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ For more information on how to use the following functions, please see [characte

## Changelogs

### [v3.62.1](https://github.com/purocean/yn/releases/tag/v3.62.1) 2023-10-08
### [v3.62.2](https://github.com/purocean/yn/releases/tag/v3.62.2) 2023-10-08

[Windows](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-win-x64-3.62.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-arm64-3.62.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-x64-3.62.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-x86_64-3.62.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-amd64-3.62.1.deb)
[Windows](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-win-x64-3.62.2.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-arm64-3.62.2.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-x64-3.62.2.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-x86_64-3.62.2.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-amd64-3.62.2.deb)

1. feat: sidebar document outline supports folding and expansion
2. feat: supports offline activation of premium version
Expand Down
4 changes: 2 additions & 2 deletions README_ZH-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@

## 更新日志

### [v3.62.1](https://github.com/purocean/yn/releases/tag/v3.62.1) 2023-10-08
### [v3.62.2](https://github.com/purocean/yn/releases/tag/v3.62.2) 2023-10-08

[Windows](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-win-x64-3.62.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-arm64-3.62.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-mac-x64-3.62.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-x86_64-3.62.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.1/Yank-Note-linux-amd64-3.62.1.deb)
[Windows](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-win-x64-3.62.2.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-arm64-3.62.2.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-mac-x64-3.62.2.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-x86_64-3.62.2.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.62.2/Yank-Note-linux-amd64-3.62.2.deb)

1. feat: 侧栏文档大纲支持折叠展开
2. feat: 支持离线激活高级版
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yank.note",
"version": "3.62.1",
"version": "3.62.2",
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
"main": "dist/main/app.js",
"license": "AGPL-3.0",
Expand Down
10 changes: 9 additions & 1 deletion src/main/server/premium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppLicenseClient } from 'app-license'
import { AppLicenseClient, decodeDevice } from 'app-license'
import request from 'request'
import { API_BASE_URL, PREMIUM_PUBLIC_KEY } from '../../share/misc'
import { getAction } from '../action'
Expand Down Expand Up @@ -65,6 +65,14 @@ export function upgradeLicense (payload: {oldLicense: string, locale: string}) {
return fetchApi('/upgrade-license', payload)
}

export async function checkDevice (payload: { device: string }) {
const device = decodeDevice(await genDeviceString())
const _device = decodeDevice(payload.device)
if (device.id !== _device.id || device.platform !== _device.platform) {
throw new Error('INVALID_LICENSE')
}
}

export function genDeviceString () {
return client.genDeviceString()
}
6 changes: 4 additions & 2 deletions src/renderer/components/Premium.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</div>
<div class="offline-input-wrapper">
<input readonly :value="machineCode" />
<button class="primary small input-copy-btn" @click="copyMachineCode">Copy</button>
<button v-if="machineCode" class="primary small input-copy-btn" @click="copyMachineCode">Copy</button>
</div>
<div class="code-label">
Activation Token
Expand Down Expand Up @@ -226,7 +226,8 @@ export default defineComponent({
devices.value = data.map(x => {
const item = decodeDevice(x)
const isCurrent = token.device === x
const device = decodeDevice(token.device)
const isCurrent = device.id === item.id && device.platform === item.platform
return {
isCurrent,
label: `[${item.platform}] ${item.hostname} ` +
Expand Down Expand Up @@ -368,6 +369,7 @@ export default defineComponent({
watch(tab, () => {
offline.value = false
activationToken.value = ''
})
watchEffect(async () => {
Expand Down
24 changes: 18 additions & 6 deletions src/renderer/others/premium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Payload = {
addDevice: { licenseId: string }
fetchDevices: { licenseId: string }
upgradeLicense: { oldLicense: string, locale: string }
checkDevice: { device: string }
genDeviceString: {},
}

Expand Down Expand Up @@ -142,7 +143,7 @@ export function showPremium (tab?: PremiumTab) {
ga.logEvent('yn_premium_show', { purchased: getPurchased() })
}

export function getLicenseToken (throwError = false) {
export function getLicenseToken () {
logger.debug('getLicenseToken')
try {
const tokenStr = getSetting('license')
Expand All @@ -167,10 +168,6 @@ export function getLicenseToken (throwError = false) {

return syncCacheLicenseToken(token)
} catch (error) {
if (throwError) {
throw error
}

logger.error('getLicenseToken', error)
}

Expand Down Expand Up @@ -217,11 +214,21 @@ async function setLicense (licenseId: string) {
}
}

async function checkDevice (device: string) {
try {
await requestApi('checkDevice', { device })
} catch (error) {
cleanLicense()
throw error
}
}

export async function refreshLicense (opts?: { throwError?: boolean }) {
logger.debug('refreshLicense', opts)
try {
const token = getLicenseToken()
if (token) {
await checkDevice(token.device)
await setLicense(token.licenseId)
}
} catch (error) {
Expand All @@ -242,7 +249,12 @@ export async function activateLicense (licenseId: string) {
export async function activateByTokenString (tokenString: string) {
logger.debug('activateByToken', tokenString)
await setSetting('license', tokenPrefix + tokenString)
getLicenseToken(true)
const token = getLicenseToken()
if (token) {
await checkDevice(token.device)
} else {
throw new Error('INVALID_LICENSE')
}
}

function checkLicenseStatus () {
Expand Down

1 comment on commit 46096a6

@vercel
Copy link

@vercel vercel bot commented on 46096a6 Oct 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

yn-api-doc – ./

yn-api-doc-git-master-purocean.vercel.app
yn-api-doc-purocean.vercel.app
yn-api-doc.vercel.app

Please sign in to comment.