Skip to content

Commit f735287

Browse files
authored
Merge pull request #395 from goxiaoy/base-path
Add admin basePath config
2 parents 2cd5f5d + afc5458 commit f735287

30 files changed

+1033
-714
lines changed

admin/.eslintrc.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
module.exports = {
2-
parser: "vue-eslint-parser",
3-
"env": {
4-
"browser": true,
5-
"es2021": true
2+
parser: 'vue-eslint-parser',
3+
env: {
4+
browser: true,
5+
es2021: true
66
},
7-
"extends": [
8-
"plugin:@typescript-eslint/recommended",
9-
"plugin:vue/vue3-recommended"
7+
extends: [
8+
'plugin:@typescript-eslint/recommended',
9+
'plugin:vue/vue3-recommended'
1010
],
11-
"parserOptions": {
12-
"parser": "@typescript-eslint/parser",
13-
"sourceType": "module",
11+
parserOptions: {
12+
parser: '@typescript-eslint/parser',
13+
sourceType: 'module',
1414
ecmaFeature: {
1515
jsx: true,
1616
tsx: true
1717
}
1818
},
19-
"plugins": [
20-
"@typescript-eslint"
19+
plugins: [
20+
'@typescript-eslint'
2121
],
22-
"rules": {
22+
rules: {
2323
'vue/max-attributes-per-line': ['error', {
2424
singleline: 10,
2525
multiline: {
26-
max: 1,
27-
allowFirstLine: false
26+
max: 1
2827
}
2928
}],
29+
'vue/multi-word-component-names': 0,
3030
'vue/singleline-html-element-content-newline': 'off',
3131
'vue/multiline-html-element-content-newline': 'off',
3232
'vue/html-indent': ['error', 4],
@@ -35,7 +35,9 @@ module.exports = {
3535
quotes: ['error', 'single'], // 单引号
3636
// 'vue/html-quotes': ['error', 'single'],
3737
semi: ['error', 'never'], // 禁止使用分号
38-
'space-infix-ops': ['error', { int32Hint: false }], // 要求操作符周围有空格
38+
'space-infix-ops': ['error', {
39+
int32Hint: false
40+
}], // 要求操作符周围有空格
3941
'no-multi-spaces': 'error', // 禁止多个空格
4042
'no-whitespace-before-property': 'error', // 禁止在属性前使用空格
4143
'space-before-blocks': 'error', // 在块之前强制保持一致的间距
@@ -48,8 +50,8 @@ module.exports = {
4850
array: true,
4951
object: true
5052
}, {
51-
enforceForRenamedProperties: false
52-
}],
53+
enforceForRenamedProperties: false
54+
}],
5355
'comma-dangle': ['error', 'never'], // 最后一个属性不允许有逗号
5456
'arrow-spacing': 'error', // 箭头函数空格
5557
'prefer-template': 'error',
@@ -59,10 +61,12 @@ module.exports = {
5961
'no-unneeded-ternary': 'error', // 禁止可以表达为更简单结构的三元操作符
6062
'no-restricted-syntax': ['error', 'WithStatement', 'BinaryExpression[operator="in"]'], // 禁止with/in语句
6163
'no-lonely-if': 'error', // 禁止 if 语句作为唯一语句出现在 else 语句块中
62-
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }], // 要求方法链中每个调用都有一个换行符
64+
'newline-per-chained-call': ['error', {
65+
ignoreChainWithDepth: 2
66+
}], // 要求方法链中每个调用都有一个换行符
6367
// 路径别名设置
6468
'no-submodule-imports': ['off', '/@'],
6569
'no-implicit-dependencies': ['off', ['/@']],
6670
'@typescript-eslint/no-explicit-any': 'off' // 类型可以使用any
6771
}
68-
}
72+
}

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: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "vite build && echo > dist/placeholder",
8-
"preview": "vite preview"
8+
"preview": "vite preview",
9+
"lint": "eslint --ext .tsx,.ts,vue src/",
10+
"lint:fix": "eslint --ext .tsx,.ts,vue src/ --fix"
911
},
1012
"dependencies": {
1113
"ant-design-vue": "^3.1.1",
@@ -18,10 +20,10 @@
1820
"@types/nprogress": "^0.2.0",
1921
"@typescript-eslint/eslint-plugin": "^5.18.0",
2022
"@typescript-eslint/parser": "^5.18.0",
21-
"@vitejs/plugin-vue": "^2.3.0",
23+
"@vitejs/plugin-vue": "^4.0.0",
2224
"autoprefixer": "^10.4.4",
2325
"axios": "^0.26.1",
24-
"eslint": "^8.13.0",
26+
"eslint": "^8.33.0",
2527
"eslint-plugin-vue": "^8.6.0",
2628
"fast-glob": "^3.2.11",
2729
"nprogress": "^0.2.0",
@@ -30,12 +32,15 @@
3032
"postcss-import": "^14.1.0",
3133
"postcss-nested": "^5.0.6",
3234
"postcss-simple-vars": "^6.0.3",
35+
"prettier": "^2.8.3",
36+
"prettier-eslint": "^15.0.1",
3337
"screenfull": "^6.0.1",
3438
"tailwindcss": "^3.0.24",
3539
"typescript": "^4.5.4",
3640
"unplugin-vue-components": "^0.19.3",
37-
"vite": "^2.9.13",
38-
"vite-plugin-svg-icons": "^1.1.0",
41+
"vite": "^4.1.1",
42+
"vite-plugin-ejs": "^1.6.4",
43+
"vite-plugin-svg-icons": "^2.0.1",
3944
"vue-router": "^4.0.13",
4045
"vue-tsc": "^0.29.8"
4146
}

