feat(client): add profile widget

Resolve #7722
This commit is contained in:
syuilo 2023-01-09 20:23:06 +09:00
parent 3bc0cdbfb7
commit c179d6f735
4 changed files with 100 additions and 0 deletions

View File

@ -83,6 +83,7 @@ You should also include the user name that made the change.
- Client: Support remote objects in search @SoniEx2 - Client: Support remote objects in search @SoniEx2
- Client: user activity page @syuilo - Client: user activity page @syuilo
- Client: add user list widget @syuilo - Client: add user list widget @syuilo
- Client: add profile widget @syuilo
- Client: add heatmap of daily active users to about page @syuilo - Client: add heatmap of daily active users to about page @syuilo
- Client: introduce fluent emoji @syuilo - Client: introduce fluent emoji @syuilo
- Client: add new theme @syuilo - Client: add new theme @syuilo

View File

@ -1335,6 +1335,7 @@ _weekday:
saturday: "土曜日" saturday: "土曜日"
_widgets: _widgets:
profile: "プロフィール"
memo: "付箋" memo: "付箋"
notifications: "通知" notifications: "通知"
timeline: "タイムライン" timeline: "タイムライン"

View File

@ -1,6 +1,7 @@
import { App, defineAsyncComponent } from 'vue'; import { App, defineAsyncComponent } from 'vue';
export default function(app: App) { export default function(app: App) {
app.component('MkwProfile', defineAsyncComponent(() => import('./profile.vue')));
app.component('MkwMemo', defineAsyncComponent(() => import('./memo.vue'))); app.component('MkwMemo', defineAsyncComponent(() => import('./memo.vue')));
app.component('MkwNotifications', defineAsyncComponent(() => import('./notifications.vue'))); app.component('MkwNotifications', defineAsyncComponent(() => import('./notifications.vue')));
app.component('MkwTimeline', defineAsyncComponent(() => import('./timeline.vue'))); app.component('MkwTimeline', defineAsyncComponent(() => import('./timeline.vue')));
@ -29,6 +30,7 @@ export default function(app: App) {
} }
export const widgets = [ export const widgets = [
'profile',
'memo', 'memo',
'notifications', 'notifications',
'timeline', 'timeline',

View File

@ -0,0 +1,96 @@
<template>
<div class="_panel">
<div :class="$style.container" :style="{ backgroundImage: $i.bannerUrl ? `url(${ $i.bannerUrl })` : null }">
<div :class="$style.avatarContainer">
<MkAvatar :class="$style.avatar" :user="$i" :disable-link="true" :disable-preview="true"/>
</div>
<div :class="$style.bodyContainer">
<div :class="$style.body">
<MkA v-once :class="$style.name" :to="userPage($i)">
<MkUserName :user="$i"/>
</MkA>
<div :class="$style.username"><MkAcct :user="$i" detail/></div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import { onMounted, onUnmounted, Ref, ref, watch } from 'vue';
import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
import { GetFormResultType } from '@/scripts/form';
import { $i } from '@/account';
import { userPage } from '@/filters/user';
const name = 'profile';
const widgetPropsDef = {
};
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
// vueimporttype
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
const props = defineProps<{ widget?: Widget<WidgetProps>; }>();
const emit = defineEmits<{ (ev: 'updateProps', props: WidgetProps); }>();
const { widgetProps, configure } = useWidgetPropsManager(name,
widgetPropsDef,
props,
emit,
);
defineExpose<WidgetComponentExpose>({
name,
configure,
id: props.widget ? props.widget.id : null,
});
</script>
<style lang="scss" module>
.container {
position: relative;
background-size: cover;
background-position: center;
display: flex;
}
.avatarContainer {
display: inline-block;
text-align: center;
padding: 16px;
}
.avatar {
display: inline-block;
width: 60px;
height: 60px;
box-sizing: border-box;
border: solid 3px #fff;
}
.bodyContainer {
display: flex;
align-items: center;
min-width: 0;
padding: 0 16px 0 0;
}
.body {
text-overflow: ellipsis;
overflow: clip;
}
.name {
color: #fff;
filter: drop-shadow(0 0 4px #000);
font-weight: bold;
}
.username {
color: #fff;
filter: drop-shadow(0 0 4px #000);
}
</style>