Skip to content

Commit

Permalink
Update: 音声合成モデルのインストールサイズを表示する
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Jan 4, 2025
1 parent 9e28843 commit f8b81cc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openapi.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/components/Dialog/ModelManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
</span>
</div>
<div class="col-auto q-ml-auto" style="font-size: 13.5px; color: #D2D3D4;">
<span>{{ activeAivmInfo.manifest.speakers.length }} Speakers / Version {{ activeAivmInfo.manifest.version }}</span>
<span>Version {{ activeAivmInfo.manifest.version }} / </span>
<span>{{ formatBytes(activeAivmInfo.fileSize) }}</span>
<span v-if="activeAivmInfo.isUpdateAvailable" class="q-ml-xs text-primary">
(Version {{ activeAivmInfo.latestVersion }} に更新できます)
</span>
Expand Down Expand Up @@ -203,6 +204,7 @@
<script setup lang="ts">
import { computed, ref, watch, onUnmounted } from "vue";
import { formatBytes } from "@/helpers/fileHelper";
import { AivmInfo, ResponseError } from "@/openapi";
import { useStore } from "@/store";
Expand Down
17 changes: 17 additions & 0 deletions src/helpers/fileHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,20 @@ export function generateWriteErrorMessage(writeFileResult: ResultError<any>) {

return `何らかの理由で失敗しました。${writeFileResult.message}`;
}

/**
* バイト単位の数値をフォーマットする
* @param bytes バイト数
* @returns フォーマットされた文字列 (例: 1.23KB)
*/
export function formatBytes(bytes: number): string {
const units = ["B", "KB", "MB", "GB", "TB"];
let unitIndex = 0;

while (bytes >= 1000 && unitIndex < units.length - 1) {
bytes /= 1000;
unitIndex++;
}

return `${bytes.toFixed(2)}${units[unitIndex]}`;
}
9 changes: 9 additions & 0 deletions src/openapi/models/AivmInfo.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f8b81cc

Please sign in to comment.