This commit is contained in:
2025-11-17 17:00:14 +08:00
parent a4eaf0d5cb
commit ef0e8e83e0
40 changed files with 10582 additions and 3381 deletions

View File

@@ -57,7 +57,7 @@ Vue.use(VueQuillEditor)
async function loadJournalType() {
const localData = localStorage.getItem('journalType'); // 尝试从 localStorage 获取数据
// 如果 localStorage 中没有数据,则调用 API 获取并存储
if (!localData) {
try {
await api
@@ -83,30 +83,42 @@ async function loadJournalType() {
} catch (error) {
console.error('Failed to fetch journal types:', error);
}
} else {
console.log('Journal types loaded from localStorage:', JSON.parse(localData));
}
}
async function loadJournalList() {
return await api
.post('api/Article/getJournal', {})
.then((res) => {
store.commit('setJournalList', res); // 提交 mutation 更新 journalList
console.log('journalList at line 100:, 提交 mutation 更新 journalList')
})
async function loadJournalList() {
try {
const localData = store.state.journalList;
console.log('localData at line 93:', localData);
if (localData && Array.isArray(localData) && localData.length > 0) {
return localData;
}
const res = await api.post('api/Article/getJournal', {});
if (res ) {
const journalList = res;
store.commit('setJournalList', journalList);
return journalList;
} else {
return [];
}
} catch (error) {
}
}
// 启动应用时调用一次函数来加载 journalType 数据
// 时间过滤器
// 定义时间过滤器(不含时分秒)
@@ -209,7 +221,7 @@ router.beforeEach(async(to, from, next) => {
]);
} catch (err) {
// 仅打印错误,不阻断路由
console.error('接口请求失败,但继续路由跳转', err);
}
// 无论接口成功/失败,都执行原有跳转逻辑