🐛 Fix text cache content not refreshing
This commit is contained in:
parent
398483e864
commit
a014e81b77
@ -15,12 +15,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import util from '@/libs/util'
|
||||
import { mapActions } from "vuex";
|
||||
import util from "@/libs/util";
|
||||
export default {
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
methods: {
|
||||
...mapActions("acrou/db", ["databaseClear"]),
|
||||
cleanCache() {
|
||||
new Promise((resolve) => {
|
||||
Object.keys(localStorage).forEach((item) => {
|
||||
@ -28,7 +30,8 @@ export default {
|
||||
localStorage.removeItem(item);
|
||||
}
|
||||
});
|
||||
util.cookies.remove("lang")
|
||||
util.cookies.remove("lang");
|
||||
this.databaseClear();
|
||||
resolve();
|
||||
}).then(() => {
|
||||
this.$notify({
|
||||
|
@ -88,11 +88,10 @@ export const decode64 = (str) => {
|
||||
return Base64.decode(str);
|
||||
};
|
||||
|
||||
export function get_file(option, callback) {
|
||||
var path = option.path;
|
||||
var modifiedTime = option.file.modifiedTime;
|
||||
export function get_file({ path, file }, callback) {
|
||||
var modifiedTime = file ? file.modifiedTime : null;
|
||||
var key = "file_path_" + path + modifiedTime;
|
||||
var data = localStorage.getItem(key);
|
||||
var data = modifiedTime ? localStorage.getItem(key) : null;
|
||||
if (data) {
|
||||
return callback(data);
|
||||
} else {
|
||||
|
@ -161,6 +161,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapActions("acrou/aplayer", ["add"]),
|
||||
...mapActions("acrou/db", ["set"]),
|
||||
infiniteHandler($state) {
|
||||
// 首次进入页面不执行滚动事件
|
||||
if (!this.page.page_token) {
|
||||
@ -321,8 +322,13 @@ export default {
|
||||
return;
|
||||
}
|
||||
if (target === "view") {
|
||||
let checkViewPath = checkView(path);
|
||||
this.set({
|
||||
path: `page.${checkViewPath}`,
|
||||
value: file,
|
||||
});
|
||||
this.$router.push({
|
||||
path: checkView(path),
|
||||
path: checkViewPath,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -6,16 +6,8 @@
|
||||
v-model="content"
|
||||
:options="options"
|
||||
/>
|
||||
<markdown
|
||||
v-if="ismd"
|
||||
v-show="!isEdit"
|
||||
:source="content"
|
||||
/>
|
||||
<a
|
||||
v-if="ismd"
|
||||
class="g2-content-edit is-hidden-mobile"
|
||||
@click="edit"
|
||||
>
|
||||
<markdown v-if="ismd" v-show="!isEdit" :source="content" />
|
||||
<a v-if="ismd" class="g2-content-edit is-hidden-mobile" @click="edit">
|
||||
<i
|
||||
:class="'fa' + (isEdit ? ' fa-eye' : ' fa-pencil-square-o')"
|
||||
aria-hidden="true"
|
||||
@ -25,6 +17,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from "vuex";
|
||||
import { get_file, decode64 } from "@utils/AcrouUtil";
|
||||
import { codemirror } from "vue-codemirror";
|
||||
|
||||
@ -50,6 +43,12 @@ export default {
|
||||
loaded: false,
|
||||
};
|
||||
},
|
||||
beforeRouteEnter(to, from, next) {
|
||||
if (from.path === "/") {
|
||||
to.params.reload = true;
|
||||
}
|
||||
next();
|
||||
},
|
||||
activated() {
|
||||
this.render();
|
||||
},
|
||||
@ -68,13 +67,23 @@ export default {
|
||||
codemirror,
|
||||
},
|
||||
methods: {
|
||||
render() {
|
||||
...mapActions("acrou/db", ["get"]),
|
||||
async render() {
|
||||
let path = this.url;
|
||||
this.content = `<center>
|
||||
<i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</center>`;
|
||||
get_file({ path: path, file: {} }, (data) => {
|
||||
|
||||
let file;
|
||||
let reload = this.$route.params.reload;
|
||||
if (!reload) {
|
||||
file = await this.get({
|
||||
path: `page.${this.$route.fullPath}`,
|
||||
});
|
||||
}
|
||||
|
||||
get_file({ path: path, file }, (data) => {
|
||||
this.content = data;
|
||||
});
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user