mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
fix IsAnonymous
This commit is contained in:
@@ -93,22 +93,28 @@ export async function DelBiliBlackList(id: number): Promise<APIRoot<unknown>> {
|
|||||||
id: id,
|
id: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function downloadConfigDirect<T>(name: string) {
|
||||||
|
return QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
|
||||||
|
name: name,
|
||||||
|
})
|
||||||
|
}
|
||||||
export async function downloadConfig<T>(name: string) {
|
export async function downloadConfig<T>(name: string) {
|
||||||
try {
|
try {
|
||||||
const resp = await QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
|
const resp = await QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
|
||||||
name: name,
|
name: name,
|
||||||
})
|
})
|
||||||
if (resp.code == 200) {
|
if (resp.code == 200) {
|
||||||
message.success('已获取配置文件')
|
console.log('已获取配置文件: ' + name)
|
||||||
return JSON.parse(resp.data) as T
|
return JSON.parse(resp.data) as T
|
||||||
} else if (resp.code == 404) {
|
} else if (resp.code == 404) {
|
||||||
message.error(`未找到名为 ${name} 的配置文件`)
|
console.error(`未找到名为 ${name} 的配置文件`)
|
||||||
} else {
|
} else {
|
||||||
message.error('获取失败: ' + resp.message)
|
console.error(`无法获取配置文件 [${name}]: ` + resp.message)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
message.error(`获取配置文件失败: ` + err)
|
console.error(`无法获取配置文件 [${name}]: ` + err)
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
export async function uploadConfig(name: string, data: unknown) {
|
export async function uploadConfig(name: string, data: unknown) {
|
||||||
try {
|
try {
|
||||||
@@ -117,11 +123,13 @@ export async function uploadConfig(name: string, data: unknown) {
|
|||||||
json: JSON.stringify(data),
|
json: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
if (resp.code == 200) {
|
if (resp.code == 200) {
|
||||||
message.success('已保存至服务器')
|
console.log('已保存配置文件至服务器:' + name)
|
||||||
|
return true
|
||||||
} else {
|
} else {
|
||||||
message.error('保存失败: ' + resp.message)
|
console.error('保存失败: ' + resp.message)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
message.error(`保存配置文件失败: ` + err)
|
console.error(`保存配置文件失败: ` + err)
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ export interface QAInfo {
|
|||||||
isPublic: boolean
|
isPublic: boolean
|
||||||
isFavorite: boolean
|
isFavorite: boolean
|
||||||
sendAt: number
|
sendAt: number
|
||||||
|
isAnonymous: boolean
|
||||||
}
|
}
|
||||||
export interface LotteryUserInfo {
|
export interface LotteryUserInfo {
|
||||||
name: string
|
name: string
|
||||||
|
|||||||
@@ -1,13 +1,56 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { FormRules, NForm } from 'naive-ui'
|
import { TemplateConfig } from '@/data/VTsuruTypes'
|
||||||
|
import { NButton, NEmpty, NForm, NFormItem, NInput, NUpload, UploadFileInfo, useMessage } from 'naive-ui'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
defineProps<{
|
const message = useMessage()
|
||||||
rules: FormRules
|
|
||||||
|
const props = defineProps<{
|
||||||
|
configData: any
|
||||||
|
config: TemplateConfig<any> | undefined
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
const fileList = ref<UploadFileInfo[]>([])
|
||||||
|
|
||||||
|
function OnFileListChange(files: UploadFileInfo[]) {
|
||||||
|
console.log(props.configData)
|
||||||
|
if (files.length == 1) {
|
||||||
|
var file = files[0]
|
||||||
|
if ((file.file?.size ?? 0) > 10 * 1024 * 1024) {
|
||||||
|
message.error('文件大小不能超过10MB')
|
||||||
|
fileList.value = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function onSubmit() {
|
||||||
|
console.log(props.configData)
|
||||||
|
}
|
||||||
|
|
||||||
function getItems() {}
|
function getItems() {}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NForm> </NForm>
|
<NEmpty v-if="!config" description="此模板不支持配置" />
|
||||||
|
<NForm v-else>
|
||||||
|
<NFormItem v-for="item in config.items" :key="item.name" :label="item.name">
|
||||||
|
<component v-if="item.type == 'render'" :is="item.render(configData)"></component>
|
||||||
|
<template v-else-if="item.type == 'string'">
|
||||||
|
<NInput :value="item.data.get(configData)" @update:value="item.data.set(configData, $event)" />
|
||||||
|
</template>
|
||||||
|
<NUpload
|
||||||
|
v-else-if="item.type == 'image'"
|
||||||
|
accept=".png,.jpg,.jpeg,.gif,.svg,.webp,.ico"
|
||||||
|
list-type="image-card"
|
||||||
|
:default-upload="false"
|
||||||
|
v-model:file-list="fileList"
|
||||||
|
@update:file-list="OnFileListChange"
|
||||||
|
:max="item.imageLimit"
|
||||||
|
>
|
||||||
|
上传图片
|
||||||
|
</NUpload>
|
||||||
|
</NFormItem>
|
||||||
|
<NFormItem>
|
||||||
|
<NButton type="primary" @click="onSubmit">提交</NButton>
|
||||||
|
</NFormItem>
|
||||||
|
</NForm>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,14 +2,37 @@ import { VNode } from 'vue'
|
|||||||
|
|
||||||
export type TemplateConfig<T> = {
|
export type TemplateConfig<T> = {
|
||||||
name: string
|
name: string
|
||||||
items: (TemplateConfigItem<T> | TemplateConfigImageItem<T>)[]
|
items: (TemplateConfigStringItem<T> | TemplateConfigNumberItem<T> | TemplateConfigStringArrayItem<T> | TemplateConfigNumberArrayItem<T> | TemplateConfigImageItem<T> | TemplateConfigRenderItem<T>)[]
|
||||||
onConfirm?: (arg0: T) => void
|
onConfirm?: (arg0: T) => void
|
||||||
}
|
}
|
||||||
interface TemplateConfigBase {
|
interface TemplateConfigBase {
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
export type TemplateConfigItem<T> = TemplateConfigBase & {
|
|
||||||
type: 'default'
|
type CommonProps = TemplateConfigBase
|
||||||
|
type DataAccessor<T, V> = {
|
||||||
|
get: (config: T) => V
|
||||||
|
set: (config: T, value: V) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
// 扩展 CommonProps 以包含额外的共有属性
|
||||||
|
export type TemplateConfigItemWithType<T, V> = CommonProps & { data: DataAccessor<T, V> }
|
||||||
|
|
||||||
|
export type TemplateConfigStringItem<T> = TemplateConfigItemWithType<T, string> & {
|
||||||
|
type: 'string'
|
||||||
|
}
|
||||||
|
export type TemplateConfigStringArrayItem<T> = TemplateConfigItemWithType<T, string[]> & {
|
||||||
|
type: 'stringArray'
|
||||||
|
}
|
||||||
|
export type TemplateConfigNumberItem<T> = TemplateConfigItemWithType<T, number> & {
|
||||||
|
type: 'number'
|
||||||
|
}
|
||||||
|
export type TemplateConfigNumberArrayItem<T> = TemplateConfigItemWithType<T, number[]> & {
|
||||||
|
type: 'numberArray'
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TemplateConfigRenderItem<T> = TemplateConfigBase & {
|
||||||
|
type: 'render'
|
||||||
render: (arg0: T) => VNode
|
render: (arg0: T) => VNode
|
||||||
}
|
}
|
||||||
export type TemplateConfigImageItem<T> = TemplateConfigBase & {
|
export type TemplateConfigImageItem<T> = TemplateConfigBase & {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import DefaultIndexTemplateVue from '@/views/view/indexTemplate/DefaultIndexTemplate.vue'
|
||||||
import { computed, defineAsyncComponent, ref, watchEffect } from 'vue'
|
import { computed, defineAsyncComponent, ref, watchEffect } from 'vue'
|
||||||
|
|
||||||
const debugAPI = import.meta.env.VITE_DEBUG_API
|
const debugAPI = import.meta.env.VITE_DEBUG_API
|
||||||
@@ -41,5 +42,5 @@ export const SongListTemplateMap = {
|
|||||||
simple: { name: '简单', compoent: defineAsyncComponent(() => import('@/views/view/songListTemplate/SimpleSongListTemplate.vue')) },
|
simple: { name: '简单', compoent: defineAsyncComponent(() => import('@/views/view/songListTemplate/SimpleSongListTemplate.vue')) },
|
||||||
} as { [key: string]: { name: string; compoent: any } }
|
} as { [key: string]: { name: string; compoent: any } }
|
||||||
export const IndexTemplateMap = {
|
export const IndexTemplateMap = {
|
||||||
'': { name: '默认', compoent: defineAsyncComponent(() => import('@/views/view/indexTemplate/DefaultIndexTemplate.vue')) },
|
'': { name: '默认', compoent: DefaultIndexTemplateVue },
|
||||||
} as { [key: string]: { name: string; compoent: any } }
|
} as { [key: string]: { name: string; compoent: any } }
|
||||||
|
|||||||
@@ -279,8 +279,8 @@ onMounted(() => {
|
|||||||
<NTag type="warning" size="tiny"> 未读 </NTag>
|
<NTag type="warning" size="tiny"> 未读 </NTag>
|
||||||
<NDivider vertical />
|
<NDivider vertical />
|
||||||
</template>
|
</template>
|
||||||
<NText :depth="item.sender?.name ? 1 : 3" style="margin-top: 3px">
|
<NText :depth="item.isAnonymous ? 3 : 1" style="margin-top: 3px">
|
||||||
{{ item.sender?.name ?? '匿名用户' }}
|
{{ item.isAnonymous ? '匿名用户' : item.sender?.name }}
|
||||||
</NText>
|
</NText>
|
||||||
<NTag v-if="item.isSenderRegisted" size="small" type="info" :bordered="false" style="margin-left: 5px"> 已注册 </NTag>
|
<NTag v-if="item.isSenderRegisted" size="small" type="info" :bordered="false" style="margin-left: 5px"> 已注册 </NTag>
|
||||||
<NTag v-if="item.isPublic" size="small" type="success" :bordered="false" style="margin-left: 5px"> 公开 </NTag>
|
<NTag v-if="item.isPublic" size="small" type="success" :bordered="false" style="margin-left: 5px"> 公开 </NTag>
|
||||||
|
|||||||
@@ -1,16 +1,19 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DelBiliBlackList, SaveAccountSettings, SaveEnableFunctions, useAccount } from '@/api/account'
|
import { DelBiliBlackList, SaveAccountSettings, SaveEnableFunctions, downloadConfigDirect, useAccount } from '@/api/account'
|
||||||
import { FunctionTypes, ScheduleWeekInfo, SongFrom, SongLanguage, SongRequestOption, SongsInfo } from '@/api/api-models'
|
import { FunctionTypes, ScheduleWeekInfo, SongFrom, SongLanguage, SongRequestOption, SongsInfo } from '@/api/api-models'
|
||||||
|
import DynamicForm from '@/components/DynamicForm.vue'
|
||||||
|
import { TemplateConfig } from '@/data/VTsuruTypes'
|
||||||
import { FETCH_API, IndexTemplateMap, ScheduleTemplateMap, SongListTemplateMap } from '@/data/constants'
|
import { FETCH_API, IndexTemplateMap, ScheduleTemplateMap, SongListTemplateMap } from '@/data/constants'
|
||||||
import { NButton, NCard, NCheckbox, NCheckboxGroup, NDivider, NEmpty, NList, NListItem, NModal, NSelect, NSpace, NSpin, NTabPane, NTabs, NText, SelectOption, useMessage } from 'naive-ui'
|
import { NButton, NCard, NCheckbox, NCheckboxGroup, NDivider, NEmpty, NList, NListItem, NModal, NSelect, NSpace, NSpin, NTabPane, NTabs, NText, SelectOption, useMessage } from 'naive-ui'
|
||||||
import { Ref, computed, h, onActivated, onMounted, ref } from 'vue'
|
import { computed, h, nextTick, onActivated, onMounted, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
|
||||||
interface TemplateDefineTypes {
|
interface TemplateDefineTypes {
|
||||||
TemplateMap: { [name: string]: { name: string; compoent: any } }
|
TemplateMap: { [name: string]: { name: string; compoent: any } }
|
||||||
Options: SelectOption[]
|
Options: SelectOption[]
|
||||||
Data: any
|
Data: any
|
||||||
Selected: Ref<string>
|
Selected: string
|
||||||
|
Config?: any | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const accountInfo = useAccount()
|
const accountInfo = useAccount()
|
||||||
@@ -19,7 +22,7 @@ const route = useRoute()
|
|||||||
|
|
||||||
const isSaving = ref(false)
|
const isSaving = ref(false)
|
||||||
|
|
||||||
const templates = {
|
const templates = ref({
|
||||||
index: {
|
index: {
|
||||||
TemplateMap: IndexTemplateMap,
|
TemplateMap: IndexTemplateMap,
|
||||||
Options: Object.entries(IndexTemplateMap).map((v) => ({
|
Options: Object.entries(IndexTemplateMap).map((v) => ({
|
||||||
@@ -27,7 +30,7 @@ const templates = {
|
|||||||
value: v[0],
|
value: v[0],
|
||||||
})),
|
})),
|
||||||
Data: null,
|
Data: null,
|
||||||
Selected: ref(accountInfo.value?.settings.indexTemplate ?? ''),
|
Selected: accountInfo.value?.settings.indexTemplate ?? '',
|
||||||
},
|
},
|
||||||
schedule: {
|
schedule: {
|
||||||
TemplateMap: ScheduleTemplateMap,
|
TemplateMap: ScheduleTemplateMap,
|
||||||
@@ -85,7 +88,7 @@ const templates = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
] as ScheduleWeekInfo[],
|
] as ScheduleWeekInfo[],
|
||||||
Selected: ref(accountInfo.value?.settings.scheduleTemplate ?? ''),
|
Selected: accountInfo.value?.settings.scheduleTemplate ?? '',
|
||||||
},
|
},
|
||||||
songlist: {
|
songlist: {
|
||||||
TemplateMap: SongListTemplateMap,
|
TemplateMap: SongListTemplateMap,
|
||||||
@@ -162,9 +165,9 @@ const templates = {
|
|||||||
updateTime: Date.now(),
|
updateTime: Date.now(),
|
||||||
},
|
},
|
||||||
] as SongsInfo[],
|
] as SongsInfo[],
|
||||||
Selected: ref(accountInfo.value?.settings.songListTemplate ?? ''),
|
Selected: accountInfo.value?.settings.songListTemplate ?? '',
|
||||||
},
|
},
|
||||||
} as { [type: string]: TemplateDefineTypes }
|
} as { [type: string]: TemplateDefineTypes })
|
||||||
|
|
||||||
const templateOptions = [
|
const templateOptions = [
|
||||||
{
|
{
|
||||||
@@ -183,7 +186,15 @@ const templateOptions = [
|
|||||||
const selectedOption = ref(route.query.template?.toString() ?? 'index')
|
const selectedOption = ref(route.query.template?.toString() ?? 'index')
|
||||||
const selectedTab = ref(route.query.tab?.toString() ?? 'general')
|
const selectedTab = ref(route.query.tab?.toString() ?? 'general')
|
||||||
|
|
||||||
const selectedTemplateData = computed(() => templates[selectedOption.value])
|
const dynamicConfigRef = ref()
|
||||||
|
const selectedTemplateData = computed(() => templates.value[selectedOption.value])
|
||||||
|
const selectedComponent = computed(() => selectedTemplateData.value?.TemplateMap[selectedTemplateData.value.Selected].compoent)
|
||||||
|
const selectedTemplateConfig = computed(() => {
|
||||||
|
if (dynamicConfigRef.value?.Config) {
|
||||||
|
return dynamicConfigRef.value?.Config as TemplateConfig<any>
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
})
|
||||||
|
|
||||||
const biliUserInfo = ref()
|
const biliUserInfo = ref()
|
||||||
const settingModalVisiable = ref(false)
|
const settingModalVisiable = ref(false)
|
||||||
@@ -245,23 +256,48 @@ async function SaveTemplateSetting() {
|
|||||||
if (accountInfo.value) {
|
if (accountInfo.value) {
|
||||||
switch (selectedOption.value) {
|
switch (selectedOption.value) {
|
||||||
case 'index': {
|
case 'index': {
|
||||||
accountInfo.value.settings.indexTemplate = selectedTemplateData.value.Selected.value ?? ''
|
accountInfo.value.settings.indexTemplate = selectedTemplateData.value.Selected ?? ''
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'songlist': {
|
case 'songlist': {
|
||||||
accountInfo.value.settings.songListTemplate = selectedTemplateData.value.Selected.value ?? ''
|
accountInfo.value.settings.songListTemplate = selectedTemplateData.value.Selected ?? ''
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'schedule': {
|
case 'schedule': {
|
||||||
accountInfo.value.settings.scheduleTemplate = selectedTemplateData.value.Selected.value ?? ''
|
accountInfo.value.settings.scheduleTemplate = selectedTemplateData.value.Selected ?? ''
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await SaveComboSetting()
|
await SaveComboSetting()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onOpenTemplateSettings() {
|
async function onOpenTemplateSettings() {
|
||||||
settingModalVisiable.value = true
|
settingModalVisiable.value = true
|
||||||
|
nextTick(async () => {
|
||||||
|
await getTemplateConfig()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
async function getTemplateConfig() {
|
||||||
|
if (selectedTemplateConfig.value && !selectedTemplateData.value.Config) {
|
||||||
|
await downloadConfigDirect(selectedTemplateConfig.value.name)
|
||||||
|
.then((data) => {
|
||||||
|
if (data.code == 200) {
|
||||||
|
message.success('已获取配置文件')
|
||||||
|
console.log(`已获取模板配置: ${selectedTemplateConfig.value?.name}`)
|
||||||
|
selectedTemplateData.value.Config = JSON.parse(data.data)
|
||||||
|
} else if (data.code == 404) {
|
||||||
|
//message.error(`未找到名为 ${name} 的配置文件`)
|
||||||
|
console.error(`未找到名为 ${selectedTemplateConfig.value?.name} 的配置文件`)
|
||||||
|
selectedTemplateData.value.Config = dynamicConfigRef.value.DefaultConfig
|
||||||
|
} else {
|
||||||
|
message.error('获取失败: ' + data.message)
|
||||||
|
console.error('获取失败: ' + data.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
message.error(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const buttonGroup = computed(() => {
|
const buttonGroup = computed(() => {
|
||||||
return h(NSpace, () => [h(NButton, { type: 'primary', onClick: () => SaveTemplateSetting() }, () => '设为展示模板'), h(NButton, { type: 'info', onClick: onOpenTemplateSettings }, () => '模板设置')])
|
return h(NSpace, () => [h(NButton, { type: 'primary', onClick: () => SaveTemplateSetting() }, () => '设为展示模板'), h(NButton, { type: 'info', onClick: onOpenTemplateSettings }, () => '模板设置')])
|
||||||
@@ -342,18 +378,13 @@ onMounted(async () => {
|
|||||||
<NDivider style="margin: 5px 0 5px 0" title-placement="left"> 模板 </NDivider>
|
<NDivider style="margin: 5px 0 5px 0" title-placement="left"> 模板 </NDivider>
|
||||||
<div>
|
<div>
|
||||||
<NSpace>
|
<NSpace>
|
||||||
<NSelect style="width: 150px" :options="selectedTemplateData.Options" v-model:value="selectedTemplateData.Selected.value" />
|
<NSelect style="width: 150px" :options="selectedTemplateData.Options" v-model:value="selectedTemplateData.Selected" />
|
||||||
<component :is="buttonGroup" />
|
<component :is="buttonGroup" />
|
||||||
</NSpace>
|
</NSpace>
|
||||||
<NDivider />
|
<NDivider />
|
||||||
<Transition name="fade" mode="out-in">
|
<Transition name="fade" mode="out-in">
|
||||||
<div v-if="true" :key="selectedTemplateData.Selected.value">
|
<div v-if="selectedComponent" :key="selectedTemplateData.Selected">
|
||||||
<component
|
<component ref="dynamicConfigRef" :is="selectedComponent" :user-info="accountInfo" :bili-info="biliUserInfo" :current-data="selectedTemplateData.Data" />
|
||||||
:is="selectedTemplateData.TemplateMap[selectedTemplateData.Selected.value].compoent"
|
|
||||||
:user-info="accountInfo"
|
|
||||||
:bili-info="biliUserInfo"
|
|
||||||
:current-data="selectedTemplateData.Data"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
</div>
|
</div>
|
||||||
@@ -362,5 +393,9 @@ onMounted(async () => {
|
|||||||
</NTabs>
|
</NTabs>
|
||||||
</NSpin>
|
</NSpin>
|
||||||
</NCard>
|
</NCard>
|
||||||
<NModal preset="card" v-model:show="settingModalVisiable" closable style="width: 600px; max-width: 90vw" title="模板设置"> 开发中... </NModal>
|
<NModal preset="card" v-model:show="settingModalVisiable" closable style="width: 600px; max-width: 90vw" title="模板设置">
|
||||||
|
只是测试, 没用
|
||||||
|
<NSpin v-if="!selectedTemplateData.Config" show />
|
||||||
|
<DynamicForm v-else :key="selectedTemplateData.Selected" :configData="selectedTemplateData.Config" :config="selectedTemplateConfig" />
|
||||||
|
</NModal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { isDarkMode } from '@/Utils'
|
import { isDarkMode } from '@/Utils'
|
||||||
import { UserInfo } from '@/api/api-models'
|
import { UserInfo } from '@/api/api-models'
|
||||||
|
import { TemplateConfig } from '@/data/VTsuruTypes'
|
||||||
import { NAvatar, NButton, NDivider, NSpace, NText } from 'naive-ui'
|
import { NAvatar, NButton, NDivider, NSpace, NText } from 'naive-ui'
|
||||||
|
|
||||||
const width = window.innerWidth
|
const width = window.innerWidth
|
||||||
@@ -13,6 +14,37 @@ const props = defineProps<{
|
|||||||
function navigate(url: string) {
|
function navigate(url: string) {
|
||||||
window.open(url, '_blank')
|
window.open(url, '_blank')
|
||||||
}
|
}
|
||||||
|
defineExpose({ Config, DefaultConfig })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export type ConfigType = {
|
||||||
|
cover: string
|
||||||
|
}
|
||||||
|
export const DefaultConfig = {} as ConfigType
|
||||||
|
export const Config: TemplateConfig<ConfigType> = {
|
||||||
|
name: 'Template.Index.Simple',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
name: '封面',
|
||||||
|
type: 'image',
|
||||||
|
imageLimit: 1,
|
||||||
|
onUploaded: (url, config) => {
|
||||||
|
config.cover = url instanceof String ? (url as string) : url[0]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'test',
|
||||||
|
type: 'string',
|
||||||
|
data: {
|
||||||
|
get: (d) => d.cover,
|
||||||
|
set: (d, v) => {
|
||||||
|
d.cover = v
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -15,25 +15,27 @@ function navigate(url: string) {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export type SimpleIndexConfig = {
|
export type ConfigType = {
|
||||||
cover?: string
|
cover?: string
|
||||||
}
|
}
|
||||||
export const Config: TemplateConfig<SimpleIndexConfig> = {
|
export const Config: TemplateConfig<ConfigType> = {
|
||||||
name: 'Template.Index.Simple',
|
name: 'Template.Index.Simple',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
name: '封面',
|
name: '封面',
|
||||||
type: 'image',
|
type: 'image',
|
||||||
imageLimit: 1,
|
imageLimit: 1,
|
||||||
onUploaded: (url, config) => {config.cover = (url instanceof String ? url as string : url[0])}
|
onUploaded: (url, config) => {
|
||||||
|
config.cover = url instanceof String ? (url as string) : url[0]
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'test',
|
name: 'test',
|
||||||
type: 'default',
|
type: 'render',
|
||||||
render: (config) => h('div', '1')
|
render: (config) => h('div', '1'),
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user