Skip to content

Commit 94f9df0

Browse files
committed
admin add base path
1 parent 2cd5f5d commit 94f9df0

File tree

10 files changed

+617
-338
lines changed

10 files changed

+617
-338
lines changed

admin/index.html

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
3+
4+
<head>
45
<meta charset="UTF-8" />
5-
<link rel="icon" href="/favicon.ico" />
6+
<link rel="icon" href="<%= PUBLIC_PATH %>/favicon.ico" />
67
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite App</title>
8-
</head>
9-
<body>
8+
<title>Dtm</title>
9+
<script type="text/javascript">
10+
window.basePath = '<%= PUBLIC_PATH %>';
11+
12+
window.__assetsPathBuilder = function (importer) {
13+
return window.basePath + "/" + importer;
14+
};
15+
</script>
16+
</head>
17+
18+
<body>
1019
<div id="app"></div>
1120
<script type="module" src="/src/main.ts"></script>
12-
</body>
13-
</html>
21+
</body>
22+
23+
</html>

admin/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
"@types/nprogress": "^0.2.0",
1919
"@typescript-eslint/eslint-plugin": "^5.18.0",
2020
"@typescript-eslint/parser": "^5.18.0",
21-
"@vitejs/plugin-vue": "^2.3.0",
21+
"@vitejs/plugin-vue": "^4.0.0",
2222
"autoprefixer": "^10.4.4",
2323
"axios": "^0.26.1",
24-
"eslint": "^8.13.0",
24+
"eslint": "^8.33.0",
2525
"eslint-plugin-vue": "^8.6.0",
2626
"fast-glob": "^3.2.11",
2727
"nprogress": "^0.2.0",
@@ -30,12 +30,15 @@
3030
"postcss-import": "^14.1.0",
3131
"postcss-nested": "^5.0.6",
3232
"postcss-simple-vars": "^6.0.3",
33+
"prettier": "^2.8.3",
34+
"prettier-eslint": "^15.0.1",
3335
"screenfull": "^6.0.1",
3436
"tailwindcss": "^3.0.24",
3537
"typescript": "^4.5.4",
3638
"unplugin-vue-components": "^0.19.3",
37-
"vite": "^2.9.13",
38-
"vite-plugin-svg-icons": "^1.1.0",
39+
"vite": "^4.1.1",
40+
"vite-plugin-ejs": "^1.6.4",
41+
"vite-plugin-svg-icons": "^2.0.1",
3942
"vue-router": "^4.0.13",
4043
"vue-tsc": "^0.29.8"
4144
}

admin/postcss.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
plugins: {
33
tailwindcss: {},
4-
autoprefixer: {},
5-
},
6-
}
4+
autoprefixer: {}
5+
}
6+
}

admin/src/api/api_dtm.ts

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
import {AxiosResponse} from 'axios'
1+
import { AxiosResponse } from 'axios'
22
import request from '/@/utils/request'
33

44
export interface IListAllTransactionsReq {
5-
gid?: string,
6-
limit: number
7-
position?: string
5+
gid?: string;
6+
limit: number;
7+
position?: string;
88
}
99

1010
export interface IListAllKVReq {
11-
cat: string
12-
limit: number
13-
position?: string
11+
cat: string;
12+
limit: number;
13+
position?: string;
1414
}
1515

16-
export function listAllTransactions<T>(payload: IListAllTransactionsReq): Promise<AxiosResponse<T>> {
16+
export function listAllTransactions<T>(
17+
payload: IListAllTransactionsReq
18+
): Promise<AxiosResponse<T>> {
1719
return request({
1820
url: '/api/dtmsvr/all',
1921
method: 'get',
@@ -25,19 +27,24 @@ export function forceStopTransaction(gid: string): Promise<AxiosResponse> {
2527
return request({
2628
url: '/api/dtmsvr/forceStop',
2729
method: 'post',
28-
data: {gid},
30+
data: { gid }
2931
})
3032
}
3133

32-
export function queryKVPair<T>(payload: { "cat": string, "key": string }): Promise<AxiosResponse<T>> {
34+
export function queryKVPair<T>(payload: {
35+
cat: string;
36+
key: string;
37+
}): Promise<AxiosResponse<T>> {
3338
return request({
3439
url: '/api/dtmsvr/queryKV',
3540
method: 'get',
3641
params: payload
3742
})
3843
}
3944

40-
export function listKVPairs<T>(payload: IListAllKVReq): Promise<AxiosResponse<T>> {
45+
export function listKVPairs<T>(
46+
payload: IListAllKVReq
47+
): Promise<AxiosResponse<T>> {
4148
return request({
4249
url: '/api/dtmsvr/scanKV',
4350
method: 'get',
@@ -47,28 +54,37 @@ export function listKVPairs<T>(payload: IListAllKVReq): Promise<AxiosResponse<T>
4754

4855
export function deleteTopic<T>(topicName: string): Promise<AxiosResponse<T>> {
4956
return request({
50-
url: '/api/dtmsvr/topic/' + topicName,
57+
url: `/api/dtmsvr/topic/${topicName}`,
5158
method: 'delete'
5259
})
5360
}
5461

55-
export function subscribe<T>(payload: { topic: string, url: string, remark: string }): Promise<AxiosResponse<T>> {
62+
export function subscribe<T>(payload: {
63+
topic: string;
64+
url: string;
65+
remark: string;
66+
}): Promise<AxiosResponse<T>> {
5667
return request({
5768
url: '/api/dtmsvr/subscribe',
5869
method: 'get',
5970
params: payload
6071
})
6172
}
6273

63-
export function unsubscribe(payload: { topic: string, url: string }): Promise<AxiosResponse> {
74+
export function unsubscribe(payload: {
75+
topic: string;
76+
url: string;
77+
}): Promise<AxiosResponse> {
6478
return request({
6579
url: '/api/dtmsvr/unsubscribe',
6680
method: 'get',
6781
params: payload
6882
})
6983
}
7084

71-
export function getTransaction<T>(payload: { gid: string }): Promise<AxiosResponse<T>> {
85+
export function getTransaction<T>(payload: {
86+
gid: string;
87+
}): Promise<AxiosResponse<T>> {
7288
return request({
7389
url: '/api/dtmsvr/query',
7490
method: 'get',
@@ -79,6 +95,6 @@ export function getTransaction<T>(payload: { gid: string }): Promise<AxiosRespon
7995
export function getDtmVersion(): Promise<AxiosResponse<any>> {
8096
return request({
8197
url: '/api/dtmsvr/version',
82-
method: 'get',
98+
method: 'get'
8399
})
84100
}

admin/src/components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// generated by unplugin-vue-components
22
// We suggest you to commit this file into source control
3-
// Read more: https://github.com/vuejs/vue-next/pull/3399
3+
// Read more: https://github.com/vuejs/core/pull/3399
44
import '@vue/runtime-core'
55

66
declare module '@vue/runtime-core' {
@@ -20,9 +20,9 @@ declare module '@vue/runtime-core' {
2020
AMenu: typeof import('ant-design-vue/es')['Menu']
2121
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
2222
AModal: typeof import('ant-design-vue/es')['Modal']
23-
ASpace: typeof import('ant-design-vue/es')['Space']
2423
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
2524
ATable: typeof import('ant-design-vue/es')['Table']
25+
ATag: typeof import('ant-design-vue/es')['Tag']
2626
ATextarea: typeof import('ant-design-vue/es')['Textarea']
2727
RouterLink: typeof import('vue-router')['RouterLink']
2828
RouterView: typeof import('vue-router')['RouterView']

admin/src/router/index.ts

Lines changed: 68 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,80 @@
11
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
2-
import { IMenubarList } from '../type/store/layout';
3-
import { components } from './asyncRouter';
2+
import { IMenubarList } from '../type/store/layout'
3+
import { components } from './asyncRouter'
44

5-
const Components: IObject<() => Promise<typeof import('*.vue')>> = Object.assign({}, components, {
6-
LayoutHeader: (() => import('/@/layout/index.vue')) as unknown as () => Promise<typeof import('*.vue')>,
7-
LayoutMain: (() => import('/@/layout/aside.vue')) as unknown as () => Promise<typeof import('*.vue')>
8-
})
5+
const Components: IObject<() => Promise<typeof import('*.vue')>> =
6+
Object.assign({}, components, {
7+
LayoutHeader: (() =>
8+
import('/@/layout/index.vue')) as unknown as () => Promise<
9+
typeof import('*.vue')
10+
>,
11+
LayoutMain: (() =>
12+
import('/@/layout/aside.vue')) as unknown as () => Promise<
13+
typeof import('*.vue')
14+
>
15+
})
916

1017
export const allowRouter: Array<IMenubarList> = [
11-
{
12-
name: 'Admin',
13-
path: '/',
14-
redirect: '/admin/global-transactions/all',
15-
component: Components['LayoutHeader'],
16-
meta: { title: 'Admin', activeMenu: '/admin' },
17-
children: [
18-
{
19-
// name: 'Nodes',
20-
// path: '/admin/nodes',
21-
// component: Components['LayoutMain'],
22-
// meta: { title: 'Nodes' },
23-
// children: [
24-
// {
25-
// name: 'LivingNodes',
26-
// path: '/admin/nodes/living',
27-
// component: Components['LivingNodes'],
28-
// meta: { title: 'Living Nodes' },
29-
// }
30-
// ]
31-
// }, {
32-
name: 'GlobalTransactions',
33-
path: '/admin/global-transactions',
34-
component: Components['LayoutMain'],
35-
meta: { title: 'Global Transactions' },
36-
children: [
37-
{
38-
name: 'AllTransactions',
39-
path: '/admin/global-transactions/all',
40-
component: Components['AllTransactions'],
41-
meta: { title: 'All Transactions' },
42-
// }, {
43-
// name: 'UnfinishedTransactions',
44-
// path: '/admin/global-transactions/unfinished',
45-
// component: Components['UnfinishedTransactions'],
46-
// meta: { title: 'Unfinished Transactions' },
47-
}
48-
]
49-
},{
50-
name: 'KVPairs',
51-
path: '/admin/kv',
52-
component: Components['LayoutMain'],
53-
meta: { title: 'Key-Value Pairs' },
18+
{
19+
name: 'Admin',
20+
path: '/',
21+
redirect: '/admin/global-transactions/all',
22+
component: Components['LayoutHeader'],
23+
meta: { title: 'Admin', activeMenu: '/admin' },
5424
children: [
55-
{
56-
name: 'Topics',
57-
path: '/admin/kv/topics',
58-
component: Components['Topics'],
59-
meta: { title: 'Topics' },
60-
}
25+
{
26+
// name: 'Nodes',
27+
// path: '/admin/nodes',
28+
// component: Components['LayoutMain'],
29+
// meta: { title: 'Nodes' },
30+
// children: [
31+
// {
32+
// name: 'LivingNodes',
33+
// path: '/admin/nodes/living',
34+
// component: Components['LivingNodes'],
35+
// meta: { title: 'Living Nodes' },
36+
// }
37+
// ]
38+
// }, {
39+
name: 'GlobalTransactions',
40+
path: '/admin/global-transactions',
41+
component: Components['LayoutMain'],
42+
meta: { title: 'Global Transactions' },
43+
children: [
44+
{
45+
name: 'AllTransactions',
46+
path: '/admin/global-transactions/all',
47+
component: Components['AllTransactions'],
48+
meta: { title: 'All Transactions' }
49+
// }, {
50+
// name: 'UnfinishedTransactions',
51+
// path: '/admin/global-transactions/unfinished',
52+
// component: Components['UnfinishedTransactions'],
53+
// meta: { title: 'Unfinished Transactions' },
54+
}
55+
]
56+
},
57+
{
58+
name: 'KVPairs',
59+
path: '/admin/kv',
60+
component: Components['LayoutMain'],
61+
meta: { title: 'Key-Value Pairs' },
62+
children: [
63+
{
64+
name: 'Topics',
65+
path: '/admin/kv/topics',
66+
component: Components['Topics'],
67+
meta: { title: 'Topics' }
68+
}
69+
]
70+
}
6171
]
62-
},
63-
64-
]
65-
}
72+
}
6673
]
6774

6875
const router = createRouter({
69-
history: createWebHistory(),
70-
routes: allowRouter as RouteRecordRaw[]
76+
history: createWebHistory(window.basePath || undefined),
77+
routes: allowRouter as RouteRecordRaw[]
7178
})
7279

7380
export default router

admin/src/type/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ declare global {
1414
next_position: number,
1515
size: number
1616
}
17+
interface Window {
18+
basePath: string;
19+
}
1720
}

admin/src/utils/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import axios from 'axios'
22

33
const request = axios.create({
4+
baseURL: window.basePath || '',
45
timeout: 60000
56
})
67

0 commit comments

Comments
 (0)