Skip to content

Commit d0311e5

Browse files
committed
feat: 内置更新检测
1 parent 5a07c5e commit d0311e5

10 files changed

Lines changed: 267 additions & 6 deletions

File tree

AquaMai

MaiChartManager/Front/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@
5555
"vue-router": "^5.0.3",
5656
"wavesurfer.js": "^7.12.1"
5757
},
58-
"packageManager": "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd"
58+
"packageManager": "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd",
59+
"dependencies": {
60+
"@f3ve/vue-markdown-it": "^0.2.3"
61+
}
5962
}

MaiChartManager/Front/pnpm-lock.yaml

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MaiChartManager/Front/src/client/aquaMaiVersionConfigApiGen.ts

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@ export enum GetGetConfigTypeEnum {
1414
Builtin = "builtin",
1515
Release = "release",
1616
Ci = "ci",
17+
Slow = "slow",
1718
}
1819

1920
export enum PostUpsertConfigTypeEnum {
2021
Builtin = "builtin",
2122
Release = "release",
2223
Ci = "ci",
24+
Slow = "slow",
25+
}
26+
27+
export enum GetAdminStatusTypeEnum {
28+
Builtin = "builtin",
29+
Release = "release",
30+
Ci = "ci",
31+
Slow = "slow",
2332
}
2433

2534
export type QueryParamsType = Record<string | number, any>;
@@ -355,5 +364,96 @@ export class Api<
355364
format: "json",
356365
...params,
357366
}),
367+
368+
/**
369+
* No description
370+
*
371+
* @name PostAdminClear
372+
* @summary 清除慢速通道队列
373+
* @request POST:/api/admin/clear
374+
*/
375+
postAdminClear: (params: RequestParams = {}) =>
376+
this.request<
377+
{
378+
/** @min 0 */
379+
delayDays: number;
380+
lastPromotedVersion?: string;
381+
promotedAt?: string;
382+
clearedAt?: string;
383+
},
384+
any
385+
>({
386+
path: `/api/admin/clear`,
387+
method: "POST",
388+
format: "json",
389+
...params,
390+
}),
391+
392+
/**
393+
* No description
394+
*
395+
* @name PostAdminDelay
396+
* @summary 设置慢速通道延迟天数
397+
* @request POST:/api/admin/delay
398+
*/
399+
postAdminDelay: (
400+
data: {
401+
/** @min 0 */
402+
days: number;
403+
},
404+
params: RequestParams = {},
405+
) =>
406+
this.request<
407+
{
408+
delayDays: number;
409+
},
410+
any
411+
>({
412+
path: `/api/admin/delay`,
413+
method: "POST",
414+
body: data,
415+
type: ContentType.Json,
416+
format: "json",
417+
...params,
418+
}),
419+
420+
/**
421+
* No description
422+
*
423+
* @name GetAdminStatus
424+
* @summary 获取慢速通道状态
425+
* @request GET:/api/admin/status
426+
*/
427+
getAdminStatus: (params: RequestParams = {}) =>
428+
this.request<
429+
{
430+
meta: {
431+
/** @min 0 */
432+
delayDays: number;
433+
lastPromotedVersion?: string;
434+
promotedAt?: string;
435+
clearedAt?: string;
436+
};
437+
slow: {
438+
version?: string;
439+
/** @format date-time */
440+
createdAt?: string;
441+
type: GetAdminStatusTypeEnum;
442+
/** @format uri */
443+
url?: string;
444+
/** @format uri */
445+
url2?: string;
446+
sign?: string;
447+
/** @default false */
448+
default?: boolean;
449+
};
450+
},
451+
any
452+
>({
453+
path: `/api/admin/status`,
454+
method: "GET",
455+
format: "json",
456+
...params,
457+
}),
358458
};
359459
}

