mirror of
https://github.com/kokonect-link/cherrypick
synced 2025-01-24 10:43:58 +09:00
enhance(frontend): CherryPick 클라이언트 업데이트 확인 방식 변경
- `compare-versions` 라이브러리 이용
This commit is contained in:
parent
a6d8a20b50
commit
4edca7bd32
@ -34,6 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { onActivated, onMounted, onUnmounted, provide, watch, ref, computed } from 'vue';
|
import { onActivated, onMounted, onUnmounted, provide, watch, ref, computed } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import MkSuperMenu from '@/components/MkSuperMenu.vue';
|
import MkSuperMenu from '@/components/MkSuperMenu.vue';
|
||||||
import MkInfo from '@/components/MkInfo.vue';
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
@ -290,20 +291,6 @@ provideMetadataReceiver((metadataGetter) => {
|
|||||||
});
|
});
|
||||||
provideReactiveMetadata(INFO);
|
provideReactiveMetadata(INFO);
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function invite() {
|
function invite() {
|
||||||
misskeyApi('admin/invite/create').then(x => {
|
misskeyApi('admin/invite/create').then(x => {
|
||||||
os.alert({
|
os.alert({
|
||||||
|
@ -70,6 +70,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { version, instanceName, basedMisskeyVersion } from '@@/js/config.js';
|
import { version, instanceName, basedMisskeyVersion } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import FormInfo from '@/components/MkInfo.vue';
|
import FormInfo from '@/components/MkInfo.vue';
|
||||||
@ -121,53 +122,6 @@ async function init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const parseVersion = (version: string) => {
|
|
||||||
const [main, pre] = version.split('-');
|
|
||||||
const parts = main.split('.').map(num => parseInt(num, 10));
|
|
||||||
return { parts, pre: pre || null };
|
|
||||||
};
|
|
||||||
|
|
||||||
const compareArrays = (a: number[], b: number[]) => {
|
|
||||||
const maxLength = Math.max(a.length, b.length);
|
|
||||||
for (let i = 0; i < maxLength; i++) {
|
|
||||||
const part1 = a[i] || 0;
|
|
||||||
const part2 = b[i] || 0;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
const v1Parsed = parseVersion(v1);
|
|
||||||
const v2Parsed = parseVersion(v2);
|
|
||||||
|
|
||||||
const mainComparison = compareArrays(v1Parsed.parts, v2Parsed.parts);
|
|
||||||
if (mainComparison !== 0) {
|
|
||||||
return mainComparison;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v1Parsed.pre && !v2Parsed.pre) return -1;
|
|
||||||
if (!v1Parsed.pre && v2Parsed.pre) return 1;
|
|
||||||
|
|
||||||
if (v1Parsed.pre && v2Parsed.pre) {
|
|
||||||
const preOrder = ['alpha', 'beta', 'rc'];
|
|
||||||
const [pre1] = v1Parsed.pre.split('.');
|
|
||||||
const [pre2] = v2Parsed.pre.split('.');
|
|
||||||
|
|
||||||
const index1 = preOrder.indexOf(pre1);
|
|
||||||
const index2 = preOrder.indexOf(pre2);
|
|
||||||
|
|
||||||
if (index1 !== index2) {
|
|
||||||
return index1 - index2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return v1Parsed.pre.localeCompare(v2Parsed.pre);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
os.apiWithDialog('admin/update-meta', {
|
os.apiWithDialog('admin/update-meta', {
|
||||||
enableReceivePrerelease: enableReceivePrerelease.value,
|
enableReceivePrerelease: enableReceivePrerelease.value,
|
||||||
|
@ -56,6 +56,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue';
|
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { openInstanceMenu } from './common.js';
|
import { openInstanceMenu } from './common.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { navbarItemDef } from '@/navbar.js';
|
import { navbarItemDef } from '@/navbar.js';
|
||||||
@ -109,20 +110,6 @@ function toggleBannerDisplay() {
|
|||||||
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openAccountMenu(ev: MouseEvent) {
|
function openAccountMenu(ev: MouseEvent) {
|
||||||
openAccountMenu_({
|
openAccountMenu_({
|
||||||
withExtraOperation: true,
|
withExtraOperation: true,
|
||||||
|
@ -81,6 +81,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, ref, watch } from 'vue';
|
import { computed, defineAsyncComponent, ref, watch } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { openInstanceMenu } from './common.js';
|
import { openInstanceMenu } from './common.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { navbarItemDef } from '@/navbar.js';
|
import { navbarItemDef } from '@/navbar.js';
|
||||||
@ -154,20 +155,6 @@ function toggleBannerDisplay() {
|
|||||||
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openAccountMenu(ev: MouseEvent) {
|
function openAccountMenu(ev: MouseEvent) {
|
||||||
openAccountMenu_({
|
openAccountMenu_({
|
||||||
withExtraOperation: true,
|
withExtraOperation: true,
|
||||||
|
@ -50,6 +50,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, onMounted, ref } from 'vue';
|
import { computed, defineAsyncComponent, onMounted, ref } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { openInstanceMenu } from './_common_/common.js';
|
import { openInstanceMenu } from './_common_/common.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
@ -100,20 +101,6 @@ if ($i && ($i.isAdmin ?? $i.isModerator)) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function more(ev: MouseEvent) {
|
function more(ev: MouseEvent) {
|
||||||
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkLaunchPad.vue')), {
|
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkLaunchPad.vue')), {
|
||||||
src: ev.currentTarget ?? ev.target,
|
src: ev.currentTarget ?? ev.target,
|
||||||
|
@ -52,6 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineAsyncComponent, computed, watch, ref, shallowRef } from 'vue';
|
import { defineAsyncComponent, computed, watch, ref, shallowRef } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { openInstanceMenu } from './_common_/common.js';
|
import { openInstanceMenu } from './_common_/common.js';
|
||||||
// import { host } from '@@/js/config.js';
|
// import { host } from '@@/js/config.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
@ -109,20 +110,6 @@ if ($i && ($i.isAdmin ?? $i.isModerator)) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function calcViewState() {
|
function calcViewState() {
|
||||||
iconOnly.value = (window.innerWidth <= WINDOW_THRESHOLD) || (menuDisplay.value === 'sideIcon');
|
iconOnly.value = (window.innerWidth <= WINDOW_THRESHOLD) || (menuDisplay.value === 'sideIcon');
|
||||||
settingsWindowed.value = (window.innerWidth > WINDOW_THRESHOLD);
|
settingsWindowed.value = (window.innerWidth > WINDOW_THRESHOLD);
|
||||||
|
@ -57,6 +57,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue';
|
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { openInstanceMenu } from '@/ui/_common_/common.js';
|
import { openInstanceMenu } from '@/ui/_common_/common.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { navbarItemDef } from '@/navbar.js';
|
import { navbarItemDef } from '@/navbar.js';
|
||||||
@ -111,20 +112,6 @@ function toggleBannerDisplay() {
|
|||||||
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openAccountMenu(ev: MouseEvent) {
|
function openAccountMenu(ev: MouseEvent) {
|
||||||
openAccountMenu_({
|
openAccountMenu_({
|
||||||
withExtraOperation: true,
|
withExtraOperation: true,
|
||||||
|
@ -87,6 +87,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, defineAsyncComponent, ref, watch } from 'vue';
|
import { computed, defineAsyncComponent, ref, watch } from 'vue';
|
||||||
import { version } from '@@/js/config.js';
|
import { version } from '@@/js/config.js';
|
||||||
|
import { compareVersions } from 'compare-versions';
|
||||||
import { openInstanceMenu } from '@/ui/_common_/common.js';
|
import { openInstanceMenu } from '@/ui/_common_/common.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { navbarItemDef } from '@/navbar.js';
|
import { navbarItemDef } from '@/navbar.js';
|
||||||
@ -161,20 +162,6 @@ function toggleBannerDisplay() {
|
|||||||
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
bannerDisplay.value = defaultStore.state.bannerDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareVersions(v1: string, v2: string): number {
|
|
||||||
const v1Parts = v1.split('.').map(Number);
|
|
||||||
const v2Parts = v2.split('.').map(Number);
|
|
||||||
|
|
||||||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) {
|
|
||||||
const part1 = v1Parts[i] || 0;
|
|
||||||
const part2 = v2Parts[i] || 0;
|
|
||||||
|
|
||||||
if (part1 < part2) return -1;
|
|
||||||
if (part1 > part2) return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openAccountMenu(ev: MouseEvent) {
|
function openAccountMenu(ev: MouseEvent) {
|
||||||
openAccountMenu_({
|
openAccountMenu_({
|
||||||
withExtraOperation: true,
|
withExtraOperation: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user