サウンド設定でドライブのファイルを利用可否をロールで制御可能に(デフォルトでオフ)

This commit is contained in:
まっちゃとーにゅ
2023-12-27 10:16:48 +09:00
parent 98f4b69418
commit 90e8b942a3
12 changed files with 53 additions and 5 deletions

View File

@@ -86,6 +86,7 @@ export const ROLE_POLICIES = [
'canManageAvatarDecorations',
'canSearchNotes',
'canUseTranslator',
'canUseDriveFileInSoundSettings',
'canHideAds',
'driveCapacityMb',
'alwaysMarkNsfw',

View File

@@ -379,6 +379,26 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
</MkFolder>
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseDriveFileInSoundSettings, 'canUseDriveFileInSoundSettings'])">
<template #label>{{ i18n.ts._role._options.canUseDriveFileInSoundSettings }}</template>
<template #suffix>
<span v-if="role.policies.canUseDriveFileInSoundSettings.useDefault" :class="$style.useDefaultLabel">{{ i18n.ts._role.useBaseValue }}</span>
<span v-else>{{ role.policies.canUseDriveFileInSoundSettings.value ? i18n.ts.yes : i18n.ts.no }}</span>
<span :class="$style.priorityIndicator"><i :class="getPriorityIcon(role.policies.canUseDriveFileInSoundSettings)"></i></span>
</template>
<div class="_gaps">
<MkSwitch v-model="role.policies.canUseDriveFileInSoundSettings.useDefault" :readonly="readonly">
<template #label>{{ i18n.ts._role.useBaseValue }}</template>
</MkSwitch>
<MkSwitch v-model="role.policies.canUseDriveFileInSoundSettings.value" :disabled="role.policies.canUseDriveFileInSoundSettings.useDefault" :readonly="readonly">
<template #label>{{ i18n.ts.enable }}</template>
</MkSwitch>
<MkRange v-model="role.policies.canUseDriveFileInSoundSettings.priority" :min="0" :max="2" :step="1" easing :textConverter="(v) => v === 0 ? i18n.ts._role._priority.low : v === 1 ? i18n.ts._role._priority.middle : v === 2 ? i18n.ts._role._priority.high : ''">
<template #label>{{ i18n.ts._role.priority }}</template>
</MkRange>
</div>
</MkFolder>
<MkFolder v-if="matchQuery([i18n.ts._role._options.driveCapacity, 'driveCapacityMb'])">
<template #label>{{ i18n.ts._role._options.driveCapacity }}</template>
<template #suffix>

View File

@@ -127,7 +127,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkSwitch>
</MkFolder>
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseTranslator, 'canSearchNotes'])">
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseTranslator, 'canUseTranslator'])">
<template #label>{{ i18n.ts._role._options.canUseTranslator }}</template>
<template #suffix>{{ policies.canUseTranslator ? i18n.ts.yes : i18n.ts.no }}</template>
<MkSwitch v-model="policies.canUseTranslator">
@@ -135,6 +135,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</MkSwitch>
</MkFolder>
<MkFolder v-if="matchQuery([i18n.ts._role._options.canUseDriveFileInSoundSettings, 'canUseDriveFileInSoundSettings'])">
<template #label>{{ i18n.ts._role._options.canUseDriveFileInSoundSettings }}</template>
<template #suffix>{{ policies.canUseDriveFileInSoundSettings ? i18n.ts.yes : i18n.ts.no }}</template>
<MkSwitch v-model="policies.canUseDriveFileInSoundSettings">
<template #label>{{ i18n.ts.enable }}</template>
</MkSwitch>
</MkFolder>
<MkFolder v-if="matchQuery([i18n.ts._role._options.driveCapacity, 'driveCapacityMb'])">
<template #label>{{ i18n.ts._role._options.driveCapacity }}</template>
<template #suffix>{{ policies.driveCapacityMb }}MB</template>

View File

@@ -5,6 +5,7 @@
import type { SoundStore } from '@/store.js';
import { defaultStore } from '@/store.js';
import { $i } from "@/account.js";
import * as os from '@/os.js';
let ctx: AudioContext;
@@ -16,7 +17,7 @@ export const soundsTypes = [
null,
// ドライブの音声
'_driveFile_',
...($i?.policies.canUseDriveFileInSoundSettings ? ['_driveFile_'] : []),
// プリインストール
'syuilo/n-aec',
@@ -156,7 +157,7 @@ export type OperationType = typeof operationTypes[number];
export async function loadAudio(soundStore: SoundStore, options?: { useCache?: boolean; }) {
if (_DEV_) console.log('loading audio. opts:', options);
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (soundStore.type === null || (soundStore.type === '_driveFile_' && !soundStore.fileUrl)) {
if (soundStore.type === null || (soundStore.type === '_driveFile_' && (!$i?.policies.canUseDriveFileInSoundSettings || !soundStore.fileUrl))) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition