diff --git a/examples/App.vue b/examples/App.vue index 13f3976..28bbdc4 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -1,5 +1,6 @@ - console.log(pwd)" :checkUser="true" username="超级管理员" :closeAble="true"> + console.log(pwd)" :checkUser="true" username="超级管理员" :closeAble="true" + mode="horizontal"> @@ -10,29 +11,29 @@ import { Index, Views } from "noob-mengyxu"; const store = useStore(); const { buff, dictionary, config, permission, role, user, status, log } = Views.menus; -// const menus = [ -// { -// i18n: "menu.home", path: "home", icon: "HomeFilled" -// }, -// { -// i18n: "menu.operator", path: "operator", icon: "Platform", children: [ -// buff, dictionary, config, permission, role, user, status, log -// ] -// }, -// { -// i18n: "menu.base", path: "base", icon: "House", children: [ -// { i18n: "menu.table", path: "table", icon: "List" }, -// { i18n: "menu.form", path: "form", icon: "Postcard" }, -// ] -// }, -// { -// i18n: "menu.tool", path: "tool", icon: "Tools", children: [ -// { i18n: "menu.terminal", path: "terminal", icon: "Platform" }, -// { i18n: "menu.color", path: "color", icon: "MagicStick" }, -// ] -// } -// ] -const menus = null; +const menus = [ + { + i18n: "menu.home", path: "home", icon: "HomeFilled" + }, + { + i18n: "menu.operator", path: "operator", icon: "Platform", children: [ + buff, dictionary, config, permission, role, user, status, log + ] + }, + { + i18n: "menu.base", path: "base", icon: "House", children: [ + { i18n: "menu.table", path: "table", icon: "List" }, + { i18n: "menu.form", path: "form", icon: "Postcard" }, + ] + }, + { + i18n: "menu.tool", path: "tool", icon: "Tools", children: [ + { i18n: "menu.terminal", path: "terminal", icon: "Platform" }, + { i18n: "menu.color", path: "color", icon: "MagicStick" }, + ] + } +] +// const menus = null; onMounted(() => { }); @@ -41,5 +42,4 @@ onMounted(() => { }); \ No newline at end of file +// } \ No newline at end of file diff --git a/examples/config/router.ts b/examples/config/router.ts index 25bf6a3..05f724d 100644 --- a/examples/config/router.ts +++ b/examples/config/router.ts @@ -1,5 +1,5 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'; -import { Views } from 'noob-mengyxu'; +import { Views, Common } from 'noob-mengyxu'; import Home from '../view/home.vue'; import Table from '../view/base/table.vue'; import Form from '../view/base/form.vue'; @@ -16,6 +16,11 @@ const routes: Array = [ name: 'home', component: Home, }, + { + path: '/login', + name: 'login', + component: Common.Login2, + }, { path: '/table', name: 'table', diff --git a/examples/store/index.ts b/examples/store/index.ts index b0ed7e9..08fb240 100644 --- a/examples/store/index.ts +++ b/examples/store/index.ts @@ -3,8 +3,11 @@ import state from './state'; import mutations from './mutations'; import actions from './actions'; +const getters = new Store.Getters(); + export default Store.createStore({ state, + getters, mutations, actions, }); diff --git a/examples/store/state.ts b/examples/store/state.ts index 693dab9..50ba0af 100644 --- a/examples/store/state.ts +++ b/examples/store/state.ts @@ -1,9 +1,10 @@ -import { Store } from 'noob-mengyxu'; +import { Store, Styles } from 'noob-mengyxu'; class State extends Store.State { test = [ { key: 'a', value: 'A' }, { key: 'b', value: 'B' }, { key: 'c', value: 'C' }, ]; + style = Styles.plainb; } export default new State(); diff --git a/package.json b/package.json index 32531fe..53b0fc0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "noob-mengyxu", - "version": "0.3.8", + "version": "0.4.0", "main": "index.ts", "module": "index.ts", "keywords": [ diff --git a/packages/base/data/login-form.vue b/packages/base/data/login-form.vue deleted file mode 100644 index ed22976..0000000 --- a/packages/base/data/login-form.vue +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - {{ t('title') }} - - - - - - - - - {{ t('pwd.login') }} - - - - - - \ No newline at end of file diff --git a/packages/base/data/search-row.vue b/packages/base/data/search-row.vue index a0709a3..8b6f60a 100644 --- a/packages/base/data/search-row.vue +++ b/packages/base/data/search-row.vue @@ -75,8 +75,10 @@ onMounted(() => { }); .search-row, .query, +.title, .left { height: v-bind('state.size.searchRowHeight'); + line-height: v-bind('state.size.searchRowHeight'); } .title { @@ -84,5 +86,6 @@ onMounted(() => { }); padding-right: 15px; font-size: v-bind('state.size.titleSize'); min-width: 20px; + color: v-bind('state.style.subTitleColor') } \ No newline at end of file diff --git a/packages/base/index.ts b/packages/base/index.ts index 224c571..b3aee61 100644 --- a/packages/base/index.ts +++ b/packages/base/index.ts @@ -11,15 +11,6 @@ import SearchRow from './data/search-row.vue'; import ListTable from './data/list-table.vue'; import Infomation from './data/infomation.vue'; import ModifyForm from './data/modify-form.vue'; -import LoginForm from './data/login-form.vue'; import Descriptions from './data/descriptions.vue'; import TableAction from './data/table-action.vue'; -export { - SearchRow, - ListTable, - Infomation, - ModifyForm, - LoginForm, - Descriptions, - TableAction, -}; +export { SearchRow, ListTable, Infomation, ModifyForm, Descriptions, TableAction }; diff --git a/packages/base/item/input.vue b/packages/base/item/input.vue index cde3280..edd5aac 100644 --- a/packages/base/item/input.vue +++ b/packages/base/item/input.vue @@ -1,5 +1,5 @@ - {{ label }} @@ -22,6 +22,10 @@ const prop = defineProps({ type: String, default: null }, + class: { + type: String, + default: null + }, type: { type: String, default: null diff --git a/packages/manage/common/head.vue b/packages/manage/common/head.vue deleted file mode 100644 index b2c0a3a..0000000 --- a/packages/manage/common/head.vue +++ /dev/null @@ -1,283 +0,0 @@ - - - - - - {{ title || t('title') }} - - - - - - - - {{ t('head.center') }} - - {{ t('pwd.changePwd') }} - {{ t('head.logout') - }} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ t('head.zh') }} - {{ t('head.en') }} - - - - - - - - - - {{ t('head.small') }} - {{ t('head.normal') }} - {{ t('head.large') }} - - - - - {{ username }} - - - - - - - - - - - \ No newline at end of file diff --git a/packages/manage/common/index.ts b/packages/manage/common/index.ts new file mode 100644 index 0000000..192c1f6 --- /dev/null +++ b/packages/manage/common/index.ts @@ -0,0 +1,4 @@ +import Login from './login.vue'; +import Login2 from './login2.vue'; + +export default { Login, Login2 }; diff --git a/packages/manage/common/login.vue b/packages/manage/common/login.vue new file mode 100644 index 0000000..7471170 --- /dev/null +++ b/packages/manage/common/login.vue @@ -0,0 +1,127 @@ + + + + + + + + {{ t('title') }} + + + + + + + + + + {{ t('pwd.login') }} + + + + + + + \ No newline at end of file diff --git a/packages/manage/common/login2.vue b/packages/manage/common/login2.vue new file mode 100644 index 0000000..16c0ef8 --- /dev/null +++ b/packages/manage/common/login2.vue @@ -0,0 +1,145 @@ + + + + + + + {{ t('title') }} + + {{ t('pwd.userId') }}: + + + + {{ t('pwd.pwd') }}: + + + + {{ t('pwd.login') }} + + + + + + + \ No newline at end of file diff --git a/packages/manage/head/fullscreen.vue b/packages/manage/head/fullscreen.vue new file mode 100644 index 0000000..7f54959 --- /dev/null +++ b/packages/manage/head/fullscreen.vue @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file diff --git a/packages/manage/head/head.vue b/packages/manage/head/head.vue new file mode 100644 index 0000000..96b7489 --- /dev/null +++ b/packages/manage/head/head.vue @@ -0,0 +1,119 @@ + + + + + + + {{ title || t('title') }} + + + + + + {{ username }} + + + + + + diff --git a/packages/manage/head/index.ts b/packages/manage/head/index.ts new file mode 100644 index 0000000..7df5ba3 --- /dev/null +++ b/packages/manage/head/index.ts @@ -0,0 +1,9 @@ +import Head from './head.vue'; +import HeadPersonal from './personal.vue'; +import Fullscreen from './fullscreen.vue'; +import StyleChange from './style-change.vue'; +import LangChange from './lang-change.vue'; +import SizeChange from './size-change.vue'; +import MenuTree from './menu-tree.vue'; + +export default { MenuTree, Head, HeadPersonal, Fullscreen, StyleChange, LangChange, SizeChange }; diff --git a/packages/manage/head/lang-change.vue b/packages/manage/head/lang-change.vue new file mode 100644 index 0000000..087fe41 --- /dev/null +++ b/packages/manage/head/lang-change.vue @@ -0,0 +1,29 @@ + + + + + + + {{ t('head.zh') }} + {{ t('head.en') }} + + + + + + + + \ No newline at end of file diff --git a/packages/manage/common/menu-tree.vue b/packages/manage/head/menu-tree.vue similarity index 65% rename from packages/manage/common/menu-tree.vue rename to packages/manage/head/menu-tree.vue index 3395374..dd294b8 100644 --- a/packages/manage/common/menu-tree.vue +++ b/packages/manage/head/menu-tree.vue @@ -1,15 +1,19 @@ - + - + + {{ menu.title || t(menu.i18n) }} - + + {{ child.title || t(child.i18n) }} @@ -26,22 +30,23 @@ diff --git a/packages/manage/head/personal.vue b/packages/manage/head/personal.vue new file mode 100644 index 0000000..884bf88 --- /dev/null +++ b/packages/manage/head/personal.vue @@ -0,0 +1,87 @@ + + + + + + + {{ t('head.center') }} + + {{ t('pwd.changePwd') }} + {{ t('head.logout') + }} + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/manage/head/size-change.vue b/packages/manage/head/size-change.vue new file mode 100644 index 0000000..50a5303 --- /dev/null +++ b/packages/manage/head/size-change.vue @@ -0,0 +1,32 @@ + + + + + + + {{ t('head.small') }} + {{ t('head.normal') }} + {{ t('head.large') }} + + + + + + + + \ No newline at end of file diff --git a/packages/manage/head/style-change.vue b/packages/manage/head/style-change.vue new file mode 100644 index 0000000..1cfce7f --- /dev/null +++ b/packages/manage/head/style-change.vue @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/manage/index.ts b/packages/manage/index.ts index d5abcaa..b94757e 100644 --- a/packages/manage/index.ts +++ b/packages/manage/index.ts @@ -1,5 +1,5 @@ import Index from './router/index.vue'; -import MenuTree from './common/menu-tree.vue'; -import Head from './common/head.vue'; +import Common from './common'; +import NoobHead from './head'; import Views from './views'; -export { Index, MenuTree, Head, Views }; +export { Index, Common, NoobHead, Views }; diff --git a/packages/manage/router/index.vue b/packages/manage/router/index.vue index f2418d6..6057d60 100644 --- a/packages/manage/router/index.vue +++ b/packages/manage/router/index.vue @@ -2,12 +2,21 @@ - + + + + + + + + + + + - - + + @@ -20,7 +29,8 @@ import { reactive, onMounted, ref, onBeforeUnmount } from "vue"; import { useStore } from "vuex"; import { useRouter } from "vue-router"; -import { MenuTree, Head, Api } from "noob-mengyxu" +import { NoobHead, Api } from "noob-mengyxu" +const { Head, MenuTree, HeadPersonal, Fullscreen, StyleChange, LangChange, SizeChange } = NoobHead; import md5 from "js-md5"; const { state, commit, dispatch } = useStore(); @@ -47,9 +57,9 @@ const props = defineProps({ type: Array(), default: null }, - type: { + mode: { type: String, - default: 'def', + default: 'vertical', }, styleAble: { type: Boolean, @@ -88,7 +98,7 @@ const props = defineProps({ const onResize = () => { const height = window.innerHeight; appMain.height = height + 'px'; - commit('initSize', height); + commit('initSize', [height, window.innerWidth]); } const getUser = (first?) => { @@ -172,6 +182,18 @@ body { .app-head { padding: 0px !important; + background-color: v-bind('state.style.headBg'); + height: v-bind('state.size.headHeight'); +} + +.head-icon { + float: right; + cursor: pointer; + height: v-bind('state.size.headHeight'); + margin-right: 20px; + font-size: v-bind('state.size.headIconSize'); + align-items: center; + color: v-bind('state.style.color'); } .form-item { @@ -216,4 +238,5 @@ body { color: v-bind('state.style.selectionColor'); } } + \ No newline at end of file diff --git a/packages/manage/views/index.ts b/packages/manage/views/index.ts index 592acd3..278b199 100644 --- a/packages/manage/views/index.ts +++ b/packages/manage/views/index.ts @@ -1,4 +1,3 @@ -import Login from './login.vue'; import Buffer from './buffer.vue'; import Config from './config.vue'; import Dictionary from './dictionary.vue'; @@ -8,11 +7,6 @@ import User from './user.vue'; import Status from './status.vue'; import Log from './log.vue'; const routes = [ - { - path: '/login', - name: 'login', - component: Login, - }, { path: '/buffer', name: 'buffer', diff --git a/packages/manage/views/login.vue b/packages/manage/views/login.vue deleted file mode 100644 index 1d3f485..0000000 --- a/packages/manage/views/login.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/plugs/config/size/large.ts b/plugs/config/size/large.ts index a9dbd6b..2f43aa7 100644 --- a/plugs/config/size/large.ts +++ b/plugs/config/size/large.ts @@ -8,7 +8,7 @@ export default class Small extends Normal { headIconSize = '24px'; //头部图标尺寸 headHeight = '60px'; //头部高度 closeTop = '45px'; //展开收起菜单按钮 - headMenuWidth = '450px'; //头部右侧菜单宽度 + headRightWidth = '450px'; //头部右侧菜单宽度 asideWidth = '200px'; //左侧菜单宽度 mainPad = '8px'; diff --git a/plugs/config/size/normal.ts b/plugs/config/size/normal.ts index 4901b21..3a8068c 100644 --- a/plugs/config/size/normal.ts +++ b/plugs/config/size/normal.ts @@ -7,7 +7,8 @@ export default class Normal { headIconSize = '20px'; //头部图标尺寸 headHeight = '50px'; //头部高度 closeTop = '40px'; //展开收起菜单按钮 - headMenuWidth = '400px'; //头部右侧菜单宽度 + headRightWidth = '400px'; //头部右侧菜单宽度 + headLeftWidth = ''; //头部左侧剩余宽度 asideWidth = '180px'; //左侧菜单宽度 mainHeight = ''; //通用页面组件高度 mainPad = '5px'; //通用页面组件内边距 diff --git a/plugs/config/size/small.ts b/plugs/config/size/small.ts index 5f19980..ca02a5c 100644 --- a/plugs/config/size/small.ts +++ b/plugs/config/size/small.ts @@ -8,7 +8,7 @@ export default class Small extends Normal { headIconSize = '16px'; //头部图标尺寸 headHeight = '45px'; //头部高度 closeTop = '35px'; //展开收起菜单按钮 - headMenuWidth = '350px'; //头部右侧菜单宽度 + headRightWidth = '350px'; //头部右侧菜单宽度 asideWidth = '160px'; //左侧菜单宽度 menuIconSize = '16px'; diff --git a/plugs/config/styles/dark.ts b/plugs/config/styles/dark.ts index d7c0b55..1d18c0a 100644 --- a/plugs/config/styles/dark.ts +++ b/plugs/config/styles/dark.ts @@ -3,8 +3,11 @@ import { light, dark, grey } from './color'; export default class Dark extends Plain { name = 'dark'; //总体样式名称 + icon = 'MoonNight'; //图标样式 + i18n = 'styles.2'; //样式提示i18n配置 bodyBg = dark[3]; //全局背景颜色 titleColor = light[0]; //标题颜色 + subTitleColor = light[4];//二级标题颜色 color = grey[5]; //全局字体颜色 selectionBg = '#0438a2'; //全局文字选中后背景 diff --git a/plugs/config/styles/index.ts b/plugs/config/styles/index.ts index 9b63258..4a3628c 100644 --- a/plugs/config/styles/index.ts +++ b/plugs/config/styles/index.ts @@ -1,6 +1,8 @@ import Plain from './plain'; +import Plainb from './plainb'; import Light from './light'; import Dark from './dark'; export const plain = new Plain(); +export const plainb = new Plainb(); export const light = new Light(); export const dark = new Dark(); diff --git a/plugs/config/styles/light.ts b/plugs/config/styles/light.ts index 08f7117..c56e686 100644 --- a/plugs/config/styles/light.ts +++ b/plugs/config/styles/light.ts @@ -3,8 +3,11 @@ import { light, dark, grey } from './color'; export default class Light extends Plain { name = 'light'; //总体样式名称 + icon = 'Sunny'; //图标样式 + i18n = 'styles.1'; //样式提示i18n配置 bodyBg = light[0]; //全局背景颜色 titleColor = dark[0]; //标题颜色 + subTitleColor = dark[3];//二级标题颜色 headBg = light[0]; //头部背景颜色 menuBg = light[0]; //菜单背景颜色 diff --git a/plugs/config/styles/plain.ts b/plugs/config/styles/plain.ts index 53cf67d..6839819 100644 --- a/plugs/config/styles/plain.ts +++ b/plugs/config/styles/plain.ts @@ -1,10 +1,13 @@ -import { light, dark } from './color'; +import { light, dark, grey } from './color'; export default class Plain { name = 'plain'; //总体样式名称 + icon = 'Sunset'; //图标样式 + i18n = 'styles.0'; //样式提示i18n配置 // bodyBg = light[0]; //全局背景颜色 bodyBg = light[7]; //全局背景颜色 titleColor = light[0]; //标题颜色 + subTitleColor = dark[9];//二级标题颜色 color = '#4e5969'; //全局字体颜色 selectionBg = '#3367d1'; //全局文字选中后背景 selectionColor = '#fff'; //全局文字选中后背景 diff --git a/plugs/config/styles/plainb.ts b/plugs/config/styles/plainb.ts new file mode 100644 index 0000000..b9c35dc --- /dev/null +++ b/plugs/config/styles/plainb.ts @@ -0,0 +1,17 @@ +import Plain from './plain'; +import { light, dark, grey } from './color'; + +export default class Plainb extends Plain { + name = 'plainb'; //总体样式名称 + i18n = 'styles.3'; //样式提示i18n配置 + // bodyBg = light[0]; //全局背景颜色 + bodyBg = light[0]; //全局背景颜色 + titleColor = light[3]; //标题颜色 + subTitleColor = '#424242'; //二级标题颜色 + color = grey[0]; //全局字体颜色 + selectionBg = '#9255f4'; //全局文字选中后背景 + + headBg = '#6200ee'; //头部背景颜色 + + menuBg = '#ebebeb'; //菜单背景颜色 +} diff --git a/plugs/i18n/en.ts b/plugs/i18n/en.ts index a660171..10098eb 100644 --- a/plugs/i18n/en.ts +++ b/plugs/i18n/en.ts @@ -36,14 +36,13 @@ export default class English { required: 'The password contains at least uppercase and lowercase letters and numbers', }; + styles = ['Default', 'Lignt', 'Dark', 'DefaultB']; + head = { center: 'Personal center', logout: 'Logout', fullScreen: 'Toggle full screen', changeStyle: 'Switch themes', - default: 'Default', - light: 'Lignt', - dark: 'Dark', language: 'Language', zh: 'Chinese', en: 'English', diff --git a/plugs/i18n/zh.ts b/plugs/i18n/zh.ts index 368aefb..46bea48 100644 --- a/plugs/i18n/zh.ts +++ b/plugs/i18n/zh.ts @@ -35,15 +35,13 @@ export default class Zh { noSpace: '密码不能包含空格', required: '密码至少包含大小写字母和数字', }; + styles = ['默认', '明亮', '黑夜', '默认2']; head = { center: '个人中心', logout: '退出登录', fullScreen: '切换全屏', changeStyle: '切换主题', - default: '默认', - light: '明亮', - dark: '黑夜', language: '语言', zh: '中文', en: '英文', diff --git a/plugs/store/index.ts b/plugs/store/index.ts index 1e11090..14d0a47 100644 --- a/plugs/store/index.ts +++ b/plugs/store/index.ts @@ -61,29 +61,37 @@ export class Mutations { updateState = (state, param) => { state[param[0]] = param[1]; }; - initSize = (state, height) => { + initSize = (state, param) => { const size = state.size; const head = parseInt(size.headHeight); const mainPad = parseInt(size.mainPad); const searchRow = parseInt(size.searchRowHeight); const searchRowPad = parseInt(size.searchRowPad); - if (height) { - size.height = height; - } else { - height = size.height; + const headRightWidth = parseInt(size.headRightWidth); + if (param) { + size.height = param[0]; + size.width = param[1]; } - size.mainHeight = Math.floor(height - head) + 'px'; - size.tableHeight = height - 2 * (mainPad + searchRowPad) - 3 - searchRow - head; + size.mainHeight = Math.floor(size.height - head) + 'px'; + size.tableHeight = size.height - 2 * (mainPad + searchRowPad) - 3 - searchRow - head; size.pTableHeight = size.tableHeight - size.pageHeight; + + size.headLeftWidth = size.width - headRightWidth - 10 + 'px'; }; updateDict = (state, param) => { state.dict[param[0]] = param[1]; }; } +export class Getters { + menuIconSize = (state) => { + return state.size.menuIconSize; + }; +} + export interface StoreOptions { state?: State; - getters?; + getters?: Getters; actions?; mutations?: Mutations; modules?;