admin/postcss.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
plugins: {
3-
tailwindcss: {},
4-
autoprefixer: {},
5-
},
6-
}
2+
plugins: {
3+
tailwindcss: {},
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/components/Screenfull/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</div>
66
</template>
77
<script setup lang='ts'>
8-
import { notification } from 'ant-design-vue';
8+
import { notification } from 'ant-design-vue'
99
import { onMounted, onUnmounted, ref } from 'vue'
1010
import screenfull from 'screenfull'
1111

admin/src/layout/aside.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<Sidebar />
55
</a-layout-sider>
66
<a-layout style="padding: 0 24px 24px">
7-
<div v-if="layout.dtmVersion && layout.dtmVersion != dashVer" style="color:#f00"> !!! admin version: {{dashVer}} != dtm version: {{layout.dtmVersion}}. </div>
7+
<div v-if="layout.dtmVersion && layout.dtmVersion != dashVer" style="color:#f00"> !!! admin version: {{ dashVer }} != dtm version: {{ layout.dtmVersion }}. </div>
88
<a-breadcrumb style="margin: 16px 0">
99
<a-breadcrumb-item>{{ mainNav }}</a-breadcrumb-item>
1010
<a-breadcrumb-item>{{ subNav }}</a-breadcrumb-item>
1111
<a-breadcrumb-item>{{ page }}</a-breadcrumb-item>
1212
</a-breadcrumb>
1313
<a-layout-content
14-
:style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }"
14+
:style="{ background: '#fff', padding: '24px', margin: 0, minHeight: '280px' }"
1515
>
1616
<Content />
1717
</a-layout-content>
@@ -24,10 +24,8 @@ import Sidebar from './components/sidebar.vue'
2424
import Content from './components/content.vue'
2525
import { useRoute } from 'vue-router'
2626
import { useLayoutStore } from '../store/modules/layout'
27-
import { IMenubarList } from '../type/store/layout'
2827
import { findCurrentMenubar } from '../utils/util'
29-
import { computed, onMounted, ref } from 'vue'
30-
import { getDtmVersion } from '../api/api_dtm'
28+
import { computed, onMounted } from 'vue'
3129
3230
3331
const dashVer = import.meta.env.VITE_ADMIN_VERSION

admin/src/layout/components/content.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
closable
1010
@close="onClose"
1111
>
12-
<template v-slot:description>
13-
<span v-for="ln of errLines">{{ln}} <br/> </span>
12+
<template #description>
13+
<span v-for="(ln, index) of errLines" :key="index">{{ ln }} <br> </span>
1414
</template>
1515
</a-alert>
1616
<component :is="Component" :key="key" />
@@ -30,10 +30,10 @@ const route = useRoute()
3030
const key = computed(() => route.path)
3131
3232
const layoutStore = useLayoutStore()
33-
const errLines = computed(() => layoutStore.globalError.split("\n"))
34-
const onClose = async (e: MouseEvent) => {
33+
const errLines = computed(() => layoutStore.globalError.split('\n'))
34+
const onClose = async() => {
3535
await sleep(1000)
36-
layoutStore.setGlobalError("")
36+
layoutStore.setGlobalError('')
3737
}
3838
3939
</script>

0 commit comments

Comments
 (0)