-
-
-
-
+
+
+
+
-
-
+
+
- 登录
+
+ 登录
+ 注册
+
-
diff --git a/oaf/src/views/user_setting.vue b/oaf/src/views/user_setting.vue
new file mode 100644
index 0000000..21264a4
--- /dev/null
+++ b/oaf/src/views/user_setting.vue
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/oaf/src/vuex.d.ts b/oaf/src/vuex.d.ts
new file mode 100644
index 0000000..0ef57c5
--- /dev/null
+++ b/oaf/src/vuex.d.ts
@@ -0,0 +1,14 @@
+import {ComponentCustomProperties} from 'vue'
+import {Store} from 'vuex'
+import {State as root} from './store'
+
+declare module '@vue/runtime-core' {
+ // 声明自己的 store state
+ interface State extends root {
+ }
+
+ // 为 `this.$store` 提供类型声明
+ interface ComponentCustomProperties {
+ $store: Store
+ }
+}
diff --git a/oaf/vite.config.ts b/oaf/vite.config.ts
index 9384742..09b039a 100644
--- a/oaf/vite.config.ts
+++ b/oaf/vite.config.ts
@@ -1,19 +1,36 @@
-import { defineConfig } from 'vite'
+import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
- plugins: [vue()],
- server: {
- // host: '0.0.0.0',
- host: '127.0.0.1',
- port: 8080,
- proxy: {
- '/api': 'http://127.0.0.1:4001/'
+ plugins: [vue()],
+ server: {
+ // host: '0.0.0.0',
+ host: '127.0.0.1',
+ port: 8080,
+ proxy: {
+ '/api': {
+ target: 'http://127.0.0.1:4001/',
+ changeOrigin: true,
+ ws: true
+ },
+ '/media': {
+ target: 'http://127.0.0.1:4001/',
+ changeOrigin: true,
+ ws: true
+ }
+ }
+ },
+ build: {
+ outDir: '../sub/static/',
+ assetsDir: './',
+ rollupOptions: {
+ output: {
+ // 重点在这里哦
+ entryFileNames: `static/[name].[hash].js`,
+ chunkFileNames: `static/[name].[hash].js`,
+ assetFileNames: `static/[name].[hash].[ext]`
+ }
+ }
}
- },
- build: {
- outDir: '../build/static/',
- assetsDir: 'assets'
- }
})
diff --git a/oaf/yarn.lock b/oaf/yarn.lock
index 539df17..a1688be 100644
--- a/oaf/yarn.lock
+++ b/oaf/yarn.lock
@@ -216,10 +216,10 @@
dependencies:
"@types/yargs-parser" "*"
-"@veypi/one-icon@2":
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/@veypi/one-icon/-/one-icon-2.0.0.tgz#15262e87644903d90a2124fbc9c95fbb6bb6bcb8"
- integrity sha512-zcUx3YzTIRiZe5XkJRZyKDgVzQThEWyZSCpQTreeYtKEObCl4B0Oa6CFYo4IToGD6uQmReM0R6oNPg5mhPjc2A==
+"@veypi/one-icon@2.0.5":
+ version "2.0.5"
+ resolved "https://registry.yarnpkg.com/@veypi/one-icon/-/one-icon-2.0.5.tgz#1083be30fc3bbb89aaf19501b00110d3ae9b1c77"
+ integrity sha512-THnQh1zbH+glwDBLjP7rtcF3UtTQnzsxnUQEtUjAjv9Eo6rVSa1u4RsFA8CMDpoVcQiTMhqgRalbfjovdr11wg==
dependencies:
vue "^3.2.20"
@@ -396,6 +396,11 @@ acorn@^7.0.0, acorn@^7.1.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
+animate.css@^4.1.1:
+ version "4.1.1"
+ resolved "https://registry.yarnpkg.com/animate.css/-/animate.css-4.1.1.tgz#614ec5a81131d7e4dc362a58143f7406abd68075"
+ integrity sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ==
+
ansi-regex@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
diff --git a/sub/init.go b/sub/init.go
index 1adca9b..8efcb2e 100644
--- a/sub/init.go
+++ b/sub/init.go
@@ -5,7 +5,6 @@ import (
"OneAuth/libs/auth"
"OneAuth/models"
"github.com/urfave/cli/v2"
- "github.com/veypi/utils/cmd"
"github.com/veypi/utils/log"
"strconv"
)
@@ -20,6 +19,7 @@ func runInit(c *cli.Context) error {
}
// 初始化项目
+var appid uint
func InitSystem() error {
db()
@@ -27,15 +27,9 @@ func InitSystem() error {
if err != nil {
return err
}
- cfg.CFG.APPID = self.ID
- cfg.CFG.APPKey = self.Key
- err = cmd.DumpCfg(cfg.Path, cfg.CFG)
- // TODO
- //if err != nil {
- // return err
- //}
+ appid = self.ID
err = role(self.InitRoleID == 0)
- return nil
+ return err
}
func db() {
@@ -56,14 +50,14 @@ func selfApp() (*models.App, error) {
self := &models.App{
Name: "OA",
Icon: "",
- UUID: "jU5Jo5hM",
+ UUID: cfg.CFG.APPUUID,
Des: "",
Creator: 0,
UserCount: 0,
Hide: false,
Host: "",
UserRefreshUrl: "/",
- Key: "cB43wF94MLTksyBK",
+ Key: cfg.CFG.APPKey,
EnableRegister: true,
EnableUserKey: true,
EnableUser: true,
@@ -86,7 +80,7 @@ func role(reset_init_role bool) error {
}
var err error
adminRole := &models.Role{
- AppID: cfg.CFG.APPID,
+ AppID: appid,
Name: "admin",
IsUnique: false,
}
@@ -96,7 +90,7 @@ func role(reset_init_role bool) error {
}
for _, na := range n {
a := &models.Resource{
- AppID: cfg.CFG.APPID,
+ AppID: appid,
Name: na,
Tag: "",
Des: "",
@@ -112,7 +106,7 @@ func role(reset_init_role bool) error {
}
}
userRole := &models.Role{
- AppID: cfg.CFG.APPID,
+ AppID: appid,
Name: "user",
IsUnique: false,
}
@@ -120,12 +114,12 @@ func role(reset_init_role bool) error {
if err != nil {
return err
}
- err = auth.BindRoleAuth(cfg.DB(), userRole.ID, authMap[auth.APP].ID, models.AuthRead, strconv.Itoa(int(cfg.CFG.APPID)))
+ err = auth.BindRoleAuth(cfg.DB(), userRole.ID, authMap[auth.APP].ID, models.AuthRead, strconv.Itoa(int(appid)))
if err != nil {
return err
}
if reset_init_role {
- return cfg.DB().Model(&models.App{}).Where("id = ?", cfg.CFG.APPID).Update("init_role_id", adminRole.ID).Error
+ return cfg.DB().Model(&models.App{}).Where("id = ?", appid).Update("init_role_id", adminRole.ID).Error
}
return nil
}
diff --git a/sub/static/index.html b/sub/static/index.html
index 9831347..4b79a1f 100644
--- a/sub/static/index.html
+++ b/sub/static/index.html
@@ -1 +1,17 @@
-oaf
\ No newline at end of file
+
+
+
+
+
+
+ Vite App
+
+
+
+
+
+
+
+
+
+
diff --git a/sub/web.go b/sub/web.go
index ce43620..a0cde02 100644
--- a/sub/web.go
+++ b/sub/web.go
@@ -6,16 +6,15 @@ import (
"embed"
"github.com/urfave/cli/v2"
"github.com/veypi/OneBD"
- "github.com/veypi/OneBD/core"
- "github.com/veypi/OneBD/rfc"
"github.com/veypi/utils/log"
- "net/http"
- "os"
)
-//go:embed static
+//go:embed static/static
var staticFiles embed.FS
+//go:embed static/favicon.ico
+var icon []byte
+
//go:embed static/index.html
var indexFile []byte
@@ -37,34 +36,15 @@ func RunWeb(c *cli.Context) error {
LoggerPath: cfg.CFG.LoggerPath,
LoggerLevel: ll,
})
- app.Router().EmbedFile("/", indexFile)
- app.Router().EmbedDir("/", staticFiles, "static/")
-
- // TODO media 文件需要检验权限
- //app.Router().SubRouter("/media/").Static("/", cfg.CFG.EXEDir+"/media")
-
- app.Router().SetNotFoundFunc(func(m core.Meta) {
- f, err := os.Open(cfg.CFG.EXEDir + "/static/index.html")
- if err != nil {
- m.WriteHeader(rfc.StatusNotFound)
- return
- }
- defer f.Close()
- info, err := f.Stat()
- if err != nil {
- m.WriteHeader(rfc.StatusNotFound)
- return
- }
- if info.IsDir() {
- // TODO:: dir list
- m.WriteHeader(rfc.StatusNotFound)
- return
- }
- http.ServeContent(m, m.Request(), info.Name(), info.ModTime(), f)
- })
api.Router(app.Router().SubRouter("api"))
+ // TODO media 文件需要检验权限
+ app.Router().SubRouter("/media/").Static("/", cfg.CFG.MediaDir)
+ app.Router().EmbedDir("/static", staticFiles, "static/static/")
+ app.Router().EmbedFile("/favicon.ico", icon)
+ app.Router().EmbedFile("/*", indexFile)
+
log.Info().Msg("\nRouting Table\n" + app.Router().String())
return app.Run()
}