diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-07-16 23:53:24 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-07-16 23:53:24 +0900 |
| commit | b796aacf7fc234889cd9ddcb3d636cb4af883e13 (patch) | |
| tree | f550b31ad82a6719034f889203f48f725f358fdf /packages/client/src | |
| parent | Merge branch 'develop' (diff) | |
| parent | 12.116.0 (diff) | |
| download | misskey-b796aacf7fc234889cd9ddcb3d636cb4af883e13.tar.gz misskey-b796aacf7fc234889cd9ddcb3d636cb4af883e13.tar.bz2 misskey-b796aacf7fc234889cd9ddcb3d636cb4af883e13.zip | |
Merge branch 'develop'
Diffstat (limited to 'packages/client/src')
| -rw-r--r-- | packages/client/src/components/form/input.vue | 6 | ||||
| -rw-r--r-- | packages/client/src/components/form/select.vue | 6 | ||||
| -rw-r--r-- | packages/client/src/components/note-detailed.vue | 2 | ||||
| -rw-r--r-- | packages/client/src/components/ui/button.vue | 35 | ||||
| -rw-r--r-- | packages/client/src/pages/registry.keys.vue | 96 | ||||
| -rw-r--r-- | packages/client/src/pages/registry.value.vue | 123 | ||||
| -rw-r--r-- | packages/client/src/pages/registry.vue | 74 | ||||
| -rw-r--r-- | packages/client/src/pages/settings/other.vue | 2 | ||||
| -rw-r--r-- | packages/client/src/pages/settings/profile.vue | 4 | ||||
| -rw-r--r-- | packages/client/src/router.ts | 9 | ||||
| -rw-r--r-- | packages/client/src/ui/_common_/navbar.vue | 2 |
11 files changed, 332 insertions, 27 deletions
diff --git a/packages/client/src/components/form/input.vue b/packages/client/src/components/form/input.vue index 1cc3912178..2a03d6a5d4 100644 --- a/packages/client/src/components/form/input.vue +++ b/packages/client/src/components/form/input.vue @@ -77,9 +77,9 @@ const inputEl = ref<HTMLElement>(); const prefixEl = ref<HTMLElement>(); const suffixEl = ref<HTMLElement>(); const height = - props.small ? 38 : - props.large ? 42 : - 40; + props.small ? 36 : + props.large ? 40 : + 38; const focus = () => inputEl.value.focus(); const onInput = (ev: KeyboardEvent) => { diff --git a/packages/client/src/components/form/select.vue b/packages/client/src/components/form/select.vue index fe8c08cd6c..78282dfdc1 100644 --- a/packages/client/src/components/form/select.vue +++ b/packages/client/src/components/form/select.vue @@ -63,9 +63,9 @@ const prefixEl = ref(null); const suffixEl = ref(null); const container = ref(null); const height = - props.small ? 38 : - props.large ? 42 : - 40; + props.small ? 36 : + props.large ? 40 : + 38; const focus = () => inputEl.value.focus(); const onInput = (ev) => { diff --git a/packages/client/src/components/note-detailed.vue b/packages/client/src/components/note-detailed.vue index c05ab7fec4..85bffca4a5 100644 --- a/packages/client/src/components/note-detailed.vue +++ b/packages/client/src/components/note-detailed.vue @@ -390,7 +390,7 @@ if (appearNote.replyId) { > .article { padding: 32px; - font-size: 1.1em; + font-size: 1.2em; > .header { display: flex; diff --git a/packages/client/src/components/ui/button.vue b/packages/client/src/components/ui/button.vue index e6b20d9881..5f5d6d42ed 100644 --- a/packages/client/src/components/ui/button.vue +++ b/packages/client/src/components/ui/button.vue @@ -1,5 +1,6 @@ <template> -<button v-if="!link" class="bghgjjyj _button" +<button + v-if="!link" class="bghgjjyj _button" :class="{ inline, primary, gradate, danger, rounded, full }" :type="type" @click="$emit('click', $event)" @@ -10,7 +11,8 @@ <slot></slot> </div> </button> -<MkA v-else class="bghgjjyj _button" +<MkA + v-else class="bghgjjyj _button" :class="{ inline, primary, gradate, danger, rounded, full }" :to="to" @mousedown="onMousedown" @@ -29,56 +31,56 @@ export default defineComponent({ props: { type: { type: String, - required: false + required: false, }, primary: { type: Boolean, required: false, - default: false + default: false, }, gradate: { type: Boolean, required: false, - default: false + default: false, }, rounded: { type: Boolean, required: false, - default: false + default: false, }, inline: { type: Boolean, required: false, - default: false + default: false, }, link: { type: Boolean, required: false, - default: false + default: false, }, to: { type: String, - required: false + required: false, }, autofocus: { type: Boolean, required: false, - default: false + default: false, }, wait: { type: Boolean, required: false, - default: false + default: false, }, danger: { type: Boolean, required: false, - default: false + default: false, }, full: { type: Boolean, required: false, - default: false + default: false, }, }, emits: ['click'], @@ -127,8 +129,8 @@ export default defineComponent({ window.setTimeout(() => { if (this.$refs.ripples) this.$refs.ripples.removeChild(ripple); }, 2000); - } - } + }, + }, }); </script> @@ -142,8 +144,7 @@ export default defineComponent({ padding: 8px 14px; text-align: center; font-weight: normal; - font-size: 0.9em; - line-height: 22px; + font-size: 1em; box-shadow: none; text-decoration: none; background: var(--buttonBg); diff --git a/packages/client/src/pages/registry.keys.vue b/packages/client/src/pages/registry.keys.vue new file mode 100644 index 0000000000..9d2f24f18a --- /dev/null +++ b/packages/client/src/pages/registry.keys.vue @@ -0,0 +1,96 @@ +<template> +<MkStickyContainer> + <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> + <MkSpacer :content-max="600"> + <FormSplit> + <MkKeyValue class="_formBlock"> + <template #key>{{ $ts._registry.domain }}</template> + <template #value>{{ $ts.system }}</template> + </MkKeyValue> + <MkKeyValue class="_formBlock"> + <template #key>{{ $ts._registry.scope }}</template> + <template #value>{{ scope.join('/') }}</template> + </MkKeyValue> + </FormSplit> + + <MkButton primary @click="createKey">{{ i18n.ts._registry.createKey }}</MkButton> + + <FormSection v-if="keys"> + <template #label>{{ i18n.ts.keys }}</template> + <div class="_formLinks"> + <FormLink v-for="key in keys" :to="`/registry/value/system/${scope.join('/')}/${key[0]}`" class="_monospace">{{ key[0] }}<template #suffix>{{ key[1].toUpperCase() }}</template></FormLink> + </div> + </FormSection> + </MkSpacer> +</MkStickyContainer> +</template> + +<script lang="ts" setup> +import { ref, watch } from 'vue'; +import JSON5 from 'json5'; +import * as os from '@/os'; +import { i18n } from '@/i18n'; +import { definePageMetadata } from '@/scripts/page-metadata'; +import FormLink from '@/components/form/link.vue'; +import FormSection from '@/components/form/section.vue'; +import MkButton from '@/components/ui/button.vue'; +import MkKeyValue from '@/components/key-value.vue'; +import FormSplit from '@/components/form/split.vue'; + +const props = defineProps<{ + path: string; +}>(); + +const scope = $computed(() => props.path.split('/')); + +let keys = $ref(null); + +function fetchKeys() { + os.api('i/registry/keys-with-type', { + scope: scope, + }).then(res => { + keys = Object.entries(res).sort((a, b) => a[0].localeCompare(b[0])); + }); +} + +async function createKey() { + const { canceled, result } = await os.form(i18n.ts._registry.createKey, { + key: { + type: 'string', + label: i18n.ts._registry.key, + }, + value: { + type: 'string', + multiline: true, + label: i18n.ts.value, + }, + scope: { + type: 'string', + label: i18n.ts._registry.scope, + default: scope.join('/'), + }, + }); + if (canceled) return; + os.apiWithDialog('i/registry/set', { + scope: result.scope.split('/'), + key: result.key, + value: JSON5.parse(result.value), + }).then(() => { + fetchKeys(); + }); +} + +watch(() => props.path, fetchKeys, { immediate: true }); + +const headerActions = $computed(() => []); + +const headerTabs = $computed(() => []); + +definePageMetadata({ + title: i18n.ts.registry, + icon: 'fas fa-cogs', +}); +</script> + +<style lang="scss" scoped> +</style> diff --git a/packages/client/src/pages/registry.value.vue b/packages/client/src/pages/registry.value.vue new file mode 100644 index 0000000000..5291b2e4c8 --- /dev/null +++ b/packages/client/src/pages/registry.value.vue @@ -0,0 +1,123 @@ +<template> +<MkStickyContainer> + <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> + <MkSpacer :content-max="600"> + <FormInfo warn>{{ $ts.editTheseSettingsMayBreakAccount }}</FormInfo> + + <template v-if="value"> + <FormSplit> + <MkKeyValue class="_formBlock"> + <template #key>{{ $ts._registry.domain }}</template> + <template #value>{{ $ts.system }}</template> + </MkKeyValue> + <MkKeyValue class="_formBlock"> + <template #key>{{ $ts._registry.scope }}</template> + <template #value>{{ scope.join('/') }}</template> + </MkKeyValue> + <MkKeyValue class="_formBlock"> + <template #key>{{ $ts._registry.key }}</template> + <template #value>{{ key }}</template> + </MkKeyValue> + </FormSplit> + + <FormTextarea v-model="valueForEditor" tall class="_formBlock _monospace"> + <template #label>{{ $ts.value }} (JSON)</template> + </FormTextarea> + + <MkButton class="_formBlock" primary @click="save"><i class="fas fa-save"></i> {{ $ts.save }}</MkButton> + + <MkKeyValue class="_formBlock"> + <template #key>{{ $ts.updatedAt }}</template> + <template #value><MkTime :time="value.updatedAt" mode="detail"/></template> + </MkKeyValue> + + <MkButton danger @click="del"><i class="fas fa-trash"></i> {{ $ts.delete }}</MkButton> + </template> + </MkSpacer> +</MkStickyContainer> +</template> + +<script lang="ts" setup> +import { ref, watch } from 'vue'; +import JSON5 from 'json5'; +import * as os from '@/os'; +import { i18n } from '@/i18n'; +import { definePageMetadata } from '@/scripts/page-metadata'; +import FormLink from '@/components/form/link.vue'; +import FormSection from '@/components/form/section.vue'; +import MkButton from '@/components/ui/button.vue'; +import MkKeyValue from '@/components/key-value.vue'; +import FormTextarea from '@/components/form/textarea.vue'; +import FormSplit from '@/components/form/split.vue'; +import FormInfo from '@/components/ui/info.vue'; + +const props = defineProps<{ + path: string; +}>(); + +const scope = $computed(() => props.path.split('/').slice(0, -1)); +const key = $computed(() => props.path.split('/').at(-1)); + +let value = $ref(null); +let valueForEditor = $ref(null); + +function fetchValue() { + os.api('i/registry/get-detail', { + scope, + key, + }).then(res => { + value = res; + valueForEditor = JSON5.stringify(res.value, null, '\t'); + }); +} + +async function save() { + try { + JSON5.parse(valueForEditor); + } catch (e) { + os.alert({ + type: 'error', + text: i18n.ts.invalidValue, + }); + return; + } + os.confirm({ + type: 'warning', + text: i18n.ts.saveConfirm, + }).then(({ canceled }) => { + if (canceled) return; + os.apiWithDialog('i/registry/set', { + scope, + key, + value: JSON5.parse(valueForEditor), + }); + }); +} + +function del() { + os.confirm({ + type: 'warning', + text: i18n.ts.deleteConfirm, + }).then(({ canceled }) => { + if (canceled) return; + os.apiWithDialog('i/registry/remove', { + scope, + key, + }); + }); +} + +watch(() => props.path, fetchValue, { immediate: true }); + +const headerActions = $computed(() => []); + +const headerTabs = $computed(() => []); + +definePageMetadata({ + title: i18n.ts.registry, + icon: 'fas fa-cogs', +}); +</script> + +<style lang="scss" scoped> +</style> diff --git a/packages/client/src/pages/registry.vue b/packages/client/src/pages/registry.vue new file mode 100644 index 0000000000..a428755a88 --- /dev/null +++ b/packages/client/src/pages/registry.vue @@ -0,0 +1,74 @@ +<template> +<MkStickyContainer> + <template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template> + <MkSpacer :content-max="600"> + <MkButton primary @click="createKey">{{ i18n.ts._registry.createKey }}</MkButton> + + <FormSection v-if="scopes"> + <template #label>{{ i18n.ts.system }}</template> + <div class="_formLinks"> + <FormLink v-for="scope in scopes" :to="`/registry/keys/system/${scope.join('/')}`" class="_monospace">{{ scope.join('/') }}</FormLink> + </div> + </FormSection> + </MkSpacer> +</MkStickyContainer> +</template> + +<script lang="ts" setup> +import { ref, watch } from 'vue'; +import JSON5 from 'json5'; +import * as os from '@/os'; +import { i18n } from '@/i18n'; +import { definePageMetadata } from '@/scripts/page-metadata'; +import FormLink from '@/components/form/link.vue'; +import FormSection from '@/components/form/section.vue'; +import MkButton from '@/components/ui/button.vue'; + +let scopes = $ref(null); + +function fetchScopes() { + os.api('i/registry/scopes').then(res => { + scopes = res.slice().sort((a, b) => a.join('/').localeCompare(b.join('/'))); + }); +} + +async function createKey() { + const { canceled, result } = await os.form(i18n.ts._registry.createKey, { + key: { + type: 'string', + label: i18n.ts._registry.key, + }, + value: { + type: 'string', + multiline: true, + label: i18n.ts.value, + }, + scope: { + type: 'string', + label: i18n.ts._registry.scope, + }, + }); + if (canceled) return; + os.apiWithDialog('i/registry/set', { + scope: result.scope.split('/'), + key: result.key, + value: JSON5.parse(result.value), + }).then(() => { + fetchScopes(); + }); +} + +fetchScopes(); + +const headerActions = $computed(() => []); + +const headerTabs = $computed(() => []); + +definePageMetadata({ + title: i18n.ts.registry, + icon: 'fas fa-cogs', +}); +</script> + +<style lang="scss" scoped> +</style> diff --git a/packages/client/src/pages/settings/other.vue b/packages/client/src/pages/settings/other.vue index 52ef4d401f..51dab04cfa 100644 --- a/packages/client/src/pages/settings/other.vue +++ b/packages/client/src/pages/settings/other.vue @@ -10,6 +10,8 @@ <FormLink to="/settings/account-info" class="_formBlock">{{ i18n.ts.accountInfo }}</FormLink> + <FormLink to="/registry" class="_formBlock"><template #icon><i class="fas fa-cogs"></i></template>{{ i18n.ts.registry }}</FormLink> + <FormLink to="/settings/delete-account" class="_formBlock"><template #icon><i class="fas fa-exclamation-triangle"></i></template>{{ i18n.ts.closeAccount }}</FormLink> </div> </template> diff --git a/packages/client/src/pages/settings/profile.vue b/packages/client/src/pages/settings/profile.vue index 121709f127..f30b0ccbdc 100644 --- a/packages/client/src/pages/settings/profile.vue +++ b/packages/client/src/pages/settings/profile.vue @@ -39,10 +39,10 @@ <div class="_formRoot"> <FormSplit v-for="(record, i) in fields" :min-width="250" class="_formBlock"> - <FormInput v-model="record.name"> + <FormInput v-model="record.name" small> <template #label>{{ i18n.ts._profile.metadataLabel }} #{{ i + 1 }}</template> </FormInput> - <FormInput v-model="record.value"> + <FormInput v-model="record.value" small> <template #label>{{ i18n.ts._profile.metadataContent }} #{{ i + 1 }}</template> </FormInput> </FormSplit> diff --git a/packages/client/src/router.ts b/packages/client/src/router.ts index 2ff41e9723..b61b77eeeb 100644 --- a/packages/client/src/router.ts +++ b/packages/client/src/router.ts @@ -154,6 +154,15 @@ export const routes = [{ path: '/channels', component: page(() => import('./pages/channels.vue')), }, { + path: '/registry/keys/system/:path(*)?', + component: page(() => import('./pages/registry.keys.vue')), +}, { + path: '/registry/value/system/:path(*)?', + component: page(() => import('./pages/registry.value.vue')), +}, { + path: '/registry', + component: page(() => import('./pages/registry.vue')), +}, { path: '/admin/file/:fileId', component: iAmModerator ? page(() => import('./pages/admin-file.vue')) : page(() => import('./pages/not-found.vue')), }, { diff --git a/packages/client/src/ui/_common_/navbar.vue b/packages/client/src/ui/_common_/navbar.vue index 3eb8c5a37c..e18f89113f 100644 --- a/packages/client/src/ui/_common_/navbar.vue +++ b/packages/client/src/ui/_common_/navbar.vue @@ -44,7 +44,7 @@ <button v-tooltip.noDelay.right="i18n.ts.note" class="item _button post" data-cy-open-post-form @click="os.post"> <i class="icon fas fa-pencil-alt fa-fw"></i><span class="text">{{ i18n.ts.note }}</span> </button> - <button v-click-anime v-tooltip.noDelay.right="i18n.ts.account" class="item _button account" @click="openAccountMenu"> + <button v-click-anime v-tooltip.noDelay.right="`${i18n.ts.account}: @${$i.username}`" class="item _button account" @click="openAccountMenu"> <MkAvatar :user="$i" class="avatar"/><MkAcct class="text" :user="$i"/> </button> </div> |