songjianet
3 years ago
committed by
GitHub
13 changed files with 266 additions and 17 deletions
@ -0,0 +1,49 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { defineComponent } from 'vue' |
||||
import { useI18n } from 'vue-i18n' |
||||
import { NButton } from 'naive-ui' |
||||
import Card from '@/components/card' |
||||
import Info from './info' |
||||
|
||||
const profile = defineComponent({ |
||||
name: 'profile', |
||||
setup() { |
||||
const { t } = useI18n() |
||||
|
||||
return { t } |
||||
}, |
||||
render() { |
||||
const { t } = this |
||||
|
||||
return ( |
||||
<Card title={t('profile.profile')}> |
||||
{{ |
||||
default: () => <Info />, |
||||
'header-extra': () => ( |
||||
<NButton type='info' size='small'> |
||||
{t('profile.edit')} |
||||
</NButton> |
||||
), |
||||
}} |
||||
</Card> |
||||
) |
||||
}, |
||||
}) |
||||
|
||||
export default profile |
@ -0,0 +1,29 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
.container { |
||||
> .item { |
||||
display: flex; |
||||
justify-content: flex-start; |
||||
align-items: center; |
||||
|
||||
> .label { |
||||
display: inline-block; |
||||
width: 100px; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,43 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { defineComponent } from 'vue' |
||||
import { useProfile } from './use-profile' |
||||
import styles from './info.module.scss' |
||||
|
||||
const Info = defineComponent({ |
||||
name: 'Info', |
||||
setup() {}, |
||||
render() { |
||||
const { infoOptions } = useProfile() |
||||
|
||||
return ( |
||||
<dl class={styles.container}> |
||||
{infoOptions.value.map((item) => { |
||||
return ( |
||||
<dd class={styles.item}> |
||||
<span class={styles.label}>{item.key}: </span> |
||||
<span>{item.value}</span> |
||||
</dd> |
||||
) |
||||
})} |
||||
</dl> |
||||
) |
||||
}, |
||||
}) |
||||
|
||||
export default Info |
@ -0,0 +1,23 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
interface InfoProps { |
||||
key: string |
||||
value: string | number | undefined |
||||
} |
||||
|
||||
export { InfoProps } |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
import { ref } from 'vue' |
||||
import { useUserStore } from '@/store/user/user' |
||||
import { useI18n } from 'vue-i18n' |
||||
import type { UserInfoRes } from '@/service/modules/users/types' |
||||
import type { InfoProps } from './types' |
||||
import type { Ref } from 'vue' |
||||
|
||||
export function useProfile() { |
||||
const { t } = useI18n() |
||||
const userStore = useUserStore() |
||||
const userInfo = userStore.getUserInfo as UserInfoRes |
||||
const infoOptions: Ref<Array<InfoProps>> = ref([]) |
||||
|
||||
infoOptions.value.push({ |
||||
key: t('profile.username'), |
||||
value: userInfo.userName, |
||||
}) |
||||
infoOptions.value.push({ key: t('profile.email'), value: userInfo.email }) |
||||
infoOptions.value.push({ key: t('profile.phone'), value: userInfo.phone }) |
||||
infoOptions.value.push({ |
||||
key: t('profile.permission'), |
||||
value: userInfo.userName, |
||||
}) |
||||
infoOptions.value.push({ |
||||
key: t('profile.create_time'), |
||||
value: userInfo.createTime, |
||||
}) |
||||
infoOptions.value.push({ |
||||
key: t('profile.update_time'), |
||||
value: userInfo.updateTime, |
||||
}) |
||||
|
||||
return { |
||||
infoOptions, |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
Loading…
Reference in new issue