Refactor user settings (#209)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
1964814509
commit
5cbddd5d95
32 files changed
+2534
-1160
No files matched your search
@@ -23,69 +23,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="middle" />
|
||||
<div class="bottom">
|
||||
<div v-if="showSupport" class="link">
|
||||
<help-entry>
|
||||
<template #main>
|
||||
<el-button class="button">
|
||||
<font-awesome-icon icon="fa-solid fa-question" />
|
||||
</el-button>
|
||||
</template>
|
||||
</help-entry>
|
||||
</div>
|
||||
<div class="link">
|
||||
<el-tooltip effect="dark" :content="$t('common.nav.darkMode')" placement="right">
|
||||
<el-button class="button" @click="operating.dark = true">
|
||||
<font-awesome-icon icon="fa-solid fa-moon" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<dark-selector :visible="operating.dark" @close="operating.dark = false" />
|
||||
</div>
|
||||
<div class="link">
|
||||
<el-tooltip effect="dark" :content="$t('common.nav.locale')" placement="right">
|
||||
<el-button class="button" @click="operating.locale = true">
|
||||
<i class="icon">
|
||||
<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" width="1.2em" height="1.2em">
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"
|
||||
></path>
|
||||
</svg>
|
||||
</i>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<locale-selector :visible="operating.locale" @close="operating.locale = false" />
|
||||
</div>
|
||||
<div class="link">
|
||||
<el-tooltip effect="dark" :content="$t('common.nav.console')" placement="right">
|
||||
<el-button class="button" @click="onConsole">
|
||||
<font-awesome-icon icon="fa-solid fa-compass" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div v-if="showSite" class="link">
|
||||
<el-tooltip effect="dark" :content="$t('common.nav.site')" placement="right">
|
||||
<el-button class="button" @click="onSite">
|
||||
<font-awesome-icon icon="fa-solid fa-gear" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div v-if="showDistribution" class="link">
|
||||
<el-tooltip effect="dark" :content="$t('common.nav.distribution')" placement="right">
|
||||
<el-button class="button" @click="onDistribution">
|
||||
<font-awesome-icon icon="fa-solid fa-coins" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<div v-if="authenticated" class="link">
|
||||
<el-tooltip effect="dark" :content="$t('common.nav.logOut')" placement="right">
|
||||
<el-button class="button" @click="onLogout">
|
||||
<font-awesome-icon icon="fa-solid fa-arrow-right-from-bracket" />
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -93,13 +30,7 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElButton, ElTooltip } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import LocaleSelector from './LocaleSelector.vue';
|
||||
import DarkSelector from './DarkSelector.vue';
|
||||
import {
|
||||
ROUTE_CHATDOC_INDEX,
|
||||
ROUTE_CHATDOC_CONVERSATION,
|
||||
ROUTE_CHATDOC_MANAGE,
|
||||
ROUTE_CHATDOC_SETTING,
|
||||
ROUTE_CHAT_CONVERSATION,
|
||||
ROUTE_CHAT_CONVERSATION_NEW,
|
||||
ROUTE_CONSOLE_ROOT,
|
||||
@@ -128,11 +59,8 @@ export default defineComponent({
|
||||
name: 'Navigator',
|
||||
components: {
|
||||
ElButton,
|
||||
HelpEntry,
|
||||
LogoTiny,
|
||||
DarkSelector,
|
||||
ElTooltip,
|
||||
LocaleSelector,
|
||||
FontAwesomeIcon
|
||||
},
|
||||
props: {
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<el-form :model="site" class="form" label-width="auto" style="max-width: 600px">
|
||||
<el-form-item :label="$t('site.field.distributionDefaultInviterId')">
|
||||
{{ site.distribution?.default_inviter_id }}
|
||||
<edit-text
|
||||
:model-value="site.distribution?.default_inviter_id"
|
||||
:title="$t('site.title.editDistributionDefaultInviterId')"
|
||||
:placeholder="$t('site.placeholder.editDistributionDefaultInviterId')"
|
||||
@confirm="
|
||||
onSave({
|
||||
distribution: {
|
||||
...site.distribution,
|
||||
default_inviter_id: $event
|
||||
}
|
||||
})
|
||||
"
|
||||
/>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.distributionDefaultInviterIdTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('site.field.distributionForceInviterId')">
|
||||
{{ site.distribution?.force_inviter_id }}
|
||||
<edit-text
|
||||
:model-value="site.distribution?.force_inviter_id"
|
||||
:title="$t('site.title.editDistributionForceInviterId')"
|
||||
:placeholder="$t('site.placeholder.editDistributionForceInviterId')"
|
||||
@confirm="
|
||||
onSave({
|
||||
distribution: {
|
||||
...site.distribution,
|
||||
force_inviter_id: $event
|
||||
}
|
||||
})
|
||||
"
|
||||
/>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.distributionForceInviterIdTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElForm, ElFormItem } from 'element-plus';
|
||||
import EditText from '@/components/site/EditText.vue';
|
||||
import { siteOperator } from '@/operators';
|
||||
import site from '@/router/site';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SiteIndex',
|
||||
components: {
|
||||
EditText,
|
||||
ElForm,
|
||||
ElFormItem
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editing: {
|
||||
title: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
site() {
|
||||
return this.$store.getters.site;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSave(data: any) {
|
||||
const payload = {
|
||||
...this.site,
|
||||
...data
|
||||
};
|
||||
siteOperator.update(this.site?.id, payload).then(() => {
|
||||
console.debug('getSite for id', this.site?.id);
|
||||
this.$store.dispatch('getSite');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
padding: 30px;
|
||||
background-color: var(--el-bg-color-page);
|
||||
overflow-y: auto;
|
||||
h2.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
h4.title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.form {
|
||||
.logo {
|
||||
max-width: 200px;
|
||||
}
|
||||
.tip {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<el-form :model="site" class="form" label-width="auto" style="max-width: 600px">
|
||||
<el-form-item
|
||||
v-for="(feature, featureIndex) in [
|
||||
'chat',
|
||||
'midjourney',
|
||||
'qrart',
|
||||
'suno',
|
||||
'luma',
|
||||
'pika',
|
||||
'kling',
|
||||
'flux',
|
||||
'hailuo',
|
||||
'headshots',
|
||||
'support'
|
||||
]"
|
||||
:key="featureIndex"
|
||||
:label="$t('site.field.features' + feature.charAt(0).toUpperCase() + feature.slice(1))"
|
||||
>
|
||||
<div class="w-full">
|
||||
<el-switch
|
||||
:model-value="site.features[feature]?.enabled || false"
|
||||
inline-prompt
|
||||
:active-text="$t('site.button.enabled')"
|
||||
:inactive-text="$t('site.button.disabled')"
|
||||
@update:model-value="
|
||||
onSave({
|
||||
features: {
|
||||
...site.features,
|
||||
[feature]: {
|
||||
...site.features[feature],
|
||||
enabled: $event
|
||||
}
|
||||
}
|
||||
})
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<span class="block tip w-full">
|
||||
{{ $t('site.message.features' + feature.charAt(0).toUpperCase() + feature.slice(1)) }}
|
||||
</span>
|
||||
<div v-if="feature === 'support'" v-show="site.features[feature]?.enabled">
|
||||
<el-form-item label="WeChat">
|
||||
<el-switch
|
||||
:model-value="site.features[feature]?.wechat?.enabled || false"
|
||||
inline-prompt
|
||||
:active-text="$t('site.button.enabled')"
|
||||
:inactive-text="$t('site.button.disabled')"
|
||||
@update:model-value="
|
||||
onSave({
|
||||
features: {
|
||||
...site.features,
|
||||
[feature]: {
|
||||
...site.features[feature],
|
||||
wechat: {
|
||||
...site.features[feature]?.wechat,
|
||||
enabled: $event
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="site.features[feature]?.wechat?.enabled" :label="$t('site.field.qr')">
|
||||
<span class="block w-full">
|
||||
<el-image :src="site.features[feature]?.wechat?.qr" />
|
||||
<edit-image
|
||||
:model-value="site.features[feature]?.wechat?.qr"
|
||||
:title="$t('site.title.editQR')"
|
||||
:tip="$t('site.message.editQRTip')"
|
||||
@confirm="
|
||||
onSave({
|
||||
features: {
|
||||
...site.features,
|
||||
[feature]: {
|
||||
...site.features[feature],
|
||||
wechat: {
|
||||
...site.features[feature]?.wechat,
|
||||
qr: $event
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
"
|
||||
/>
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="Discord">
|
||||
<el-switch
|
||||
:model-value="site.features[feature]?.discord?.enabled || false"
|
||||
inline-prompt
|
||||
:active-text="$t('site.button.enabled')"
|
||||
:inactive-text="$t('site.button.disabled')"
|
||||
@update:model-value="
|
||||
onSave({
|
||||
features: {
|
||||
...site.features,
|
||||
[feature]: {
|
||||
...site.features[feature],
|
||||
discord: {
|
||||
...site.features[feature]?.discord,
|
||||
enabled: $event
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
"
|
||||
></el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="site.features[feature]?.discord?.enabled" :label="$t('site.field.url')">
|
||||
<span class="block w-full">
|
||||
{{ site.features[feature]?.discord?.url }}
|
||||
<edit-text
|
||||
:model-value="site.features[feature]?.discord?.url"
|
||||
:title="$t('site.title.editUrl')"
|
||||
:placeholder="$t('site.placeholder.editUrl')"
|
||||
@confirm="
|
||||
onSave({
|
||||
features: {
|
||||
...site.features,
|
||||
[feature]: {
|
||||
...site.features[feature],
|
||||
discord: {
|
||||
...site.features[feature]?.discord,
|
||||
url: $event
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
"
|
||||
/>
|
||||
</span>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElRow, ElCol, ElCard, ElForm, ElFormItem, ElImage, ElDivider, ElSwitch } from 'element-plus';
|
||||
import EditText from '@/components/site/EditText.vue';
|
||||
import EditImage from '@/components/site/EditImage.vue';
|
||||
import EditArray from '@/components/site/EditArray.vue';
|
||||
import { siteOperator } from '@/operators';
|
||||
import site from '@/router/site';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SiteIndex',
|
||||
components: {
|
||||
EditText,
|
||||
EditImage,
|
||||
ElImage,
|
||||
ElForm,
|
||||
ElSwitch,
|
||||
ElFormItem
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editing: {
|
||||
title: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
site() {
|
||||
return this.$store.getters.site;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSave(data: any) {
|
||||
const payload = {
|
||||
...this.site,
|
||||
...data
|
||||
};
|
||||
siteOperator.update(this.site?.id, payload).then(() => {
|
||||
console.debug('getSite for id', this.site?.id);
|
||||
this.$store.dispatch('getSite');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
padding: 30px;
|
||||
background-color: var(--el-bg-color-page);
|
||||
overflow-y: auto;
|
||||
h2.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
h4.title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.form {
|
||||
.logo {
|
||||
max-width: 200px;
|
||||
}
|
||||
.tip {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<label class="block mb-2 text-sm font-medium">{{ $t('common.settings.theme') }}</label>
|
||||
<theme-switcher />
|
||||
</div>
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<label class="block mb-2 text-sm font-medium">{{ $t('common.settings.language') }}</label>
|
||||
<locale-switcher />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import ThemeSwitcher from '@/components/user/Theme.vue';
|
||||
import LocaleSwitcher from '@/components/user/Locale.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'GeneralSettings',
|
||||
components: {
|
||||
ThemeSwitcher,
|
||||
LocaleSwitcher
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<el-form :model="site" class="form" label-width="auto" style="max-width: 600px">
|
||||
<el-form-item :label="$t('site.field.description')">
|
||||
<span class="block w-full">
|
||||
{{ site.description }}
|
||||
<edit-text
|
||||
:model-value="site.description"
|
||||
:title="$t('site.title.editDescription')"
|
||||
:placeholder="$t('site.placeholder.description')"
|
||||
@confirm="onSave({ description: $event })"
|
||||
/>
|
||||
</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.descriptionTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('site.field.keywords')">
|
||||
<span class="block w-full">
|
||||
{{ site.keywords?.join(', ') }}
|
||||
<edit-array
|
||||
:model-value="site?.keywords || []"
|
||||
:title="$t('site.title.editKeywords')"
|
||||
:placeholder="$t('site.placeholder.keywords')"
|
||||
:tip="$t('site.message.keywordsTip2')"
|
||||
@confirm="onSave({ keywords: $event })"
|
||||
/>
|
||||
</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.keywordsTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElRow, ElCol, ElCard, ElForm, ElFormItem, ElImage, ElDivider, ElSwitch } from 'element-plus';
|
||||
import EditText from '@/components/site/EditText.vue';
|
||||
import EditImage from '@/components/site/EditImage.vue';
|
||||
import EditArray from '@/components/site/EditArray.vue';
|
||||
import { siteOperator } from '@/operators';
|
||||
import site from '@/router/site';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SettingSeo',
|
||||
components: {
|
||||
EditText,
|
||||
EditArray,
|
||||
ElForm,
|
||||
ElFormItem
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editing: {
|
||||
title: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
site() {
|
||||
return this.$store.getters.site;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSave(data: any) {
|
||||
const payload = {
|
||||
...this.site,
|
||||
...data
|
||||
};
|
||||
siteOperator.update(this.site?.id, payload).then(() => {
|
||||
console.debug('getSite for id', this.site?.id);
|
||||
this.$store.dispatch('getSite');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
padding: 30px;
|
||||
background-color: var(--el-bg-color-page);
|
||||
overflow-y: auto;
|
||||
h2.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
h4.title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.form {
|
||||
.logo {
|
||||
max-width: 200px;
|
||||
}
|
||||
.tip {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<el-form :model="site" class="form" label-width="auto" style="max-width: 600px">
|
||||
<el-form-item :label="$t('site.field.origin')">
|
||||
<span class="block w-full">{{ site.origin }}</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.originTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('site.field.title')">
|
||||
<span class="block w-full">
|
||||
{{ site.title }}
|
||||
<edit-text
|
||||
:model-value="site.title"
|
||||
:title="$t('site.title.editTitle')"
|
||||
:placeholder="$t('site.placeholder.title')"
|
||||
@confirm="onSave({ title: $event })"
|
||||
/>
|
||||
</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.titleTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('site.field.logo')">
|
||||
<span class="block w-full">
|
||||
<el-image :src="site.logo" class="logo" />
|
||||
<edit-image
|
||||
:model-value="site.logo"
|
||||
:title="$t('site.title.editLogo')"
|
||||
:tip="$t('site.message.editLogoTip')"
|
||||
@confirm="onSave({ logo: $event })"
|
||||
/>
|
||||
</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.logoTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('site.field.favicon')">
|
||||
<span class="block w-full">
|
||||
<el-image :src="site.favicon" class="favicon" />
|
||||
<edit-image
|
||||
:model-value="site.favicon"
|
||||
:title="$t('site.title.editFavicon')"
|
||||
:tip="$t('site.message.editFaviconTip')"
|
||||
@confirm="onSave({ favicon: $event })"
|
||||
/>
|
||||
</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.faviconTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-divider border-style="dashed" />
|
||||
<el-form-item :label="$t('site.field.admins')">
|
||||
<span class="block w-full">
|
||||
{{ site.admins?.join(', ') }}
|
||||
<edit-array
|
||||
:model-value="site?.admins || []"
|
||||
:title="$t('site.title.editAdmins')"
|
||||
:placeholder="$t('site.placeholder.admins')"
|
||||
:tip="$t('site.message.adminsTip2')"
|
||||
:min="1"
|
||||
:min-error-message="$t('site.message.atLeastOneAdmin')"
|
||||
@confirm="onSave({ admins: $event })"
|
||||
/>
|
||||
</span>
|
||||
<span class="block tip">
|
||||
{{ $t('site.message.adminsTip') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElForm, ElFormItem, ElImage, ElDivider } from 'element-plus';
|
||||
import EditText from '@/components/site/EditText.vue';
|
||||
import EditImage from '@/components/site/EditImage.vue';
|
||||
import EditArray from '@/components/site/EditArray.vue';
|
||||
import { siteOperator } from '@/operators';
|
||||
import site from '@/router/site';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'SiteIndex',
|
||||
components: {
|
||||
EditText,
|
||||
EditImage,
|
||||
EditArray,
|
||||
ElDivider,
|
||||
ElImage,
|
||||
ElForm,
|
||||
ElFormItem
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editing: {
|
||||
title: false
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
site() {
|
||||
return this.$store.getters.site;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onSave(data: any) {
|
||||
const payload = {
|
||||
...this.site,
|
||||
...data
|
||||
};
|
||||
siteOperator.update(this.site?.id, payload).then(() => {
|
||||
console.debug('getSite for id', this.site?.id);
|
||||
this.$store.dispatch('getSite');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.panel {
|
||||
padding: 30px;
|
||||
background-color: var(--el-bg-color-page);
|
||||
overflow-y: auto;
|
||||
h2.title {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
h4.title {
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
.form {
|
||||
.logo {
|
||||
max-width: 200px;
|
||||
}
|
||||
.tip {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<img :src="user?.avatar || defaultAvatar" class="avatar" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import defaultAvatar from '@/assets/images/avatar.png';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UserAvatar',
|
||||
data() {
|
||||
return {
|
||||
defaultAvatar
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
user() {
|
||||
return this.$store.getters?.user;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
cursor: pointer;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<div class="relative inline-block text-left">
|
||||
<div @click="toggleMenu">
|
||||
<user-avatar class="cursor-pointer" />
|
||||
</div>
|
||||
<transition name="fade">
|
||||
<el-card v-if="showMenu" class="absolute right-0 mt-2 min-w-[220px] z-50 p-0">
|
||||
<div v-if="user.email" class="px-4 py-2 text-sm font-medium">
|
||||
{{ user?.email }}
|
||||
</div>
|
||||
<el-divider v-if="user.email" class="mb-1 mt-1" />
|
||||
<div class="py-1">
|
||||
<button class="block w-full px-4 py-2 text-left text-sm rounded-lg" @click="onSettings">
|
||||
<font-awesome-icon icon="fa-solid fa-cog" class="mr-1" />
|
||||
{{ $t('common.nav.setting') }}
|
||||
</button>
|
||||
<button class="block w-full px-4 py-2 text-left text-sm rounded-lg" @click="onDistribution">
|
||||
<font-awesome-icon icon="fa-solid fa-coins" class="mr-1" />
|
||||
{{ $t('common.nav.distribution') }}
|
||||
</button>
|
||||
<button class="block w-full px-4 py-2 text-left text-sm rounded-lg" @click="onConsole">
|
||||
<font-awesome-icon icon="fa-solid fa-compass" class="mr-1" />
|
||||
{{ $t('common.nav.console') }}
|
||||
</button>
|
||||
<button class="block w-full px-4 py-2 text-left text-sm rounded-lg" @click="onLogout">
|
||||
<font-awesome-icon icon="fa-solid fa-arrow-right-from-bracket" class="mr-1" />
|
||||
{{ $t('common.nav.logOut') }}
|
||||
</button>
|
||||
</div>
|
||||
</el-card>
|
||||
</transition>
|
||||
<user-setting v-model:visible="showSetting" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import UserAvatar from '@/components/user/Avatar.vue';
|
||||
import UserSetting from '@/components/user/Setting.vue';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { ROUTE_CONSOLE_ROOT, ROUTE_DISTRIBUTION_INDEX } from '@/router';
|
||||
import { ElDivider, ElCard } from 'element-plus';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UserCenter',
|
||||
components: { UserAvatar, UserSetting, FontAwesomeIcon, ElDivider, ElCard },
|
||||
data() {
|
||||
return {
|
||||
showMenu: false,
|
||||
showSetting: false
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
user() {
|
||||
return this.$store.getters?.user;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
document.addEventListener('click', this.closeMenu);
|
||||
},
|
||||
unmounted() {
|
||||
document.removeEventListener('click', this.closeMenu);
|
||||
},
|
||||
methods: {
|
||||
toggleMenu() {
|
||||
this.showMenu = !this.showMenu;
|
||||
},
|
||||
closeMenu(event: MouseEvent) {
|
||||
const target = event.target as HTMLElement;
|
||||
if (!this.$el.contains(target)) {
|
||||
this.showMenu = false;
|
||||
}
|
||||
},
|
||||
async onLogout() {
|
||||
await this.$store.dispatch('logout');
|
||||
},
|
||||
onConsole() {
|
||||
this.$router.push({ name: ROUTE_CONSOLE_ROOT });
|
||||
},
|
||||
onDistribution() {
|
||||
this.$router.push({
|
||||
name: ROUTE_DISTRIBUTION_INDEX
|
||||
});
|
||||
},
|
||||
onSettings() {
|
||||
this.showSetting = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.fade-enter-active,
|
||||
.fade-leave-active {
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
.fade-enter-from,
|
||||
.fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<el-dropdown trigger="click" @command="onSelectLocale">
|
||||
<span class="el-dropdown-link">
|
||||
{{ currentLabel }}
|
||||
<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="(locale, idx) in locales" :key="idx" :command="locale.value">
|
||||
{{ locale.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDropdown, ElDropdownMenu, ElDropdownItem, ElIcon } from 'element-plus';
|
||||
import { ArrowDown } from '@element-plus/icons-vue';
|
||||
import { SUPPORTED_LOCALES, setI18nLanguage } from '@/i18n';
|
||||
import { setCookie } from 'typescript-cookie';
|
||||
import { getDomain } from '@/utils/initializer';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'LocaleSelector',
|
||||
components: {
|
||||
ElDropdown,
|
||||
ElDropdownMenu,
|
||||
ElDropdownItem,
|
||||
ElIcon,
|
||||
ArrowDown
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
locales: SUPPORTED_LOCALES
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
value(): string {
|
||||
return this.$i18n.locale;
|
||||
},
|
||||
currentLabel(): string {
|
||||
const found = this.locales.find((l) => l.value === this.value);
|
||||
return found ? found.label : this.value;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async onSelectLocale(locale: string) {
|
||||
this.$router.push({ query: { ...this.$route.query, locale: undefined } });
|
||||
await setI18nLanguage(locale);
|
||||
setCookie('LOCALE', locale, {
|
||||
path: '/',
|
||||
domain: getDomain()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.el-dropdown-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
color: var(--el-text-color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
.el-icon--right {
|
||||
margin-left: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<el-dialog :model-value="visible" @close="onClose">
|
||||
<div class="flex settings">
|
||||
<aside class="w-56 border-r">
|
||||
<nav class="flex flex-col p-2 space-y-1">
|
||||
<button
|
||||
v-for="(item, index) in navItems"
|
||||
:key="index"
|
||||
:class="[
|
||||
'flex items-center px-4 py-2 text-sm rounded-lg cursor-pointer',
|
||||
activeTab === item.key ? 'active' : ''
|
||||
]"
|
||||
@click="activeTab = item.key"
|
||||
>
|
||||
<font-awesome-icon :icon="item.icon" class="mr-2" />
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</nav>
|
||||
</aside>
|
||||
<main class="flex-1 p-6 overflow-y-auto">
|
||||
<div v-if="activeTab === 'general'">
|
||||
<general-setting />
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'site' && isSiteAdmin">
|
||||
<site-setting />
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'seo' && isSiteAdmin">
|
||||
<seo-setting />
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'distribution' && isSiteAdmin">
|
||||
<distribution-setting />
|
||||
</div>
|
||||
<div v-else-if="activeTab === 'function' && isSiteAdmin">
|
||||
<function-setting />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDialog } from 'element-plus';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import { faCog, faBell, faUserShield, faMagic, faMoneyBill } from '@fortawesome/free-solid-svg-icons';
|
||||
import GeneralSetting from '@/components/setting/General.vue';
|
||||
import SiteSetting from '@/components/setting/Site.vue';
|
||||
import SeoSetting from '@/components/setting/Seo.vue';
|
||||
import DistributionSetting from '@/components/setting/Distribution.vue';
|
||||
import FunctionSetting from '@/components/setting/Function.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'UserSetting',
|
||||
components: {
|
||||
ElDialog,
|
||||
FontAwesomeIcon,
|
||||
GeneralSetting,
|
||||
SiteSetting,
|
||||
SeoSetting,
|
||||
DistributionSetting,
|
||||
FunctionSetting
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits: ['update:visible'],
|
||||
data() {
|
||||
return {
|
||||
activeTab: 'general',
|
||||
showSuggestions: true,
|
||||
navItems: [
|
||||
{ key: 'general', label: this.$t('common.settings.general'), icon: faCog },
|
||||
{ key: 'site', label: this.$t('common.settings.site'), icon: faBell },
|
||||
{ key: 'seo', label: this.$t('common.settings.seo'), icon: faUserShield },
|
||||
{ key: 'distribution', label: this.$t('common.settings.distribution'), icon: faMoneyBill },
|
||||
{ key: 'function', label: this.$t('common.settings.function'), icon: faMagic }
|
||||
]
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
currentTabTitle() {
|
||||
const current = this.navItems.find((item) => item.key === this.activeTab);
|
||||
return current ? current.label : '';
|
||||
},
|
||||
isSiteAdmin(): boolean {
|
||||
return !!this.$store?.state?.site?.admins?.includes(this.$store.getters.user?.id);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onClose() {
|
||||
this.$emit('update:visible', false);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.settings {
|
||||
height: 460px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<el-dropdown trigger="click" @command="onSelect">
|
||||
<span class="el-dropdown-link">
|
||||
{{ currentLabel }}
|
||||
<el-icon class="el-icon--right"><arrow-down /></el-icon>
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="light">{{ $t('common.theme.light') }}</el-dropdown-item>
|
||||
<el-dropdown-item command="dark">{{ $t('common.theme.dark') }}</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElDropdown, ElDropdownMenu, ElDropdownItem, ElIcon } from 'element-plus';
|
||||
import { getDomain } from '@/utils';
|
||||
import { getCookie, setCookie } from 'typescript-cookie';
|
||||
import { ArrowDown } from '@element-plus/icons-vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ThemeSelector',
|
||||
components: {
|
||||
ArrowDown,
|
||||
ElDropdown,
|
||||
ElDropdownMenu,
|
||||
ElDropdownItem,
|
||||
ElIcon
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
theme: 'light' as 'light' | 'dark'
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
currentLabel(): string {
|
||||
return this.theme === 'dark'
|
||||
? (this.$t('common.theme.dark') as string)
|
||||
: (this.$t('common.theme.light') as string);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.theme = this.loadFromCookie();
|
||||
this.applyTheme();
|
||||
},
|
||||
methods: {
|
||||
onSelect(command: 'light' | 'dark') {
|
||||
this.theme = command;
|
||||
this.applyTheme();
|
||||
},
|
||||
applyTheme() {
|
||||
setCookie('THEME', this.theme, {
|
||||
path: '/',
|
||||
domain: getDomain()
|
||||
});
|
||||
if (this.theme === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
},
|
||||
loadFromCookie(): 'light' | 'dark' {
|
||||
const saved = getCookie('THEME');
|
||||
return saved === 'dark' ? 'dark' : 'light';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.demonstration {
|
||||
margin-right: 8px;
|
||||
cursor: pointer;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
.el-dropdown-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
color: var(--el-text-color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user