2023-07-27 14:31:52 +09:00
|
|
|
<!--
|
2024-02-13 15:59:27 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2025-03-06 23:15:19 +09:00
|
|
|
<SearchMarker path="/settings/drive" :label="i18n.ts.drive" :keywords="['drive']" icon="ti ti-cloud">
|
|
|
|
<div class="_gaps_m">
|
|
|
|
<SearchMarker :keywords="['capacity', 'usage']">
|
|
|
|
<FormSection first>
|
|
|
|
<template #label><SearchLabel>{{ i18n.ts.usageAmount }}</SearchLabel></template>
|
2023-01-05 21:04:56 +09:00
|
|
|
|
2025-03-06 23:15:19 +09:00
|
|
|
<div v-if="!fetching" class="_gaps_m">
|
|
|
|
<div>
|
|
|
|
<div :class="$style.meter"><div :class="$style.meterValue" :style="meterStyle"></div></div>
|
|
|
|
</div>
|
|
|
|
<FormSplit>
|
|
|
|
<MkKeyValue>
|
|
|
|
<template #key>{{ i18n.ts.capacity }}</template>
|
|
|
|
<template #value>{{ bytes(capacity, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue>
|
|
|
|
<template #key>{{ i18n.ts.inUse }}</template>
|
|
|
|
<template #value>{{ bytes(usage, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
</FormSplit>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
|
|
|
</SearchMarker>
|
|
|
|
|
|
|
|
<SearchMarker :keywords="['statistics', 'usage']">
|
|
|
|
<FormSection>
|
|
|
|
<template #label><SearchLabel>{{ i18n.ts.statistics }}</SearchLabel></template>
|
|
|
|
<MkChart src="per-user-drive" :args="{ user: $i }" span="day" :limit="7 * 5" :bar="true" :stacked="true" :detailed="false" :aspectRatio="6"/>
|
|
|
|
</FormSection>
|
|
|
|
</SearchMarker>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<div class="_gaps_m">
|
|
|
|
<SearchMarker :keywords="['default', 'upload', 'folder']">
|
|
|
|
<FormLink @click="chooseUploadFolder()">
|
|
|
|
<SearchLabel>{{ i18n.ts.uploadFolder }}</SearchLabel>
|
|
|
|
<template #suffix>{{ uploadFolder ? uploadFolder.name : '-' }}</template>
|
|
|
|
<template #suffixIcon><i class="ti ti-folder"></i></template>
|
|
|
|
</FormLink>
|
|
|
|
</SearchMarker>
|
|
|
|
|
|
|
|
<FormLink to="/settings/drive/cleaner">
|
|
|
|
{{ i18n.ts.drivecleaner }}
|
|
|
|
</FormLink>
|
2021-11-28 20:07:37 +09:00
|
|
|
|
2025-03-06 23:15:19 +09:00
|
|
|
<SearchMarker :keywords="['keep', 'original', 'raw', 'upload']">
|
2025-03-09 12:34:08 +09:00
|
|
|
<MkPreferenceContainer k="keepOriginalUploading">
|
|
|
|
<MkSwitch v-model="keepOriginalUploading">
|
|
|
|
<template #label><SearchLabel>{{ i18n.ts.keepOriginalUploading }}</SearchLabel></template>
|
|
|
|
<template #caption><SearchKeyword>{{ i18n.ts.keepOriginalUploadingDescription }}</SearchKeyword></template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkPreferenceContainer>
|
2025-03-06 23:15:19 +09:00
|
|
|
</SearchMarker>
|
2021-11-28 20:07:37 +09:00
|
|
|
|
2025-03-06 23:15:19 +09:00
|
|
|
<SearchMarker :keywords="['keep', 'original', 'filename']">
|
2025-03-09 12:34:08 +09:00
|
|
|
<MkPreferenceContainer k="keepOriginalFilename">
|
|
|
|
<MkSwitch v-model="keepOriginalFilename">
|
|
|
|
<template #label><SearchLabel>{{ i18n.ts.keepOriginalFilename }}</SearchLabel></template>
|
|
|
|
<template #caption><SearchKeyword>{{ i18n.ts.keepOriginalFilenameDescription }}</SearchKeyword></template>
|
|
|
|
</MkSwitch>
|
|
|
|
</MkPreferenceContainer>
|
2025-03-06 23:15:19 +09:00
|
|
|
</SearchMarker>
|
|
|
|
|
|
|
|
<SearchMarker :keywords="['always', 'default', 'mark', 'nsfw', 'sensitive', 'media', 'file']">
|
|
|
|
<MkSwitch v-model="alwaysMarkNsfw" @update:modelValue="saveProfile()">
|
|
|
|
<template #label><SearchLabel>{{ i18n.ts.alwaysMarkSensitive }}</SearchLabel></template>
|
|
|
|
</MkSwitch>
|
|
|
|
</SearchMarker>
|
|
|
|
|
|
|
|
<SearchMarker :keywords="['auto', 'nsfw', 'sensitive', 'media', 'file']">
|
|
|
|
<MkSwitch v-model="autoSensitive" @update:modelValue="saveProfile()">
|
|
|
|
<template #label><SearchLabel>{{ i18n.ts.enableAutoSensitive }}</SearchLabel><span class="_beta">{{ i18n.ts.beta }}</span></template>
|
|
|
|
<template #caption><SearchKeyword>{{ i18n.ts.enableAutoSensitiveDescription }}</SearchKeyword></template>
|
|
|
|
</MkSwitch>
|
|
|
|
</SearchMarker>
|
|
|
|
</div>
|
|
|
|
</FormSection>
|
|
|
|
</div>
|
|
|
|
</SearchMarker>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 03:14:48 +02:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 17:38:49 +09:00
|
|
|
import { computed, ref } from 'vue';
|
2023-12-26 14:19:35 +09:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-05-30 12:09:22 +00:00
|
|
|
import tinycolor from 'tinycolor2';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2023-01-07 14:59:54 +09:00
|
|
|
import MkSwitch from '@/components/MkSwitch.vue';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormSection from '@/components/form/section.vue';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkKeyValue from '@/components/MkKeyValue.vue';
|
2021-12-30 21:47:48 +09:00
|
|
|
import FormSplit from '@/components/form/split.vue';
|
2023-09-19 16:37:43 +09:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 18:32:46 +09:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 16:37:43 +09:00
|
|
|
import bytes from '@/filters/bytes.js';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkChart from '@/components/MkChart.vue';
|
2023-09-19 16:37:43 +09:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2024-01-04 15:30:40 +09:00
|
|
|
import { signinRequired } from '@/account.js';
|
2025-03-09 12:34:08 +09:00
|
|
|
import { prefer } from '@/preferences.js';
|
|
|
|
import MkPreferenceContainer from '@/components/MkPreferenceContainer.vue';
|
2024-01-04 15:30:40 +09:00
|
|
|
|
|
|
|
const $i = signinRequired();
|
2022-05-04 03:14:48 +02:00
|
|
|
|
|
|
|
const fetching = ref(true);
|
2023-12-26 14:19:35 +09:00
|
|
|
const usage = ref<number | null>(null);
|
|
|
|
const capacity = ref<number | null>(null);
|
|
|
|
const uploadFolder = ref<Misskey.entities.DriveFolder | null>(null);
|
2023-12-07 14:42:09 +09:00
|
|
|
const alwaysMarkNsfw = ref($i.alwaysMarkNsfw);
|
|
|
|
const autoSensitive = ref($i.autoSensitive);
|
2022-05-04 03:14:48 +02:00
|
|
|
|
|
|
|
const meterStyle = computed(() => {
|
2024-01-05 12:38:06 +09:00
|
|
|
if (!capacity.value || !usage.value) return {};
|
2022-05-04 03:14:48 +02:00
|
|
|
return {
|
|
|
|
width: `${usage.value / capacity.value * 100}%`,
|
|
|
|
background: tinycolor({
|
|
|
|
h: 180 - (usage.value / capacity.value * 180),
|
|
|
|
s: 0.7,
|
2022-06-20 17:38:49 +09:00
|
|
|
l: 0.5,
|
2024-07-11 16:29:18 +09:00
|
|
|
}).toHslString(),
|
2022-05-04 03:14:48 +02:00
|
|
|
};
|
|
|
|
});
|
2021-10-24 12:32:41 +09:00
|
|
|
|
2025-03-09 12:34:08 +09:00
|
|
|
const keepOriginalUploading = prefer.model('keepOriginalUploading');
|
|
|
|
const keepOriginalFilename = prefer.model('keepOriginalFilename');
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2024-01-04 18:32:46 +09:00
|
|
|
misskeyApi('drive').then(info => {
|
2022-05-04 03:14:48 +02:00
|
|
|
capacity.value = info.capacity;
|
|
|
|
usage.value = info.usage;
|
|
|
|
fetching.value = false;
|
|
|
|
});
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2025-03-09 12:34:08 +09:00
|
|
|
if (prefer.s.uploadFolder) {
|
2024-01-04 18:32:46 +09:00
|
|
|
misskeyApi('drive/folders/show', {
|
2025-03-09 12:34:08 +09:00
|
|
|
folderId: prefer.s.uploadFolder,
|
2022-05-04 03:14:48 +02:00
|
|
|
}).then(response => {
|
|
|
|
uploadFolder.value = response;
|
|
|
|
});
|
|
|
|
}
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2022-05-04 03:14:48 +02:00
|
|
|
function chooseUploadFolder() {
|
|
|
|
os.selectDriveFolder(false).then(async folder => {
|
2025-03-09 12:34:08 +09:00
|
|
|
prefer.set('uploadFolder', folder[0] ? folder[0].id : null);
|
2022-05-04 03:14:48 +02:00
|
|
|
os.success();
|
2025-03-09 12:34:08 +09:00
|
|
|
if (prefer.s.uploadFolder) {
|
2024-01-04 18:32:46 +09:00
|
|
|
uploadFolder.value = await misskeyApi('drive/folders/show', {
|
2025-03-09 12:34:08 +09:00
|
|
|
folderId: prefer.s.uploadFolder,
|
2020-04-22 00:34:56 +09:00
|
|
|
});
|
2022-05-04 03:14:48 +02:00
|
|
|
} else {
|
|
|
|
uploadFolder.value = null;
|
2020-04-22 00:34:56 +09:00
|
|
|
}
|
2022-05-04 03:14:48 +02:00
|
|
|
});
|
|
|
|
}
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2022-07-07 21:06:37 +09:00
|
|
|
function saveProfile() {
|
2024-01-04 18:32:46 +09:00
|
|
|
misskeyApi('i/update', {
|
2023-12-07 14:42:09 +09:00
|
|
|
alwaysMarkNsfw: !!alwaysMarkNsfw.value,
|
|
|
|
autoSensitive: !!autoSensitive.value,
|
2023-05-05 14:18:06 +09:00
|
|
|
}).catch(err => {
|
|
|
|
os.alert({
|
|
|
|
type: 'error',
|
|
|
|
title: i18n.ts.error,
|
|
|
|
text: err.message,
|
|
|
|
});
|
2023-12-07 14:42:09 +09:00
|
|
|
alwaysMarkNsfw.value = true;
|
2022-07-07 21:06:37 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-07 14:42:09 +09:00
|
|
|
const headerActions = computed(() => []);
|
2022-06-20 17:38:49 +09:00
|
|
|
|
2023-12-07 14:42:09 +09:00
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 17:38:49 +09:00
|
|
|
|
2024-02-16 16:17:09 +09:00
|
|
|
definePageMetadata(() => ({
|
2022-06-20 17:38:49 +09:00
|
|
|
title: i18n.ts.drive,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-cloud',
|
2024-02-16 16:17:09 +09:00
|
|
|
}));
|
2020-01-30 04:37:25 +09:00
|
|
|
</script>
|
|
|
|
|
2023-05-30 10:20:06 +09:00
|
|
|
<style lang="scss" module>
|
|
|
|
.meter {
|
2023-05-30 14:38:13 +09:00
|
|
|
height: 10px;
|
2023-05-30 10:20:06 +09:00
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
border-radius: 999px;
|
|
|
|
overflow: clip;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2023-05-30 10:20:06 +09:00
|
|
|
.meterValue {
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 999px;
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
</style>
|