generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support moment user center (#68)
#### What type of PR is this? /kind feature #### What this PR does / why we need it: 支持在个人中心发布瞬间 #### How to test it? 在个人中心发布瞬间,并测试相关权限是否正常。 #### Which issue(s) this PR fixes: Fixes #47 Fixes #53 #### Does this PR introduce a user-facing change? ```release-note 适配在个人中心发布瞬间 ```
- Loading branch information
Showing
30 changed files
with
1,786 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,5 @@ build { | |
|
||
halo { | ||
version = '2.12.0' | ||
debug = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<script lang="ts" setup> | ||
import { | ||
IconArrowDown, | ||
IconClose, | ||
VDropdown, | ||
VDropdownItem, | ||
} from "@halo-dev/components"; | ||
import { computed } from "vue"; | ||
const props = withDefaults( | ||
defineProps<{ | ||
items: { | ||
label: string; | ||
value?: string | boolean | number; | ||
}[]; | ||
label: string; | ||
modelValue?: string | boolean | number; | ||
}>(), | ||
{ | ||
modelValue: undefined, | ||
} | ||
); | ||
const emit = defineEmits<{ | ||
( | ||
event: "update:modelValue", | ||
modelValue: string | boolean | number | undefined | ||
): void; | ||
}>(); | ||
const selectedItem = computed(() => { | ||
return props.items.find((item) => item.value === props.modelValue); | ||
}); | ||
function handleSelect(item: { | ||
label: string; | ||
value?: string | boolean | number; | ||
}) { | ||
if (item.value === props.modelValue) { | ||
emit("update:modelValue", undefined); | ||
return; | ||
} | ||
emit("update:modelValue", item.value); | ||
} | ||
const handleClear = (event: Event) => { | ||
emit("update:modelValue", undefined); | ||
event.stopPropagation(); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<VDropdown> | ||
<div | ||
class="filter-dropdown moments-group" | ||
:class="{ | ||
'moments-font-semibold moments-text-gray-700': modelValue !== undefined, | ||
}" | ||
> | ||
<span v-if="!selectedItem" class="mr-0.5"> | ||
{{ label }} | ||
</span> | ||
<span v-else class="mr-0.5"> {{ label }}:{{ selectedItem.label }} </span> | ||
<span class="moments-text-base"> | ||
<IconArrowDown | ||
:class="{ 'group-hover:moments-hidden': modelValue !== undefined }" | ||
/> | ||
<IconClose | ||
v-if="modelValue !== undefined" | ||
class="moments-hidden group-hover:moments-block" | ||
@click="handleClear" | ||
/> | ||
</span> | ||
</div> | ||
<template #popper> | ||
<VDropdownItem | ||
v-for="(item, index) in items" | ||
:key="index" | ||
:selected="item.value === modelValue" | ||
@click="handleSelect(item)" | ||
> | ||
{{ item.label }} | ||
</VDropdownItem> | ||
</template> | ||
</VDropdown> | ||
</template> | ||
<style scoped lang="scss"> | ||
.filter-dropdown { | ||
@apply moments-flex moments-cursor-pointer moments-select-none moments-items-center moments-text-sm moments-leading-9 moments-px-3 moments-text-gray-700 moments-rounded-lg hover:moments-text-black; | ||
border: 1px solid rgb(209 213 219); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.