bugfix
This commit is contained in:
parent
89540c210f
commit
8699dafdba
@ -1,5 +1,7 @@
|
|||||||
// import axios from "axios";
|
// import axios from "axios";
|
||||||
|
|
||||||
|
import FetchWrapper from "../utils/FetchWapper";
|
||||||
|
|
||||||
export const schema = [
|
export const schema = [
|
||||||
{ name: 'title', label: '标题', type: 'input' },
|
{ name: 'title', label: '标题', type: 'input' },
|
||||||
{ name: 'body', label: '内容', type: 'input' },
|
{ name: 'body', label: '内容', type: 'input' },
|
||||||
@ -18,7 +20,34 @@ export type cardType = {
|
|||||||
btnHref?: string | null
|
btnHref?: string | null
|
||||||
};
|
};
|
||||||
|
|
||||||
function getData() {
|
export function getDatas(url: string, cards: cardType[]) {
|
||||||
|
console.log(url);
|
||||||
|
FetchWrapper.fetch(url, { timeout: 3000 })
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
// throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
console.log(response);
|
||||||
|
return response.json();
|
||||||
|
}).then(jsonData => {
|
||||||
|
console.log('JSON Data:', jsonData);
|
||||||
|
if (!jsonData) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
cards.length = 0;
|
||||||
|
jsonData.datas.forEach((i: cardType) => {
|
||||||
|
const item = { ...jsonData.default_item, ...i }
|
||||||
|
cards.push({
|
||||||
|
title: item.title,
|
||||||
|
body: item.intro,
|
||||||
|
jumpHerf: item.url
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setData() {
|
function setData() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="outerContainer" @wheel.stop="handleWheel">
|
<div ref="outerContainer" @wheel.stop="handleWheel">
|
||||||
<iframe ref="frameRef" :src="frameUrl" :style="frameStyle"/>
|
<iframe ref="frameRef" :src="frameUrl" :srcdoc="frameDoc" :style="frameStyle"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -8,9 +8,13 @@
|
|||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
'frameUrl': {
|
frameUrl: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
default: undefined
|
||||||
|
},
|
||||||
|
frameDoc: {
|
||||||
|
type: String,
|
||||||
|
default: undefined
|
||||||
},
|
},
|
||||||
height: {
|
height: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"file_api": {
|
"file_api": {
|
||||||
|
"root_url": "/api/files",
|
||||||
"cards": {
|
"cards": {
|
||||||
"type": "json",
|
"type": "json",
|
||||||
"base_url": "/api/files/cards",
|
"url": "cards",
|
||||||
"home_json": "index-content.json"
|
"home": "index-content"
|
||||||
},
|
},
|
||||||
"notes": {
|
"notes": {
|
||||||
"type": "html",
|
"type": "html",
|
||||||
"base_url": "/api/files/notes"
|
"url": "notes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,35 +16,25 @@ import Footer from "@/components/Footer.vue"
|
|||||||
// import axios, { AxiosError } from "axios"
|
// import axios, { AxiosError } from "axios"
|
||||||
import router from "@/router"
|
import router from "@/router"
|
||||||
import FetchWrapper from "@/components/utils/FetchWapper";
|
import FetchWrapper from "@/components/utils/FetchWapper";
|
||||||
import type { cardType } from "@/components/cards/Card";
|
import { getDatas, type cardType } from "@/components/cards/Card";
|
||||||
import CardsManager from "@/components/cards/CardsManager.vue";
|
import CardsManager from "@/components/cards/CardsManager.vue";
|
||||||
|
|
||||||
import { file_api } from '@/assets/config.json'
|
import { file_api } from '@/config/config.json';
|
||||||
|
|
||||||
const props = defineProps(['user_name', 'pages_name', 'token'])
|
const props = defineProps(['user_name', 'pages_name', 'token'])
|
||||||
|
|
||||||
let isShowEdit = ref(false)
|
let isShowEdit = ref(false)
|
||||||
let TOKEN = ref("")
|
let TOKEN = ref("")
|
||||||
|
|
||||||
|
const cardUrl = (
|
||||||
|
`${file_api.root_url}/` +
|
||||||
|
`${file_api.cards.url}/` +
|
||||||
|
`${props.pages_name}?` +
|
||||||
|
`type=${file_api.cards.type}`
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
FetchWrapper.fetch(`${file_api.cards.base_url}/${props.pages_name}.json`, { timeout: 3000 })
|
getDatas(cardUrl, cardsData.value);
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
}).then(body => {
|
|
||||||
console.log(body)
|
|
||||||
body.datas.forEach((i:any) => {
|
|
||||||
const item = {...body.default_item, ...i}
|
|
||||||
cardsData.value.push({
|
|
||||||
title: item.title,
|
|
||||||
body: item.intro,
|
|
||||||
jumpHerf: item.url
|
|
||||||
})
|
|
||||||
})
|
|
||||||
console.log(cardsData.value)
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let cardsData = ref<cardType[]>([])
|
let cardsData = ref<cardType[]>([])
|
||||||
|
@ -32,13 +32,12 @@ import { onMounted, ref, watch } from "vue"
|
|||||||
import Navbar from "@/components/Navbar.vue"
|
import Navbar from "@/components/Navbar.vue"
|
||||||
import Hero from "@/components/Hero.vue"
|
import Hero from "@/components/Hero.vue"
|
||||||
import Footer from "@/components/Footer.vue"
|
import Footer from "@/components/Footer.vue"
|
||||||
import { type cardType } from "@/components/cards/Card"
|
import { type cardType, getDatas } from "@/components/cards/Card"
|
||||||
import CardsManager from "@/components/cards/CardsManager.vue"
|
import CardsManager from "@/components/cards/CardsManager.vue"
|
||||||
import FetchWrapper from "@/components/utils/FetchWapper"
|
|
||||||
import { useRouter } from "vue-router"
|
import { useRouter } from "vue-router"
|
||||||
import Alert from "@/components/utils/Alert.vue"
|
import Alert from "@/components/utils/Alert.vue"
|
||||||
|
|
||||||
import { file_api } from "@/assets/config.json"
|
import { file_api } from "@/config/config.json"
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
@ -55,29 +54,15 @@ function checkHandle() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const cardUrl = `${file_api.cards.base_url}/${file_api.cards.home_json}`
|
const cardUrl = (
|
||||||
|
`${file_api.root_url}/` +
|
||||||
|
`${file_api.cards.url}/` +
|
||||||
|
`${file_api.cards.home}?` +
|
||||||
|
`type=${file_api.cards.type}`
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
FetchWrapper.fetch(cardUrl, { timeout: 3000 })
|
getDatas(cardUrl, cards.value)
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
}).then(body => {
|
|
||||||
if (!body.datas) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cards.value.length = 0;
|
|
||||||
body.datas.forEach((i: cardType) => {
|
|
||||||
const item = {...body.default_item, ...i}
|
|
||||||
cards.value.push({
|
|
||||||
title: item.title,
|
|
||||||
body: item.intro,
|
|
||||||
jumpHerf: item.url
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let cards = ref<cardType[]>([
|
let cards = ref<cardType[]>([
|
||||||
@ -93,7 +78,7 @@ let cards = ref<cardType[]>([
|
|||||||
{
|
{
|
||||||
title: "404",
|
title: "404",
|
||||||
body: "note",
|
body: "note",
|
||||||
jumpHerf: '/note/Style Guide for C.html',
|
jumpHerf: '/note/Style Guide for C',
|
||||||
imgSrc: null,
|
imgSrc: null,
|
||||||
imgAlt: null,
|
imgAlt: null,
|
||||||
btnText: null,
|
btnText: null,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<Navbar/>
|
<Navbar/>
|
||||||
<!-- <Alert/> -->
|
<!-- <Alert/> -->
|
||||||
<IFrame :frameUrl="noteUrl"/>
|
<IFrame :frameUrl="noteUrl" :frameDoc="noteDoc"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
@ -9,9 +9,37 @@ import { computed, onMounted, ref, watch } from "vue"
|
|||||||
import IFrame from '@/components/utils/IFrame.vue'
|
import IFrame from '@/components/utils/IFrame.vue'
|
||||||
import Navbar from "@/components/Navbar.vue";
|
import Navbar from "@/components/Navbar.vue";
|
||||||
import Alert from '@/components/utils/Alert.vue'
|
import Alert from '@/components/utils/Alert.vue'
|
||||||
const props = defineProps(['note_url', 'token'])
|
import FetchWrapper from "@/components/utils/FetchWapper";
|
||||||
|
|
||||||
|
import { file_api } from '@/config/config.json';
|
||||||
|
|
||||||
|
const props = defineProps(['note_name', 'token'])
|
||||||
let isShow = ref(true)
|
let isShow = ref(true)
|
||||||
const noteUrl = ref('/files/notes/' + props.note_url ?? '')
|
const noteUrl = ref()
|
||||||
|
const noteDoc = ref()
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
FetchWrapper.fetch(`${file_api.root_url}/${file_api.notes.url}/${props.note_name}?type=${file_api.notes.type}`,
|
||||||
|
{
|
||||||
|
timeout: 3000,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'text/html',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (!response.ok) {
|
||||||
|
// throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
// noteUrl.value = '/.notes/' + props.note_name + '.html';
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return response.text();
|
||||||
|
})
|
||||||
|
.then(htmlText => {
|
||||||
|
noteUrl.value = null;
|
||||||
|
noteDoc.value = htmlText;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
let msg = ref('msg')
|
let msg = ref('msg')
|
||||||
let btnTxt = ref('btnTxt')
|
let btnTxt = ref('btnTxt')
|
||||||
|
@ -31,7 +31,7 @@ const router = createRouter({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "noteShower",
|
name: "noteShower",
|
||||||
path: "/note/:note_url/:token?",
|
path: "/note/:note_name/:token?",
|
||||||
component: () => import("@/pages/NoteShower.vue"),
|
component: () => import("@/pages/NoteShower.vue"),
|
||||||
props(route) {
|
props(route) {
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user