MaiChartManager/Front/src/components/VersionInfo/index.tsx

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { computed, defineComponent, ref } from "vue";
2-
import { Popover, Qrcode } from "@munet/ui";
32
import AppIcon from '@/components/AppIcon';
43
import '@fontsource/nerko-one'
5-
import { updateVersion, version } from "@/store/refs";
4+
import { appUpdateInfo, updateVersion, version } from "@/store/refs";
5+
import { compareVersions } from "@/views/ModManager/shouldShowUpdateController";
6+
import { locale } from "@/locales";
7+
import { VueMarkdownIt } from '@f3ve/vue-markdown-it';
8+
import style from './style.module.sass';
69
import StorePurchaseButton from "@/components/StorePurchaseButton";
710
import AfdianIcon from "@/icons/afdian.svg";
811
import { HardwareAccelerationStatus, LicenseStatus } from "@/client/apiGen";
@@ -17,6 +20,19 @@ export default defineComponent({
1720
const activationCode = ref('');
1821
const activating = ref(false);
1922
const displayVersion = computed(() => version.value?.version?.split('+')[0]);
23+
const showChangelog = ref(false);
24+
25+
const hasAppUpdate = computed(() => {
26+
if (!appUpdateInfo.value?.version || !version.value?.version) return false;
27+
const currentVersion = version.value.version.split('+')[0];
28+
return compareVersions(appUpdateInfo.value.version, currentVersion) > 0;
29+
});
30+
31+
const changelogNotes = computed(() => {
32+
if (!appUpdateInfo.value?.notes) return '';
33+
return appUpdateInfo.value.notes[locale.value] || appUpdateInfo.value.notes['en'] || '';
34+
});
35+
2036
const { t } = useI18n();
2137

2238
const onVersionClick = (e: MouseEvent) => {
@@ -47,8 +63,9 @@ export default defineComponent({
4763
}
4864
};
4965

50-
return () => version.value && <div class={'w-15 py-1 flex items-center justify-center rounded-md cursor-pointer transition-all duration-200 bg-avatarMenuButton text-3.5 shrink-0'} onClick={onVersionClick}>
66+
return () => version.value && <div class={'w-15 py-1 flex items-center justify-center rounded-md cursor-pointer transition-all duration-200 bg-avatarMenuButton text-3.5 shrink-0 relative'} onClick={onVersionClick}>
5167
v{displayVersion.value}
68+
{hasAppUpdate.value && <div class="absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-red-500 pointer-events-none" />}
5269

5370
<Modal
5471
width="min(85vw,60em)"
@@ -61,8 +78,20 @@ export default defineComponent({
6178
<a class="i-mdi-github hover:c-[var(--text-color)] transition-300" href="https://github.com/clansty/MaiChartManager" target="_blank"/>
6279
<a class="i-ri-qq-fill hover:c-[var(--text-color)] transition-300" href="https://qm.qq.com/q/U3gT7CDuy6" target="_blank" />
6380
</div>
64-
<div>
81+
<div class="flex items-center gap-2">
6582
{t('about.version')}: v{version.value.version}
83+
{hasAppUpdate.value && <>
84+
<span class="c-red-500 font-bold">{t('about.updateAvailable', { version: appUpdateInfo.value!.version })}</span>
85+
<a
86+
class={[theme.value.lc, 'fl cursor-pointer']}
87+
onClick={() => { showChangelog.value = true; }}
88+
>
89+
{t('about.viewChangelog')}
90+
</a>
91+
<Button onClick={() => window.open('ms-windows-store://pdp/?ProductId=9P1JDKQ60G4G')}>
92+
{t('about.updateHint')}
93+
</Button>
94+
</>}
6695
</div>
6796
<div>
6897
{t('about.gameVersion')}: 1.{version.value.gameVersion}
@@ -125,6 +154,16 @@ export default defineComponent({
125154
{t('common.confirm')}
126155
</Button>,
127156
}}</Modal>
157+
158+
<Modal
159+
width="min(85vw,50em)"
160+
title={t('about.changelogTitle')}
161+
v-model:show={showChangelog.value}
162+
>
163+
<div class={style.mdContent}>
164+
<VueMarkdownIt source={changelogNotes.value} />
165+
</div>
166+
</Modal>
128167
</div>;
129168
}
130169
})
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.mdContent
2+
p
3+
margin-bottom: 0.5em
4+
img
5+
max-width: 100%
6+
height: auto
7+
display: block
8+
margin: 0 auto
9+
a
10+
color: var(--link-color, #4facfe)
11+
text-decoration: none
12+
&:hover
13+
text-decoration: underline
14+
ul
15+
list-style-type: disc
16+
margin-left: 1.5em
17+
margin-bottom: 0.5em
18+
ol
19+
list-style-type: decimal
20+
margin-left: 1.5em
21+
margin-bottom: 0.5em
22+
li
23+
margin-bottom: 0.25em
24+
h1
25+
font-size: 1.3em
26+
margin-bottom: 0.5rem
27+
font-weight: bold
28+
h2
29+
font-size: 1.15em
30+
margin-bottom: 0.5rem
31+
font-weight: bold
32+
h3
33+
font-size: 1.05em
34+
margin-bottom: 0.5rem
35+
font-weight: bold
36+
code
37+
background: rgba(128, 128, 128, 0.1)
38+
padding: 0.1em 0.3em
39+
border-radius: 4px
40+
font-family: Consolas, Monaco, Andale Mono, Ubuntu Mono, monospace
41+
strong
42+
font-weight: bold

0 commit comments

Comments
 (0)