Skip to content

Commit

Permalink
feat: 新增主题选择
Browse files Browse the repository at this point in the history
  • Loading branch information
vastsa committed Nov 28, 2024
1 parent ae2d9f0 commit 651e9c5
Show file tree
Hide file tree
Showing 126 changed files with 98 additions and 39 deletions.
1 change: 1 addition & 0 deletions apps/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async def update_config(
config_service: ConfigService = Depends(get_config_service),
admin: bool = Depends(admin_required)
):
data.pop('themesChoices')
await config_service.update_config(data)
return APIResponse()

Expand Down
16 changes: 15 additions & 1 deletion core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# @Author : Lan
# @File : settings.py
# @Software: PyCharm
import json
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -43,6 +42,21 @@
'opacity': 0.9,
'background': '',
'uploadCount': 10,
'themesChoices': [
{
'name': '2023',
'key': 'themes/2023',
'author': 'Lan',
'version': '1.0',
},
{
'name': '2024',
'key': 'themes/2024',
'author': 'Lan',
'version': '1.0',
}
],
'themesSelect': 'themes/2024',
'errorMinute': 1,
'errorCount': 1,
'port': 12345,
Expand Down
29 changes: 29 additions & 0 deletions fcb-fronted/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,39 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
CardTools: typeof import('./src/components/CardTools.vue')['default']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCol: typeof import('element-plus/es')['ElCol']
ElContainer: typeof import('element-plus/es')['ElContainer']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDrawer: typeof import('element-plus/es')['ElDrawer']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']
ElUpload: typeof import('element-plus/es')['ElUpload']
FileBox: typeof import('./src/components/FileBox.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
UploadFile: typeof import('./src/components/UploadFile.vue')['default']
UploadText: typeof import('./src/components/UploadText.vue')['default']
}
export interface ComponentCustomProperties {
vLoading: typeof import('element-plus/es')['ElLoadingDirective']
}
}
1 change: 0 additions & 1 deletion fcb-fronted/dist/assets/SystemSettingsView-1vhqorKt.js

This file was deleted.

1 change: 0 additions & 1 deletion fcb-fronted/dist_old/assets/SettingView-B73Vn17x.js

This file was deleted.

1 change: 1 addition & 0 deletions fcb-fronted/src/locals/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
explain: 'Interface Instructions',
errorlimit: 'Error Limit',
keywords: 'Keywords',
themeSelect: 'Theme Selection',
notify_title: 'Notification Title',
notify_content: 'Notification Content',
background: 'Background Image',
Expand Down
1 change: 1 addition & 0 deletions fcb-fronted/src/locals/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
explain: 'Descripción de la interfaz',
errorlimit: 'Límite de errores',
keywords: 'Palabras clave',
themeSelect: 'Selección de tema',
notify_title: 'Título de notificación',
notify_content: 'Contenido de notificación',
background: 'Imagen de fondo',
Expand Down
1 change: 1 addition & 0 deletions fcb-fronted/src/locals/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
explain:'界面说明',
errorlimit: '错误限制',
keywords: '关键词',
themeSelect: '主题选择',
notify_title: '通知标题',
notify_content: '通知内容',
background: '背景图片',
Expand Down
1 change: 1 addition & 0 deletions fcb-fronted/src/locals/zh_cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
explain:'界面说明',
errorlimit: '错误限制',
keywords: '关键词',
themeSelect: '主题选择',
notify_title: '通知标题',
notify_content: '通知内容',
background: '背景图片',
Expand Down
1 change: 1 addition & 0 deletions fcb-fronted/src/locals/zh_tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
explain: '界面說明',
errorlimit: '錯誤限制',
keywords: '關鍵詞',
themeSelect: 'Theme選擇',
notify_title: '通知標題',
notify_content: '通知內容',
background: '背景圖片',
Expand Down
13 changes: 12 additions & 1 deletion fcb-fronted/src/views/Admin/SettingView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
<el-form-item size="large" :label="t('admin.settings.keywords')" style="letter-spacing: 0.3rem">
<el-input v-model="config.keywords" />
</el-form-item>
<el-form-item size="large" :label="t('admin.settings.themeSelect')" >
<el-select
v-model="config.themesSelect"
multiple
style="width: 100%"
>
<el-option v-for="item in config.themesChoices" :label="item.name" :value="item.key" />
</el-select>
</el-form-item>
<el-form-item size="large" :label="t('admin.settings.notify_title')">
<el-input v-model="config.notify_title" />
</el-form-item>
Expand Down Expand Up @@ -139,11 +148,13 @@ import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const config = ref({
const config:any = ref({
name: '',
description: '',
file_storage: '',
expireStyle: [],
themesChoices: [],
themesSelect: '',
admin_token: '',
robotsText:'',
keywords: '',
Expand Down
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async def lifespan(app: FastAPI):

# 加载配置
await load_config()
app.mount('/assets', StaticFiles(directory=f'./{settings.themesSelect}/assets'), name="assets")

try:
yield
Expand Down Expand Up @@ -75,8 +76,6 @@ async def load_config():
allow_headers=["*"],
)

app.mount('/assets', StaticFiles(directory='./fcb-fronted/dist/assets'), name="assets")

# 使用 register_tortoise 来添加异常处理器
register_tortoise(
app,
Expand All @@ -100,7 +99,7 @@ async def load_config():
@app.get('/')
async def index():
return HTMLResponse(
content=open(BASE_DIR / 'fcb-fronted/dist/index.html', 'r', encoding='utf-8').read()
content=open(BASE_DIR / f'{settings.themesSelect}/index.html', 'r', encoding='utf-8').read()
.replace('{{title}}', str(settings.name))
.replace('{{description}}', str(settings.description))
.replace('{{keywords}}', str(settings.keywords))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 651e9c5

Please sign in to comment.