2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSection v-if="!fetching">
|
2022-05-04 10:14:48 +09:00
|
|
|
<template #label>{{ i18n.ts.usageAmount }}</template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<div class="_formBlock uawsfosz">
|
|
|
|
<div class="meter"><div :style="meterStyle"></div></div>
|
2021-01-23 18:14:57 +09:00
|
|
|
</div>
|
2021-12-30 21:47:48 +09:00
|
|
|
<FormSplit>
|
2021-11-28 20:07:37 +09:00
|
|
|
<MkKeyValue class="_formBlock">
|
2022-05-04 10:14:48 +09:00
|
|
|
<template #key>{{ i18n.ts.capacity }}</template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<template #value>{{ bytes(capacity, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
|
|
|
<MkKeyValue class="_formBlock">
|
2022-05-04 10:14:48 +09:00
|
|
|
<template #key>{{ i18n.ts.inUse }}</template>
|
2021-11-28 20:07:37 +09:00
|
|
|
<template #value>{{ bytes(usage, 1) }}</template>
|
|
|
|
</MkKeyValue>
|
2021-12-30 21:47:48 +09:00
|
|
|
</FormSplit>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
2022-05-04 10:14:48 +09:00
|
|
|
<template #label>{{ i18n.ts.statistics }}</template>
|
2022-02-04 16:39:09 +09:00
|
|
|
<MkChart src="per-user-drive" :args="{ user: $i }" span="day" :limit="7 * 5" :bar="true" :stacked="true" :detailed="false" :aspect-ratio="6"/>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
|
|
|
|
<FormSection>
|
|
|
|
<FormLink @click="chooseUploadFolder()">
|
2022-05-04 10:14:48 +09:00
|
|
|
{{ i18n.ts.uploadFolder }}
|
2021-11-28 20:07:37 +09:00
|
|
|
<template #suffix>{{ uploadFolder ? uploadFolder.name : '-' }}</template>
|
|
|
|
<template #suffixIcon><i class="fas fa-folder-open"></i></template>
|
|
|
|
</FormLink>
|
2022-07-07 21:06:37 +09:00
|
|
|
<FormSwitch v-model="keepOriginalUploading" class="_formBlock">
|
|
|
|
<template #label>{{ i18n.ts.keepOriginalUploading }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.keepOriginalUploadingDescription }}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
<FormSwitch v-model="alwaysMarkNsfw" class="_formBlock" @update:modelValue="saveProfile()">
|
|
|
|
<template #label>{{ i18n.ts.alwaysMarkSensitive }}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
<FormSwitch v-model="autoSensitive" class="_formBlock" @update:modelValue="saveProfile()">
|
|
|
|
<template #label>{{ i18n.ts.enableAutoSensitive }}<span class="_beta">{{ i18n.ts.beta }}</span></template>
|
|
|
|
<template #caption>{{ i18n.ts.enableAutoSensitiveDescription }}</template>
|
|
|
|
</FormSwitch>
|
2021-11-28 20:07:37 +09:00
|
|
|
</FormSection>
|
|
|
|
</div>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-04 10:14:48 +09:00
|
|
|
<script lang="ts" setup>
|
2022-06-20 17:38:49 +09:00
|
|
|
import { computed, ref } from 'vue';
|
2022-05-30 21:09:22 +09:00
|
|
|
import tinycolor from 'tinycolor2';
|
2021-11-28 20:07:37 +09:00
|
|
|
import FormLink from '@/components/form/link.vue';
|
2022-01-30 14:11:52 +09:00
|
|
|
import FormSwitch from '@/components/form/switch.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';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
import bytes from '@/filters/bytes';
|
2022-01-30 14:11:52 +09:00
|
|
|
import { defaultStore } from '@/store';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MkChart from '@/components/MkChart.vue';
|
2022-05-04 10:14:48 +09:00
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2022-07-07 21:06:37 +09:00
|
|
|
import { $i } from '@/account';
|
2022-05-04 10:14:48 +09:00
|
|
|
|
|
|
|
const fetching = ref(true);
|
|
|
|
const usage = ref<any>(null);
|
|
|
|
const capacity = ref<any>(null);
|
|
|
|
const uploadFolder = ref<any>(null);
|
2022-07-07 21:06:37 +09:00
|
|
|
let alwaysMarkNsfw = $ref($i.alwaysMarkNsfw);
|
|
|
|
let autoSensitive = $ref($i.autoSensitive);
|
2022-05-04 10:14:48 +09:00
|
|
|
|
|
|
|
const meterStyle = computed(() => {
|
|
|
|
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,
|
|
|
|
}),
|
2022-05-04 10:14:48 +09:00
|
|
|
};
|
|
|
|
});
|
2021-10-24 12:32:41 +09:00
|
|
|
|
2022-05-04 10:14:48 +09:00
|
|
|
const keepOriginalUploading = computed(defaultStore.makeGetterSetter('keepOriginalUploading'));
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2022-05-04 10:14:48 +09:00
|
|
|
os.api('drive').then(info => {
|
|
|
|
capacity.value = info.capacity;
|
|
|
|
usage.value = info.usage;
|
|
|
|
fetching.value = false;
|
|
|
|
});
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2022-05-04 10:14:48 +09:00
|
|
|
if (defaultStore.state.uploadFolder) {
|
|
|
|
os.api('drive/folders/show', {
|
2022-06-20 17:38:49 +09:00
|
|
|
folderId: defaultStore.state.uploadFolder,
|
2022-05-04 10:14:48 +09:00
|
|
|
}).then(response => {
|
|
|
|
uploadFolder.value = response;
|
|
|
|
});
|
|
|
|
}
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2022-05-04 10:14:48 +09:00
|
|
|
function chooseUploadFolder() {
|
|
|
|
os.selectDriveFolder(false).then(async folder => {
|
|
|
|
defaultStore.set('uploadFolder', folder ? folder.id : null);
|
|
|
|
os.success();
|
|
|
|
if (defaultStore.state.uploadFolder) {
|
|
|
|
uploadFolder.value = await os.api('drive/folders/show', {
|
2022-06-20 17:38:49 +09:00
|
|
|
folderId: defaultStore.state.uploadFolder,
|
2020-04-22 00:34:56 +09:00
|
|
|
});
|
2022-05-04 10:14:48 +09:00
|
|
|
} else {
|
|
|
|
uploadFolder.value = null;
|
2020-04-22 00:34:56 +09:00
|
|
|
}
|
2022-05-04 10:14:48 +09:00
|
|
|
});
|
|
|
|
}
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2022-07-07 21:06:37 +09:00
|
|
|
function saveProfile() {
|
|
|
|
os.api('i/update', {
|
|
|
|
alwaysMarkNsfw: !!alwaysMarkNsfw,
|
|
|
|
autoSensitive: !!autoSensitive,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.drive,
|
2022-12-19 13:54:35 +09:00
|
|
|
icon: 'fas fa-cloud',
|
2020-01-30 04:37:25 +09:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-06-05 14:57:52 +09:00
|
|
|
|
|
|
|
@use "sass:math";
|
|
|
|
|
2020-01-30 11:10:42 +09:00
|
|
|
.uawsfosz {
|
2021-01-23 18:14:57 +09:00
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
> .meter {
|
|
|
|
$size: 12px;
|
|
|
|
background: rgba(0, 0, 0, 0.1);
|
|
|
|
border-radius: math.div($size, 2);
|
|
|
|
overflow: hidden;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-11-28 20:07:37 +09:00
|
|
|
> div {
|
|
|
|
height: $size;
|
|
|
|
border-radius: math.div($size, 2);
|
2021-01-23 18:14:57 +09:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
</style>
|