Skip to content

Commit

Permalink
设置页面增加插件版本号显示
Browse files Browse the repository at this point in the history
  • Loading branch information
lanyuanxiaoyao committed Oct 24, 2022
1 parent b4373de commit 546f43d
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 2 deletions.
17 changes: 17 additions & 0 deletions bin/build-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require('path')
const fs = require('fs')
const {execSync} = require('child_process')
const args = process.argv.slice(2)
if (args.length < 1) {
throw new Error('Need args for root path')
}
const root = args[0]
const packagePath = path.join(root, 'package.json')
const versionPath = path.join(root, 'dist', 'utils', 'versions', 'PluginVersion.js')

const content = JSON.parse(fs.readFileSync(packagePath, {encoding: 'utf-8'}))
const version = content['version']
const gitCount = execSync('git rev-list --all --count')
const pluginVersion = `${version}(${gitCount})`.replace(/\s/g, '')

fs.appendFileSync(versionPath, `exports.pluginVersion = '${pluginVersion}';\n`, {encoding: 'utf-8'})
3 changes: 3 additions & 0 deletions bin/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Write-Output $root_path

$bin_path="$root_path\bin"

# 生成版本号
node ${bin_path}\build-version.js $root_path

# 生成 icon
node $bin_path\build-icon.js $root_path

Expand Down
3 changes: 3 additions & 0 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ echo $root_path

bin_path="${root_path}/bin"

# 生成版本号
node ${bin_path}/build-version.js $root_path

# 生成 icon
node ${bin_path}/build-icon.js $root_path

Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
3.10.2
设置页面增加插件版本号显示

3.10.1
1. 增加 wps for mac 适配
2. 优化 wps for mac (International) 读取配置的逻辑
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": "utools-bookmark-and-history",
"version": "3.10.1",
"version": "3.10.2",
"author": "lanyuanxiaoyao",
"license": "MIT",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "lanyuanxiaoyao",
"homepage": "http://lanyuanxiaoyao.com",
"description": "快速查找打开书签和历史记录,支持 vscode,sublime,jetbrains(Android Studio,GoLand,IDEA,PyCharm,Webstorm等系列),WPS,Office(Word,Excel,Powerpoint),LibreOffice,Xcode,Chrome,Firefox,Safari,Edge,Opera,Brave,Yandex等主流浏览器",
"version": "3.10.1",
"version": "3.10.2",
"logo": "fox.png",
"preload": "preload.js",
"pluginSetting": {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/EnUs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ export class EnUs implements Sentence {
readonly unlimited: string = 'Unlimited'
readonly decreasePerformance: string = 'Decrease performance'
readonly decreasePerformanceDesc: string = 'The Option may \ndecrease performance'
readonly pluginVersion: string = 'Plugin Version'
}
1 change: 1 addition & 0 deletions src/i18n/ZhCn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ export class ZhCn implements Sentence {
readonly unlimited: string = '无限制'
readonly decreasePerformance: string = '影响性能'
readonly decreasePerformanceDesc: string = '该选项可能会影响插件性能,请谨慎设置'
readonly pluginVersion: string = '插件版本'
}
2 changes: 2 additions & 0 deletions src/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const sentenceKey = {
unlimited: 'unlimited',
decreasePerformance: 'decreasePerformance',
decreasePerformanceDesc: 'decreasePerformanceDesc',
pluginVersion: 'pluginVersion',
}

export interface Sentence {
Expand Down Expand Up @@ -217,6 +218,7 @@ export interface Sentence {
readonly unlimited: string
readonly decreasePerformance: string
readonly decreasePerformanceDesc: string
readonly pluginVersion: string
}

let languageData = new I18n('zh-CN', {
Expand Down
22 changes: 22 additions & 0 deletions src/setting/components/InformationCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Context} from '../../Context'
import {i18n, sentenceKey} from '../../i18n'
import {Platform} from '../../Types'
import {systemUser} from '../../Utils'
import {pluginVersion} from '../../utils/versions/PluginVersion'

const platformName: (Platform) => string = platform => {
if (platform == Platform.win32) {
Expand All @@ -25,6 +26,7 @@ export interface InformationCardState {
avatar: string
username: string
version: string
pluginVersion: string
systemUser: string
nativeId: string
}
Expand All @@ -37,6 +39,7 @@ export class InformationCard extends Component<InformationCardProps, Information
avatar: utools.getUser()?.avatar ?? 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAMAAADVRocKAAAAQlBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACO4fbyAAAAFXRSTlMACOHTj+9DaxMoHXNWTbC8ncY7gTBQQCg8AAACc0lEQVRo3u2Z3XK0IAyGSyAIImjXzf3f6nf27bQbeUGcTjvjcxxD/gwQPm5ubpoJfnKrJRZhsqubfLhQucnOyhvWZXOJ+sfGckTJw8ZPJFVoMiPqEwmE0uklMkkTtJxSPxdppswnzGfpgHudME462boyET6lm8/QEX4rJ7DNiYh0oMH5aEz0zooKxUb7SVfvXyIPPYTU5EPQ7Zu+Sk26EQ15MKpx7L/LeVYzjWvJiYZXmqBoOKR/AfGBUVpAglXHrS6sJovriS44QC+8aJRqAxLkAHZBcqWCCCcOFwQdV1ISHCEcI0mdDkg87CnS58IkOubQItGZDuTpqgUIRPRciHDWNiDeYdKm+suigMpUhw34yTp+NJ0MzDnRKrDTVoALg18EUQDtukLA/uINp4bH9uAts8YEcty96eMsr/ICHlu8FcAKSqL74IXLiGQI3O9YLoXfFpCL+ekFrg/RzyfZyqVY8KMNs4JWMYwDzW6YCbTrYbyy4VTh1aXlOQdjwvxckltBWYeeDZC2Jb7Lx2UjXEQ4yzbFyoU3WZBjcGxhB6++T6cFKzcdvDiZk1MlVj/cKurREqwcHUGhrnPXcOlrI3jg47sbmf9YfAHZP7rZ8QXEUOUqiin4Fpj+i4R+/YHAJRC40OuAThZoBfReMjADDDXgEKW0DkOWc/p5RpJgheGv3ImfLenf4JFaaWt2pTJSA0NB67G8p8pQEI81C/gkbGCsCQezvIeK+p3xYBaPlo+2tejAaLl9OG73+KZ9t2A4Dtq7cm5ZHnE2Zo6PRTm1OPO7HiiGnliufyTKv/WZ67qHOnx00+HN/4XH0sPn3pubm1b+AbmqIcRUyWtIAAAAAElFTkSuQmCC',
username: utools.getUser()?.nickname ?? 'Unknown User',
version: utools.getAppVersion(),
pluginVersion: pluginVersion,
systemUser: systemUser(),
nativeId: utools.getNativeId(),
}
Expand Down Expand Up @@ -79,6 +82,25 @@ export class InformationCard extends Component<InformationCardProps, Information
/>
</div>
</div>
<div class="form-group">
<div class="col-3 col-sm-12">
<label
class="form-label label-sm"
for="plugin-version"
>
{i18n.t(sentenceKey.pluginVersion)}
</label>
</div>
<div class="col-9 col-sm-12">
<input
class="form-input input-sm"
type="text"
id="plugin-version"
value={this.state.pluginVersion}
readonly
/>
</div>
</div>
<div class="form-group">
<div class="col-3 col-sm-12">
<label
Expand Down
1 change: 1 addition & 0 deletions src/utils/versions/PluginVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const pluginVersion = '0.0.0'

0 comments on commit 546f43d

Please sign in to comment.