diff --git a/atune/server/config.yml.templete b/atune/server/config.yml.templete
index 79a1592f1a36166e13c82ee99dd65bccff20686c..2846aae6833f850ddf9ee672e0631476895902bd 100644
--- a/atune/server/config.yml.templete
+++ b/atune/server/config.yml.templete
@@ -1,5 +1,5 @@
plugin_atune:
- url: "http://localhost:8099/plugin/atune"
+ url: "http://localhost:8099"
plugin_type: "iframe" # iframe micro-app
http_server:
addr: "localhost:8099"
diff --git a/atune/server/router/router.go b/atune/server/router/router.go
index c8b61334cf4d7961b0ef6917049b29fa38021da6..c85d956278d0c63f60f773768cffbdb68696b0aa 100644
--- a/atune/server/router/router.go
+++ b/atune/server/router/router.go
@@ -1,6 +1,9 @@
package router
import (
+ "net/http"
+ "strings"
+
"gitee.com/openeuler/PilotGo/sdk/logger"
"github.com/gin-gonic/gin"
"openeuler.org/PilotGo/atune-plugin/config"
@@ -29,6 +32,7 @@ func setupRouter() *gin.Engine {
router.Use(gin.Recovery())
registerAPIs(router)
+ StaticRouter(router)
return router
}
@@ -59,3 +63,18 @@ func registerAPIs(router *gin.Engine) {
restune.GET("result_search", controller.SearchResult)
}
}
+
+func StaticRouter(router *gin.Engine) {
+ router.Static("/plugin/atune/static", "../web/dist/static")
+ router.StaticFile("/plugin/atune", "../web/dist/index.html")
+
+ // 解决页面刷新404的问题
+ router.NoRoute(func(c *gin.Context) {
+ logger.Error("process noroute: %s", c.Request.URL)
+ if !strings.HasPrefix(c.Request.RequestURI, "/plugin/atune/*path") {
+ c.File("../web/dist/index.html")
+ return
+ }
+ c.Status(http.StatusNotFound)
+ })
+}
diff --git a/atune/web/index.html b/atune/web/index.html
index 5d0406973085fa6fafaa0975a20d6dc33aff8d71..338418c7bb49c56f66ed4a44eb97e1fe0edc67c0 100644
--- a/atune/web/index.html
+++ b/atune/web/index.html
@@ -2,7 +2,8 @@
-
+
+
智能调优
diff --git a/atune/web/public/favicon.ico b/atune/web/public/favicon.ico
new file mode 100644
index 0000000000000000000000000000000000000000..df36fcfb72584e00488330b560ebcf34a41c64c2
Binary files /dev/null and b/atune/web/public/favicon.ico differ
diff --git a/atune/web/src/router/index.ts b/atune/web/src/router/index.ts
index 1595bdf8120f549ed6c6536480a70052f0a5b4aa..06d6afc25e22f2e2f725779c1b2066d8922c9ecf 100644
--- a/atune/web/src/router/index.ts
+++ b/atune/web/src/router/index.ts
@@ -1,13 +1,9 @@
-import { createRouter, createWebHashHistory } from 'vue-router';
+import { createRouter, createWebHistory } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';
import Home from '@/views/Home.vue';
import Result from '@/views/ResultInfo.vue';
const routes: Array = [
- {
- path: '/',
- redirect: '/plugin/atune', //使用redirect重定向,默认系统显示的第一页
- },
{
path: '/plugin/atune',
component: Home,
@@ -21,7 +17,7 @@ const routes: Array = [
];
const router = createRouter({
- history: createWebHashHistory(),
+ history: createWebHistory('/'),
routes,
});
diff --git a/atune/web/vite.config.ts b/atune/web/vite.config.ts
index ac5d1d574e814fc5efb22f22a8ae43ebd1e7a49b..75a32402d41d9240a130a43aba7558e5078768e7 100644
--- a/atune/web/vite.config.ts
+++ b/atune/web/vite.config.ts
@@ -4,7 +4,7 @@ import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
- base: './',
+ base: '/plugin/atune/',
plugins: [vue()],
resolve: {
alias: {
@@ -16,10 +16,9 @@ export default defineConfig({
https: false,
cors: true,
proxy: {
- '/plugin': {
+ '/': {
target: 'http://localhost:8099',
changeOrigin: true,
- rewrite: (path) => path.replace(/^\//, ''),
},
},
},
@@ -28,20 +27,5 @@ export default defineConfig({
assetsDir: 'static/', //指定静态资源存放路径
sourcemap: false, //是否构建source map 文件
chunkSizeWarningLimit: 1500, //chunk 大小警告的限制,默认500KB
- rollupOptions: {
- output: {
- // 最小化拆分包
- manualChunks(id) {
- if (id.includes('node_modules')) {
- return id
- .toString()
- .split('node_modules/')[1]
- .split('/')[0]
- .toString();
- }
- },
- chunkFileNames: 'js/[name].[hash].js', // 用于命名代码拆分时创建的共享块的输出命名,[name]表示文件名,[hash]表示该文件内容hash值
- },
- },
},
});