Skip to content

Commit

Permalink
add loading to doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jamshidi799 committed Mar 25, 2021
1 parent cffd036 commit 884d693
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
36 changes: 24 additions & 12 deletions components/doc/Tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<v-navigation-drawer v-model="drawer" :permanent="$vuetify.breakpoint.mdAndUp" floating app right clipped class="pt-6 bg-color">
<v-treeview
:items="items"
:loading="loading"
open-on-click
activatable
dense
Expand All @@ -39,6 +40,7 @@
<markdown-renderer :content="content" />
</v-col>
</v-row>
<loading :active.sync="loading" color="#eb3654" background-color="black" :is-full-page="true"></loading>
</div>
</template>

Expand All @@ -47,20 +49,23 @@ const fm = require('front-matter');
import { parseGithubData, findActiveNode, findOpenIds, findActiveIds } from './parseGithubData';
import MarkdownRenderer from './MarkdownRenderer.vue';
import Header from './Header';
import Loading from 'vue-loading-overlay';
import 'vue-loading-overlay/dist/vue-loading.css';
export default {
data() {
return {
items: [],
openIds: [],
activeIds: [],
loading: false,
metaData: {},
content: '',
repo_name: '',
user_name: '',
drawer: null,
};
},
components: { MarkdownRenderer, Header },
components: { MarkdownRenderer, Header, Loading },
async fetch() {
let slug = this.$route.params.slug;
await this.$axios
Expand Down Expand Up @@ -89,17 +94,24 @@ export default {
},
methods: {
active(name) {
const splittedPath = name[0].split('/');
const fileName = splittedPath[splittedPath.length - 1];
const slug = fileName.substring(0, fileName.length - 3);
this.$router.push(`${slug}`);
const url = `https://raw.githubusercontent.com/${this.user_name}/${this.repo_name}/main/${name[0]}`;
fetch(url)
.then(res => res.text())
.then(res => {
this.metaData = fm(res);
this.content = '${toc} \n' + this.metaData.body;
});
console.log(name);
try {
const splittedPath = name[0].split('/');
const fileName = splittedPath[splittedPath.length - 1];
const slug = fileName.substring(0, fileName.length - 3);
this.$router.push(`${slug}`);
this.loading = true;
const url = `https://raw.githubusercontent.com/${this.user_name}/${this.repo_name}/main/${name[0]}`;
fetch(url)
.then(res => res.text())
.then(res => {
this.metaData = fm(res);
this.content = '${toc} \n' + this.metaData.body;
this.loading = false;
});
} catch (e) {
console.log('error');
}
},
open(items) {
this.openIds = items;
Expand Down
2 changes: 1 addition & 1 deletion components/doc/parseGithubData.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const parseGithubData = res => {
const nodePath = node.path;
const splittedPath = nodePath.split('/');
const fileName = splittedPath[splittedPath.length - 1];
const slug = fileName.substring(0, fileName.length - 3);
const slug = fileName.substring(2, fileName.length - 3);
// try {
// slug.replaceAll(/-/g, ' ');
// } catch (e) {
Expand Down
5 changes: 4 additions & 1 deletion components/editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default {
],
},
color: 'white',
placeholder: 'type something',
placeholder: 'متن موردنظر',
},
};
},
Expand Down Expand Up @@ -67,5 +67,8 @@ export default {
.ql-editor {
min-height: 200px;
}
.ql-blank {
text-align: right;
}
}
</style>
2 changes: 1 addition & 1 deletion layouts/dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
icon: 'mdi-file-document-outline',
hover: 'mdi-file-document',
link: '/dashboard/doc/Game-Doc',
disabled: true,
disabled: false,
},
doc: {
title: 'مستندات و منابع',
Expand Down
23 changes: 5 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"nuxt": "^v2.15.3",
"vue-google-oauth2": "^1.5.8",
"vue-i18n": "^8.24.0",
"vue-loading-overlay": "^3.4.2",
"vue-quill-editor": "^3.0.6"
},
"devDependencies": {
Expand Down

0 comments on commit 884d693

Please sign in to comment.