mirror of
https://github.com/Megghy/vtsuru.live.git
synced 2025-12-07 02:46:55 +08:00
save
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { ACCOUNT_API_URL, BASE_API } from '@/data/constants'
|
|
||||||
import { APIRoot, AccountInfo, FunctionTypes } from './api-models'
|
|
||||||
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
import { QueryGetAPI, QueryPostAPI } from '@/api/query'
|
||||||
import { ref } from 'vue'
|
import { ACCOUNT_API_URL, VTSURU_API_URL } from '@/data/constants'
|
||||||
import { useLocalStorage } from '@vueuse/core'
|
import { useLocalStorage } from '@vueuse/core'
|
||||||
import { createDiscreteApi } from 'naive-ui'
|
|
||||||
import { isSameDay } from 'date-fns'
|
import { isSameDay } from 'date-fns'
|
||||||
|
import { createDiscreteApi } from 'naive-ui'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { APIRoot, AccountInfo, FunctionTypes } from './api-models'
|
||||||
|
|
||||||
export const ACCOUNT = ref<AccountInfo>()
|
export const ACCOUNT = ref<AccountInfo>()
|
||||||
export const isLoadingAccount = ref(true)
|
export const isLoadingAccount = ref(true)
|
||||||
@@ -93,3 +93,35 @@ export async function DelBiliBlackList(id: number): Promise<APIRoot<unknown>> {
|
|||||||
id: id,
|
id: id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export async function downloadConfig<T>(name: string) {
|
||||||
|
try {
|
||||||
|
const resp = await QueryGetAPI<string>(VTSURU_API_URL + 'get-config', {
|
||||||
|
name: name,
|
||||||
|
})
|
||||||
|
if (resp.code == 200) {
|
||||||
|
message.success('已获取配置文件')
|
||||||
|
return JSON.parse(resp.data) as T
|
||||||
|
} else if (resp.code == 404) {
|
||||||
|
message.error(`未找到名为 ${name} 的配置文件`)
|
||||||
|
} else {
|
||||||
|
message.error('获取失败: ' + resp.message)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
message.error(`获取配置文件失败: ` + err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export async function uploadConfig(name: string, data: unknown) {
|
||||||
|
try {
|
||||||
|
const resp = await QueryPostAPI(VTSURU_API_URL + 'set-config', {
|
||||||
|
name: name,
|
||||||
|
json: JSON.stringify(data),
|
||||||
|
})
|
||||||
|
if (resp.code == 200) {
|
||||||
|
message.success('已保存至服务器')
|
||||||
|
} else {
|
||||||
|
message.error('保存失败: ' + resp.message)
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
message.error(`保存配置文件失败: ` + err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
19
src/data/VTsuruTypes.ts
Normal file
19
src/data/VTsuruTypes.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
import { VNode } from 'vue'
|
||||||
|
|
||||||
|
export type TemplateConfig<T> = {
|
||||||
|
name: string
|
||||||
|
items: (TemplateConfigItem<T> | TemplateConfigImageItem<T>)[]
|
||||||
|
onConfirm?: (arg0: T) => void
|
||||||
|
}
|
||||||
|
interface TemplateConfigBase {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
export type TemplateConfigItem<T> = TemplateConfigBase & {
|
||||||
|
type: 'default'
|
||||||
|
render: (arg0: T) => VNode
|
||||||
|
}
|
||||||
|
export type TemplateConfigImageItem<T> = TemplateConfigBase & {
|
||||||
|
type: 'image'
|
||||||
|
imageLimit: number
|
||||||
|
onUploaded: (arg0: string | string[], arg1: T) => void
|
||||||
|
}
|
||||||
40
src/views/view/indexTemplate/SimpleIndexTemplate.vue
Normal file
40
src/views/view/indexTemplate/SimpleIndexTemplate.vue
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
import { UserInfo } from '@/api/api-models'
|
||||||
|
import { TemplateConfig } from '@/data/VTsuruTypes'
|
||||||
|
import { h } from 'vue'
|
||||||
|
|
||||||
|
const width = window.innerWidth
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
userInfo: UserInfo | undefined
|
||||||
|
biliInfo: any | undefined
|
||||||
|
currentData?: any
|
||||||
|
}>()
|
||||||
|
function navigate(url: string) {
|
||||||
|
window.open(url, '_blank')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export type SimpleIndexConfig = {
|
||||||
|
cover?: string
|
||||||
|
}
|
||||||
|
export const Config: TemplateConfig<SimpleIndexConfig> = {
|
||||||
|
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: 'default',
|
||||||
|
render: (config) => h('div', '1')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template></template>
|
||||||
Reference in New Issue
Block a user