Skip to content

Commit

Permalink
🐛 fixed #7
Browse files Browse the repository at this point in the history
  • Loading branch information
yann0917 committed Aug 23, 2023
1 parent 8f8dad5 commit 02499cb
Show file tree
Hide file tree
Showing 13 changed files with 111 additions and 125 deletions.
9 changes: 9 additions & 0 deletions backend/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ func (a *App) GetQrcode() (qrCode QrCodeResp, err error) {
if err != nil {
return
}
if token == `{"message":"invalid csrf token"}` {
app.Logout()
services.CsrfToken = ""
_, _ = Instance.GetHomeInitialState()
token, err = Instance.LoginAccessToken()
if err != nil {
return
}
}
code, err := Instance.GetQrcode(token)
if err != nil {
return
Expand Down
1 change: 1 addition & 0 deletions build/darwin/Info.dev.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>{{.Info.Copyright}}</string>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
Expand Down
1 change: 1 addition & 0 deletions build/darwin/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<string>true</string>
<key>NSHumanReadableCopyright</key>
<string>{{.Info.Copyright}}</string>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const activeIndex = computed(() => {
return route.path
})
const handleSelect = (key: string, keyPath: string[]) => {
// this.activeIndex = this.$route.path
// console.log(key, keyPath)
}
</script>
26 changes: 9 additions & 17 deletions frontend/src/components/NotesItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
<div class="box" v-if="item.s_part.images?.length>0">
<div class="imageBox">
<el-image v-for="i in item.s_part.images" :src="i" :preview-src-list="item.s_part.images.map((v,i)=>{
return v
})" :initial-index="0" fit="cover" :style="item.s_part.images?.length>1?'height:245px;width: 32%;':'width: 32%;'"/>
return v
})" :initial-index="0" fit="cover" :style="item.s_part.images?.length>1?'height:245px;width: 32%;':'width: 32%;'"/>
</div>
</div>
<div class="note-line" v-if="item.s_part.base_source.title !=''">
Expand Down Expand Up @@ -162,15 +162,9 @@
<script setup lang="ts">
import {ref, reactive, onMounted, defineProps, watch} from 'vue'
import { ElMessage } from 'element-plus'
import { NotesTimeline,TopicNotesList,TopicNoteDetail} from '../../wailsjs/go/backend/App'
import { NotesTimeline,TopicNotesList} from '../../wailsjs/go/backend/App'
import { services } from '../../wailsjs/go/models'
import { useRoute, useRouter } from 'vue-router'
import { userStore } from '../stores/user';
import {is} from "@babel/types";
const store = userStore()
const router = useRouter()
const route = useRoute()
import { arrayExpression } from '@babel/types'
const page = ref(0)
const total = ref(0)
Expand All @@ -197,16 +191,16 @@ const props = defineProps({
onMounted(() => {
watch(() => {
topic_id_hazy.value = props.topicDetail?.topic_id_hazy ? props.topicDetail.topic_id_hazy : ''
console.log('change', topic_id_hazy)
},
() => {
console.log('cb', topic_id_hazy)
noteList.notes = []
isElected.value=true
if (topic_id_hazy.value !='') {
noteList.notes = []
}
isElected.value = true
page.value = 0
getTableData()
},
{immediate: true,deep:true}
{immediate: true, deep: true}
)
})
Expand All @@ -221,7 +215,6 @@ const loadNotes = () => {
}
const getTableData = async () => {
console.log(topic_id_hazy.value)
if (topic_id_hazy.value != '') {
await TopicNotesList(props.topicDetail.topic_id_hazy, isElected.value, page.value, pageSize.value)
.then((table)=>{
Expand Down Expand Up @@ -254,7 +247,6 @@ const getTableData = async () => {
})
})
} else {
console.log(maxId.value)
await NotesTimeline(maxId.value).then((table) => {
console.log(table)
Object.assign(tableData, table)
Expand Down
55 changes: 23 additions & 32 deletions frontend/src/components/TopicItem.vue
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
<template>
<p style="text-align: left; font-size: 20px; font-weight: bold"><span style="color:#ff6b00"># </span>推荐话题</p>
<div class="topic">
<ul v-infinite-scroll="loadTopic"
class="infinite-list"
style="overflow-y: auto; max-height: 800px;"
:infinite-scroll-disabled="infLoadingTopic"
infinite-scroll-distance="10">
<li v-for="i in topicList.list" class="infinite-list-item">
<el-button text class="topic-item" @click="sendTopicDetail(i)">
<div class="title">
<span style="color:#ff6b00">#</span>{{i.name}}
<el-badge :value="i.tag==1?'新':i.tag==2?'热':''" class="badge-item" :type="i.tag==2?'warning':'danger'">
</el-badge>
</div>
<div class="intro">{{i.intro}}</div>
</el-button>
</li>
</ul>
</div>
<div v-if="topicList.list.length>0">
<p style="text-align: left; font-size: 20px; font-weight: bold"><span style="color:#ff6b00"># </span>推荐话题</p>
<div class="topic">
<ul v-infinite-scroll="loadTopic"
class="infinite-list"
style="overflow-y: auto; max-height: 800px;"
:infinite-scroll-disabled="infLoadingTopic"
infinite-scroll-distance="10">
<li v-for="i in topicList.list" class="infinite-list-item">
<el-button text class="topic-item" @click="sendTopicDetail(i)">
<div class="title">
<span style="color:#ff6b00">#</span>{{i.name}}
<el-badge :value="i.tag==1?'新':i.tag==2?'热':''" class="badge-item" :type="i.tag==2?'warning':'danger'">
</el-badge>
</div>
<div class="intro">{{i.intro}}</div>
</el-button>
</li>
</ul>
</div>
</div>
</template>

<script setup lang="ts">
import {ref, reactive, onMounted, defineProps} from 'vue'
import { ElMessage } from 'element-plus'
import { TopicAll } from '../../wailsjs/go/backend/App'
import { services } from '../../wailsjs/go/models'
import { useRoute, useRouter } from 'vue-router'
import { userStore } from '../stores/user';
const store = userStore()
const router = useRouter()
const route = useRoute()
const page = ref(1)
const total = ref(0)
const pageSize = ref(15)
const infLoadingTopic = ref(true)
let topicAll = reactive(new services.TopicAll)
Expand All @@ -42,9 +36,6 @@ topicList.list = []
const emits = defineEmits(["sendDetail"]);
// let id = ref()
// let enid = ref()
const topicPage = ref(0)
const topicHasMore = ref(false)
const topicPageSize = ref(20)
Expand Down Expand Up @@ -91,15 +82,15 @@ const sendTopicDetail = (row: any) => {

<style scoped lang="scss">
.topic {
height: 800px;
height: 100%;
border: 1px solid var(--el-border-color);
border-radius:8px;
}
.topic-item {
height: 110px;
}
/* 深度选择器(样式穿透)*/
:deep .el-button>span {
:deep(.el-button>span) {
display: inline-block;
align-items: center;
}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
}
app.config.errorHandler = (err, vm, info) => {
console.log('❌ 提示:', err);
console.log('====== 有报错了!!! ======');
if (err instanceof Error) {
let routers = useRouter()
console.log('❌ 提示:', err.message);
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
</el-carousel>
</el-col>
<el-col :span="4" class="user">
<div :class="!initial.isLogin ? 'not-login' : 'logged'">
<div v-if="!initial.isLogin">
<div :class="Local.get('cookies')==null ?'not-login' : 'logged'">
<div v-if="Local.get('cookies')==null">
<div class="receive"></div>
<el-button class="login-btn" @click="openLoginDialog()">
登录
Expand All @@ -59,11 +59,11 @@
</div>
<div class="data">
<p class="time">
<span>今日学习</span><span><em style="font-size: 22px">{{(user.today_study_time / 60).toFixed(0)}}</em>分钟</span>
<span>今日学习</span><em style="font-size: 22px;color:#333;">{{user.today_study_time > 0 ? (user.today_study_time / 60).toFixed(0):''}}</em><span>分钟</span>
</p>
<el-divider border-style="dotted" />
<p class="time">
<span>连续学习</span><span><em style="font-size: 22px">{{user.study_serial_days}}</em>天</span>
<span>连续学习</span><em style="font-size: 22px;color: #333;">{{user.study_serial_days}}</em><span>天</span>
</p>
</div>
<!-- <el-button class="button" @click="logout()"> 退出 </el-button> -->
Expand Down Expand Up @@ -298,6 +298,7 @@ import QrLogin from "../components/QrLogin.vue";
import EbookInfo from "../components/EbookInfo.vue";
import CourseInfo from "../components/CourseInfo.vue";
import { useRouter } from "vue-router";
import { Local } from "../utils/storage";
const router = useRouter();
Expand Down Expand Up @@ -418,6 +419,7 @@ const logout = async () => {
.then((result) => {
console.log(result);
WindowReloadApp();
Local.remove("cookies")
router.push("/home");
})
.catch((error) => {
Expand Down
18 changes: 1 addition & 17 deletions frontend/src/views/Knowledge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,11 @@
<script lang="ts" setup>
import NotesItem from "../components/NotesItem.vue";
import TopicItem from "../components/TopicItem.vue";
import {useRoute} from "vue-router";
import {onMounted, reactive} from "vue";
import {reactive} from "vue";
import {services} from "../../wailsjs/go/models";
const route = useRoute()
const topicDetail = reactive(new services.TopicIntro)
onMounted(() => {
// console.log(route.query)
// Object.assign(topicDetail, route.query)
// watch(() => {
// id.value = route.params.id
// enid.value = route.query.enid
// total.value = Number(route.query.total)
// breadcrumbTitle.value = route.query.title
// },
// () => getTableData(),
// {immediate: true}
// )
})
const getTopicDetail = (row:any)=> {
Object.assign(topicDetail, row)
console.log('topic子组件向父组件传值', row)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script lang="ts" setup>
import { ref, reactive, onMounted } from "vue";
import { ref, onMounted } from "vue";
import QrLogin from "../components/QrLogin.vue";
const dialogVisible = ref(false);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/views/Setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<el-form-item label="文件保存目录">
<el-input v-model="form.downloadDir"
:prefix-icon="Folder"
@blur="openDialogDir('')"
clearable @clear="clearDir "/>
</el-form-item>
<el-tooltip
Expand Down
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ go 1.18
require (
github.com/JoshVarga/svgparser v0.0.0-20200804023048-5eaba627a7d1
github.com/PuerkitoBio/goquery v1.8.1
github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.0
github.com/bmaupin/go-epub v1.0.1
github.com/chromedp/cdproto v0.0.0-20230329100754-6125fc8d7142
github.com/chromedp/chromedp v0.9.1
github.com/SebastiaanKlippert/go-wkhtmltopdf v1.9.1
github.com/bmaupin/go-epub v1.1.0
github.com/chromedp/cdproto v0.0.0-20230816033919-17ee49f3eb4f
github.com/chromedp/chromedp v0.9.2
github.com/gabriel-vasile/mimetype v1.4.2
github.com/go-resty/resty/v2 v2.7.0
github.com/json-iterator/go v1.1.12
github.com/mattn/go-colorable v0.1.13
github.com/mitchellh/mapstructure v1.5.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/wailsapp/wails/v2 v2.5.1
golang.org/x/sync v0.1.0
golang.org/x/sync v0.3.0
)

require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/bep/debounce v1.2.1 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/gobwas/ws v1.3.0 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/labstack/echo/v4 v4.10.2 // indirect
github.com/labstack/echo/v4 v4.11.1 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leaanthony/go-ansi-parser v1.6.0 // indirect
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
github.com/leaanthony/gosod v1.0.3 // indirect
github.com/leaanthony/slicer v1.6.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
Expand All @@ -49,9 +49,9 @@ require (
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vincent-petithory/dataurl v1.0.0 // indirect
github.com/wailsapp/mimetype v1.4.1 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
)
Loading

0 comments on commit 02499cb

Please sign in to comment.