refine imports and styles

This commit is contained in:
AceDataCloud committed 2023-01-25 12:28:56 +08:00
1 parent f538780b91
commit c9010effbb
47 files changed
+303 -337

No files matched your search

-3
View File
@@ -17,9 +17,6 @@ export default defineComponent({
return {
locale: zhCn
};
},
mounted() {
this.$store.dispatch('getMe');
}
});
</script>
-2
View File
@@ -36,8 +36,6 @@ import javaTemplate from '@/assets/templates/java.tpl';
import CodeSnippet from '../common/CodeSnippet.vue';
import queryString from 'query-string';
console.log('pythonTemplate', pythonTemplate);
interface IOption {
name: ILang;
icon: string;
+1 -2
View File
@@ -84,7 +84,7 @@
import { defineComponent } from 'vue';
import { ISchema } from '@/operators/api/models';
import { IService } from '@/operators/service/models';
import { applicationOperator, IApplication, IApplicationListResponse } from '@/operators';
import { IApplication } from '@/operators';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
interface IData {
@@ -140,7 +140,6 @@ export default defineComponent({
},
methods: {
onChange(key: string, val: string) {
console.log('key', key, val);
this.value[key] = val;
},
onRefreshApplications() {
+1 -4
View File
@@ -71,14 +71,11 @@ export default defineComponent({
required: true
}
},
// emits: ['change'],
data(): IData {
return {
value: {}
};
},
watch: {},
methods: {}
}
});
</script>
-1
View File
@@ -54,7 +54,6 @@ export default defineComponent({
params: { ...this.form.queries },
data: { ...this.form.body }
};
console.debug('config of testing', config);
axios(config)
.then((response) => {
this.loading = false;
-1
View File
@@ -59,7 +59,6 @@ import ApiResult from './Result.vue';
import urlJoin from 'url-join';
import { applicationOperator } from '@/operators/application/operator';
import { IApplication, IApplicationListResponse } from '@/operators/application/models';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export interface IData {
formValue: IForm;
-182
View File
@@ -1,182 +0,0 @@
<template>
<el-card v-if="application && service" shadow="hover" class="card">
<div class="item">
<div class="icon">
<font-awesome-icon v-if="service.icon" :icon="service.icon" />
</div>
<div class="main">
<div class="title">
<router-link
:to="{
name: 'service-detail',
params: {
id: service.id
}
}"
>
{{ service.title }}
</router-link>
</div>
<div class="key">
<span class="label">{{ $t('application.field.apiKey') }}</span>
<span class="value">{{ application.api_key }}</span>
<span class="copy">
<font-awesome-icon icon="fa-regular fa-copy" />
</span>
</div>
<div class="remaining-count">
<span class="label">{{ $t('application.field.remainingCount') }}</span>
<span class="value">{{ application.remaining_count }}</span>
</div>
<div class="links">
<div class="link">
<font-awesome-icon icon="fa-regular fa-file-lines" class="label" />
<span class="text">{{ $t('application.button.document') }}</span>
</div>
</div>
</div>
<div class="operations">
<div class="operation">
<router-link
:to="{
name: 'service-detail',
params: {
id: service.id
}
}"
>
<el-button type="danger">
{{ $t('application.button.buyMore') }}
</el-button>
</router-link>
</div>
</div>
</div>
</el-card>
</template>
<script lang="ts">
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import {
applicationOperator,
IApplication,
IApplicationDetailResponse,
IService,
IServiceDetailResponse,
serviceOperator
} from '@/operators';
import { defineComponent } from 'vue';
interface IData {
loading: boolean;
service: IService | undefined;
}
export default defineComponent({
name: 'ApplicationPreviewCard',
components: {
FontAwesomeIcon
},
props: {
application: {
type: Object as () => IApplication,
required: true
}
},
data(): IData {
return {
loading: false,
service: undefined
};
},
mounted() {
if (this.application?.service_id)
serviceOperator.get(this.application.service_id).then(({ data: data }: { data: IServiceDetailResponse }) => {
this.service = data;
this.loading = false;
});
},
methods: {}
});
</script>
<style lang="scss" scoped>
.card {
margin-bottom: 20px;
.item {
height: 200px;
display: flex;
$icon-size: 150px;
$icon-font-size: 50px;
.icon {
width: $icon-size;
height: $icon-size;
line-height: $icon-size;
font-size: $icon-font-size;
text-align: center;
margin: auto 0;
color: var(--el-color-primary);
}
.main {
padding: 0 15px;
position: relative;
flex-grow: 1;
.title {
font-size: 20px;
font-weight: 500;
margin-bottom: 10px;
}
.key {
font-size: 14px;
margin-bottom: 5px;
.label {
font-weight: 600;
}
.value {
display: inline-block;
margin-left: 5px;
}
.copy {
display: inline-block;
margin-left: 5px;
color: #666;
cursor: pointer;
}
}
.remaining-count {
font-size: 14px;
margin-bottom: 5px;
.label {
font-weight: 600;
}
.value {
display: inline-block;
margin-left: 5px;
}
}
.links {
position: absolute;
bottom: 5px;
left: 20px;
.link {
color: #666;
.label {
color: var(--el-color-primary);
}
.text {
cursor: pointer;
display: inline-block;
margin-left: 5px;
}
}
}
}
.operations {
display: flex;
flex-direction: column;
justify-content: center;
}
}
}
</style>
+1
View File
@@ -18,6 +18,7 @@ export default defineComponent({
default: ''
}
},
emits: ['update:show'],
watch: {
show(val, oldVal) {
if (val) {
+29 -8
View File
@@ -17,12 +17,14 @@
$t('common.button.login')
}}</el-button>
</div>
<div v-else class="mt-3 pr-10 float-right">
<div v-else class="float-right">
<div class="console" @click="onConsole">
{{ $t('common.button.console') }}
</div>
<el-dropdown trigger="click">
<img :src="user?.avatar || defaultAvatar" class="avatar" />
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item @click="onConsole">{{ $t('common.button.console') }}</el-dropdown-item>
<el-dropdown-item @click="onProfile">{{ $t('common.button.profile') }}</el-dropdown-item>
<el-dropdown-item @click="onVerify">{{ $t('common.button.verify') }}</el-dropdown-item>
<el-dropdown-item @click="onLogout">{{ $t('common.button.logout') }}</el-dropdown-item>
@@ -39,6 +41,9 @@
<script lang="ts">
import { defineComponent } from 'vue';
import defaultAvatar from '@/assets/images/avatar.png';
import { getAuthBaseUrl } from '@/utils';
import { ROUTE_AUTH_LOGIN, ROUTE_CONSOLE_ROOT, ROUTE_INDEX } from '@/router';
export default defineComponent({
name: 'TopHeader',
data() {
@@ -61,28 +66,32 @@ export default defineComponent({
},
onHome() {
this.$router.push({
name: 'home'
name: ROUTE_INDEX
});
},
onLogin() {
this.$router.push({
name: 'login'
name: ROUTE_AUTH_LOGIN
});
},
onProfile() {
window.location.href = 'https://auth.test.zhishuyun.com/user/profile';
const authBaseUrl = getAuthBaseUrl();
window.open(`${authBaseUrl}/user/profile`, '_blank');
},
onVerify() {
window.location.href = 'https://auth.test.zhishuyun.com/user/verify';
const authBaseUrl = getAuthBaseUrl();
window.open(`${authBaseUrl}/user/verify`, '_blank');
},
onConsole() {
this.$router.push({
name: 'console-application-list'
name: ROUTE_CONSOLE_ROOT
});
},
onLogout() {
this.$store.dispatch('resetAuth');
this.$router.push('/');
this.$router.push({
name: ROUTE_INDEX
});
}
}
});
@@ -123,6 +132,18 @@ $height: 60px;
height: 40px;
border-radius: 50%;
cursor: pointer;
margin-top: 10px;
margin-right: 20px;
margin-left: 10px;
}
.console {
color: white;
height: 60px;
line-height: 60px;
margin: 0 10px;
font-size: 14px;
display: inline-block;
cursor: pointer;
}
}
</style>
+3 -1
View File
@@ -6,6 +6,7 @@
import { defineComponent } from 'vue';
import { ElMessageBox } from 'element-plus';
import { authOperator, ITokenResponse } from '@/operators';
import { getAuthBaseUrl } from '@/utils';
export default defineComponent({
name: 'VerificationAlert',
@@ -53,7 +54,8 @@ export default defineComponent({
closeOnHashChange: false
})
.then(() => {
window.open('https://auth.test.zhishuyun.com/user/verify?redirect=' + window.location.href + '?refresh=1');
const authBaseUrl = getAuthBaseUrl();
window.open(`${authBaseUrl}/user/verify?redirect=` + window.location.href + '?refresh=1');
})
.catch(() => {});
}
-2
View File
@@ -1,7 +1,6 @@
<script lang="ts">
import type { PropType } from 'vue';
import { defineComponent, computed, h } from 'vue';
import MarkdownIt, { Options as MarkdownItOptions } from 'markdown-it';
export default defineComponent({
@@ -19,7 +18,6 @@ export default defineComponent({
},
setup(props, { attrs }) {
const md = new MarkdownIt(props.options);
const content = computed(() => {
const src = props.source;
return md?.render(src);
-5
View File
@@ -1,5 +0,0 @@
import TopHeader from './TopHeader.vue';
import Breadcrumb from './Breadcrumb.vue';
import SuccessInfo from './SuccessInfo.vue';
import Pagination from './Pagination.vue';
export { TopHeader, Breadcrumb, SuccessInfo, Pagination };
+4 -3
View File
@@ -33,6 +33,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { Clock, User, Postcard } from '@element-plus/icons-vue';
import { ROUTE_CONSOLE_APPLICATION_LIST, ROUTE_CONSOLE_ORDER_LIST, ROUTE_INDEX } from '@/router';
interface ILink {
key: string;
@@ -58,13 +59,13 @@ export default defineComponent({
{
key: 'profile',
text: this.$t('console.menu.orderList'),
name: 'console-order-list',
name: ROUTE_CONSOLE_ORDER_LIST,
icon: 'user'
},
{
key: 'verify',
text: this.$t('console.menu.applicationList'),
name: 'console-application-list',
name: ROUTE_CONSOLE_APPLICATION_LIST,
icon: 'postcard'
}
]
@@ -79,7 +80,7 @@ export default defineComponent({
methods: {
onHome() {
this.$router.push({
name: 'home'
name: ROUTE_INDEX
});
}
}
+4 -3
View File
@@ -8,7 +8,7 @@
<el-link type="primary" class="link" :underline="false">
<span class="name">{{ document?.api?.title }}</span>
</el-link>
<el-tag v-if="document?.api?.request?.method" type="primary" class="request-method" effect="dark">
<el-tag v-if="document?.api?.request?.method" type="primary" class="method" effect="dark">
{{ document?.api?.request?.method }}
</el-tag>
</div>
@@ -17,6 +17,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IDocument } from '@/operators/document/models';
import { ROUTE_DOCUMENT_DETAIL } from '@/router';
export default defineComponent({
name: 'ApiListItem',
@@ -29,7 +30,7 @@ export default defineComponent({
methods: {
onClick() {
this.$router.push({
name: 'document-detail',
name: ROUTE_DOCUMENT_DETAIL,
params: {
id: this.document.id
}
@@ -60,7 +61,7 @@ $height: 35px;
display: flex;
}
}
.request-method {
.method {
position: absolute;
right: 10px;
top: 5px;
+2 -1
View File
@@ -27,6 +27,7 @@
import { IApplication, IOrderDetailResponse, orderOperator } from '@/operators';
import { defineComponent } from 'vue';
import { ElMessage } from 'element-plus';
import { ROUTE_CONSOLE_ORDER_DETAIL } from '@/router';
export default defineComponent({
name: 'CreateOrderDialog',
@@ -66,7 +67,7 @@ export default defineComponent({
this.creating = false;
const order = data;
this.$router.push({
name: 'console-order-detail',
name: ROUTE_CONSOLE_ORDER_DETAIL,
params: {
id: order.id
}
+2 -1
View File
@@ -8,5 +8,6 @@ export default {
course: '课程',
category: '分类',
service: '服务',
document: '文档'
document: '文档',
console: '控制台'
};
+1 -7
View File
@@ -8,13 +8,7 @@
import { defineComponent } from 'vue';
export default defineComponent({
name: 'LayoutAuth',
components: {},
data() {
return {};
},
computed: {},
methods: {}
name: 'LayoutAuth'
});
</script>
+3 -6
View File
@@ -15,18 +15,15 @@ export default defineComponent({
name: 'LayoutConsole',
components: {
Navigator
},
data() {
return {};
},
computed: {},
methods: {}
}
});
</script>
<style lang="scss" scoped>
.container {
height: 100vh;
width: 100%;
max-width: initial;
}
.header {
+1 -1
View File
@@ -20,7 +20,7 @@
</template>
<script lang="ts">
import { TopHeader } from '@/components/common/index';
import TopHeader from '@/components/common/TopHeader.vue';
import BottomFooter from '@/components/common/BottomFooter.vue';
import DocumentList from '@/components/document/List.vue';
+3 -2
View File
@@ -11,10 +11,11 @@
</template>
<script lang="ts">
import { TopHeader } from '@/components/common/index';
import TopHeader from '@/components/common/TopHeader.vue';
import BottomFooter from '@/components/common/BottomFooter.vue';
export default {
name: 'LayoutCourse',
name: 'LayoutService',
components: {
TopHeader,
BottomFooter
+2 -1
View File
@@ -11,6 +11,8 @@ import './plugins/font-awesome';
const app = createApp(App);
const env = import.meta.env.VITE_APP_ENV;
console.log('env', env);
app.use(router);
app.use(store);
app.use(ElementPlus);
@@ -18,5 +20,4 @@ app.use(i18n);
app.use(dayjs, {
formatString: 'YYYY-MM-DD HH:mm:ss'
});
// app.mixin(constants);
app.mount('#app');
+6 -2
View File
@@ -1,4 +1,4 @@
import router from '@/router';
import router, { ROUTE_INDEX } from '@/router';
import store from '@/store';
import axios, { AxiosInstance } from 'axios';
import { getCookie } from 'typescript-cookie';
@@ -26,7 +26,11 @@ httpClient.interceptors.response.use(
(error) => {
if (error?.response?.status === 401) {
store.dispatch('resetAuth');
router.push('/');
setTimeout(() => {
router.push({
name: ROUTE_INDEX
});
}, 1000);
}
return Promise.reject(error);
}
+9 -10
View File
@@ -1,9 +1,7 @@
<template>
<div></div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { getCookie } from 'typescript-cookie';
import { getAuthBaseUrl, getDataBaseUrl } from '@/utils';
interface IData {
accessToken: string | undefined;
@@ -12,7 +10,7 @@ interface IData {
}
export default defineComponent({
name: 'Login',
name: 'AuthCallback',
data(): IData {
return {
accessToken: undefined,
@@ -30,15 +28,16 @@ export default defineComponent({
this.$router.push(this.redirect);
}
} else {
const host = window.location.host;
const subDomain = import.meta.env.DEV ? 'test.zhishuyun.com' : host.substring(host.indexOf('.') + 1);
console.debug('access token and refresh token not found, try to re-auth again');
const dataBaseUrl = getDataBaseUrl();
const authBaseUrl = getAuthBaseUrl();
// callback url used to init access token and then redirect back of `redirect`
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
const callbackUrl = `${dataBaseUrl}/auth/callback?redirect=${this.redirect}`;
// redirect to auth service to get access token then redirect back
const targetUrl = `${authBaseUrl}?redirect=${callbackUrl}`;
window.location.href = targetUrl;
}
},
methods: {}
}
});
</script>
+6 -17
View File
@@ -1,7 +1,5 @@
<template>
<div></div>
</template>
<script lang="ts">
import { getAuthBaseUrl, getDataBaseUrl } from '@/utils';
import { defineComponent } from 'vue';
interface IData {
@@ -9,30 +7,21 @@ interface IData {
}
export default defineComponent({
name: 'Login',
name: 'AuthLogin',
data(): IData {
return {
redirect: this.$route.query.redirect?.toString()
};
},
async mounted() {
const host = window.location.host;
const subDomain = import.meta.env.DEV ? 'test.zhishuyun.com' : host.substring(host.indexOf('.') + 1);
const dataBaseUrl = getDataBaseUrl();
const authBaseUrl = getAuthBaseUrl();
// callback url used to init access token and then redirect back of `redirect`
const callbackUrl = `https://${host}/auth/callback?redirect=${this.redirect}`;
const callbackUrl = `${dataBaseUrl}/auth/callback?redirect=${this.redirect}`;
// redirect to auth service to get access token then redirect back
const targetUrl = `https://auth.${subDomain}?redirect=${callbackUrl}`;
const targetUrl = `${authBaseUrl}?redirect=${callbackUrl}`;
window.location.href = targetUrl;
},
methods: {}
});
</script>
<style lang="scss" scoped>
.panel {
.title {
text-align: center;
font-size: 22px;
}
}
</style>
+2 -2
View File
@@ -28,7 +28,7 @@
width="100px"
class-name="text-center"
/>
<el-table-column :label="$t('application.field.apiKey')" class-name="api-key">
<el-table-column :label="$t('application.field.apiKey')" class-name="api-key" width="320px">
<template #default="scope">
<span class="key">{{ scope.row.api_key }}</span>
<span class="copy">
@@ -88,7 +88,7 @@ interface IData {
}
export default defineComponent({
name: 'ApplicationList',
name: 'ConsoleApplicationList',
components: {
FontAwesomeIcon,
Pagination,
+2 -1
View File
@@ -15,7 +15,7 @@
<el-skeleton />
</div>
<div v-else class="order">
<el-descriptions :title="$t('order.title.info')" :column="1">
<el-descriptions :column="1">
<el-descriptions-item :label="$t('order.field.id')">{{ order?.id }}</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.description')">
{{ order?.description }}
@@ -184,6 +184,7 @@ export default defineComponent({
min-height: 500px;
}
.order {
padding-top: 50px;
.price {
font-size: 20px;
font-weight: bold;
+1 -1
View File
@@ -99,7 +99,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { IOrder, IOrderListResponse, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
import { IOrder, IOrderListResponse, orderOperator, OrderState } from '@/operators/order';
import Pagination from '@/components/common/Pagination.vue';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
+1
View File
@@ -29,6 +29,7 @@ export interface IData {
}
export default defineComponent({
name: 'DocumentDetail',
components: {
ApiUsage,
ApiTry,
@@ -9,19 +9,19 @@
<script lang="ts">
import { IDocument, IDocumentListResponse } from '@/operators/document/models';
import { documentOperator } from '@/operators/document/operator';
import { ROUTE_DOCUMENT_DETAIL } from '@/router';
import { defineComponent } from 'vue';
interface IData {
documents: IDocument[];
}
export default defineComponent({
components: {},
name: 'DocumentIndex',
data(): IData {
return {
documents: []
};
},
computed: {},
mounted() {
this.getDocuments(0, 1);
},
@@ -38,7 +38,7 @@ export default defineComponent({
if (this.documents.length > 0) {
const firstDocument = this.documents[0];
this.$router.push({
name: 'document-detail',
name: ROUTE_DOCUMENT_DETAIL,
params: {
id: firstDocument.id
}
+2 -1
View File
@@ -59,6 +59,7 @@ import { ElMessage } from 'element-plus';
import { apiOperator } from '@/operators/api/operator';
import { IApi, IApiListResponse } from '@/operators/api/models';
import MarkdownRenderer from '@/components/common/MarkdownRenderer.vue';
import { ROUTE_CONSOLE_APPLICATION_LIST } from '@/router';
interface IData {
service: IService | undefined;
@@ -115,7 +116,7 @@ export default defineComponent({
ElMessage.success(this.$t('application.message.applySuccessfully'));
setTimeout(() => {
this.$router.push({
name: 'console-application-list'
name: ROUTE_CONSOLE_APPLICATION_LIST
});
}, 2000);
})
+3 -13
View File
@@ -1,27 +1,17 @@
import { t } from '../i18n';
import { ROUTE_AUTH_CALLBACK, ROUTE_AUTH_LOGIN } from './constants';
export default {
path: '/auth',
name: 'auth',
meta: {
title: t('common.nav.content')
},
component: () => import('@/layouts/Auth.vue'),
children: [
{
path: 'login',
name: 'auth-login',
meta: {
title: t('common.nav.article')
},
name: ROUTE_AUTH_LOGIN,
component: () => import('@/pages/auth/Login.vue')
},
{
path: 'callback',
name: 'auth-callback',
meta: {
title: t('common.nav.article')
},
name: ROUTE_AUTH_CALLBACK,
component: () => import('@/pages/auth/Callback.vue')
}
]
+17 -4
View File
@@ -1,24 +1,37 @@
import {
ROUTE_CONSOLE_APPLICATION_LIST,
ROUTE_CONSOLE_ORDER_DETAIL,
ROUTE_CONSOLE_ORDER_LIST,
ROUTE_CONSOLE_ROOT
} from './constants';
export default {
path: '/console',
name: 'console',
meta: {
auth: true
},
component: () => import('@/layouts/Console.vue'),
children: [
{
path: '',
name: ROUTE_CONSOLE_ROOT,
redirect: {
name: ROUTE_CONSOLE_APPLICATION_LIST
}
},
{
path: 'orders',
name: 'console-order-list',
name: ROUTE_CONSOLE_ORDER_LIST,
component: () => import('@/pages/console/order/List.vue')
},
{
path: 'orders/:id',
name: 'console-order-detail',
name: ROUTE_CONSOLE_ORDER_DETAIL,
component: () => import('@/pages/console/order/Detail.vue')
},
{
path: 'applications',
name: 'console-application-list',
name: ROUTE_CONSOLE_APPLICATION_LIST,
component: () => import('@/pages/console/application/List.vue')
}
]
+15
View File
@@ -0,0 +1,15 @@
export const ROUTE_INDEX = 'ROUTE_INDEX';
export const ROUTE_AUTH_LOGIN = 'auth-login';
export const ROUTE_AUTH_CALLBACK = 'auth-callback';
export const ROUTE_CONSOLE_ROOT = 'console-root';
export const ROUTE_CONSOLE_ORDER_LIST = 'console-order-list';
export const ROUTE_CONSOLE_ORDER_DETAIL = 'console-order-detail';
export const ROUTE_CONSOLE_APPLICATION_LIST = 'console-application-list';
export const ROUTE_DOCUMENT_LIST = 'document-list';
export const ROUTE_DOCUMENT_DETAIL = 'document-detail';
export const ROUTE_SERVICE_LIST = 'service-list';
export const ROUTE_SERVICE_DETAIL = 'service-detail';
+5 -7
View File
@@ -1,19 +1,17 @@
import { ROUTE_DOCUMENT_DETAIL, ROUTE_DOCUMENT_LIST } from './constants';
export default {
path: '/documents',
name: 'documents',
meta: {
auth: true
},
component: () => import('@/layouts/Document.vue'),
children: [
{
path: '',
name: 'document-index',
component: () => import('@/pages/document/Index.vue')
name: ROUTE_DOCUMENT_LIST,
component: () => import('@/pages/document/List.vue')
},
{
path: ':id',
name: 'document-detail',
name: ROUTE_DOCUMENT_DETAIL,
component: () => import('@/pages/document/Detail.vue')
}
]
+9 -5
View File
@@ -1,15 +1,18 @@
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';
import { createRouter, createWebHistory } from 'vue-router';
import service from './service';
import auth from './auth';
import console from './console';
import document from './document';
import store from '@/store';
import { ROUTE_AUTH_LOGIN, ROUTE_INDEX, ROUTE_SERVICE_LIST } from './constants';
const routes = [
{
path: '/',
name: 'home',
redirect: '/services'
name: ROUTE_INDEX,
redirect: {
name: ROUTE_SERVICE_LIST
}
},
service,
auth,
@@ -19,7 +22,6 @@ const routes = [
const router = createRouter({
history: createWebHistory(),
// history: createWebHashHistory(),
routes
});
@@ -27,7 +29,7 @@ router.beforeEach((to, from, next) => {
if (to.matched.some((record) => record.meta.auth)) {
if (!store.getters.authenticated) {
next({
name: 'auth-login',
name: ROUTE_AUTH_LOGIN,
query: { redirect: to.fullPath }
});
} else {
@@ -39,3 +41,5 @@ router.beforeEach((to, from, next) => {
});
export default router;
export * from './constants';
+4 -6
View File
@@ -1,19 +1,17 @@
import { ROUTE_SERVICE_DETAIL, ROUTE_SERVICE_LIST, ROUTE_SERVICE_ROOT } from './constants';
export default {
path: '/services',
name: 'services',
meta: {
auth: true
},
component: () => import('@/layouts/Service.vue'),
children: [
{
path: '',
name: 'service-list',
name: ROUTE_SERVICE_LIST,
component: () => import('@/pages/service/List.vue')
},
{
path: ':id',
name: 'service-detail',
name: ROUTE_SERVICE_DETAIL,
component: () => import('@/pages/service/Detail.vue')
}
]
+1 -2
View File
@@ -1,7 +1,6 @@
import { createStore, ActionContext } from 'vuex';
import { IUser } from '@/operators/user/models';
import createPersistedState from 'vuex-persistedstate';
import { userOperator } from '@/operators';
import { userOperator, IUser } from '@/operators';
export interface IState {
accessToken: string | undefined;
+27
View File
@@ -0,0 +1,27 @@
import { getEnv } from './env';
/**
* Get base url of app
* @returns
*/
export const getDataBaseUrl = () => {
const env = getEnv();
if (env === 'local') {
return 'https://data.local.zhishuyun.com';
} else if (env === 'test') {
return 'https://data.test.zhishuyun.com';
} else {
return 'https://data.zhishuyun.com';
}
};
export const getAuthBaseUrl = () => {
const env = getEnv();
if (env === 'local') {
return 'https://auth.test.zhishuyun.com';
} else if (env === 'test') {
return 'https://auth.test.zhishuyun.com';
} else {
return 'https://auth.zhishuyun.com';
}
};
+7
View File
@@ -0,0 +1,7 @@
/**
* Get env of App, return local, test, production
* @returns
*/
export const getEnv = () => {
return import.meta.env.VITE_APP_ENV;
};
+3
View File
@@ -0,0 +1,3 @@
export * from './baseUrl';
export * from './env';
export * from './mode';
+7
View File
@@ -0,0 +1,7 @@
/**
* Get mode of App, return development or production
* @returns
*/
export const getMode = () => {
return import.meta.env.MODE;
};