Compare commits

...

2 Commits

Author SHA1 Message Date
邹景立
403c0059a7 更新注释 2024-07-26 09:23:17 +08:00
邹景立
7afe94f1a2 调整指令 2024-07-26 09:09:54 +08:00
11 changed files with 222 additions and 192 deletions

View File

@ -27,10 +27,12 @@
<style>
@keyframes shadow {
0%,
100% {
transform: scale(1, 1);
}
50% {
transform: scale(1.2, 1);
}
@ -40,16 +42,20 @@
17% {
border-bottom-right-radius: 3px;
}
25% {
transform: translateY(9px) rotate(22.5deg);
}
50% {
border-bottom-right-radius: 40px;
transform: translateY(18px) scale(1, 0.9) rotate(45deg);
}
75% {
transform: translateY(9px) rotate(67.5deg);
}
100% {
transform: translateY(0) rotate(90deg);
}
@ -105,10 +111,10 @@
</head>
<body>
<div class="think-page-loader">
<div class="loader"></div>
</div>
<router-view></router-view>
<div class="think-page-loader">
<div class="loader"></div>
</div>
<router-view></router-view>
</body>
</html>

View File

@ -1,15 +1,16 @@
## ThinkAdmin for html
此分支是为`ThinkAdmin`下个版本前端`UI`构建测试用途。
此分支是为 `ThinkAdmin` 下个版本前端 `UI` 构建测试用途。
目前拟定以`Vue3`为技术核心库,基础`UI`组件库使用`Element-Plus`构建。
目前拟定以 `Vue3` 为技术核心库,基础 `UI` 组件库使用 `Element-Plus` 构建。
##### **集成组件:**
* vue v3.2.31
* vue.router v4.0.12
* vue.sfc.loader v0.8.4
* vue element-plus v2.0.3
- vue v3.4.34
- vue.router v4.4.0
- vue.sfc.loader v0.9.5
- vue element-plus v2.7.7
- vue element-plugs-icons v2.0.9
##### **在线体验:**
@ -17,4 +18,4 @@ http://html.thinkadmin.top
##### **建议收集:**
https://gitee.com/zoujingli/ThinkAdmin/issues/I4CK3H
https://gitee.com/zoujingli/ThinkAdmin/issues/I4CK3H

View File

@ -1,106 +1,131 @@
;(async () => {
/*! 项目应用根路径 */
window.appRoot = (function (script) {
return '/' + script.src.split('/').slice(3, -2).join('/') + '/';
})(document.querySelector('script[src*="app.js"]'));
// @ts-ignore
window.appRoot = document.querySelector('script[src*="app.js"]').src.split('/').slice(3, -2).join('/') + '/'
/*! 模块加载请求处理 */
const options = {
moduleCache: {
vue: Vue, less: less
}, getFile(url) {
if (!(/^(https?:)?\/\//)) {
url = (appRoot + url).replace(/\/+.?\/+/g, '/');
// 模块缓存
// @ts-ignore
moduleCache: { vue: Vue, less: less },
// 动态加载文件
getFile(url) {
if (!/^(https?:)?\/\//) {
// @ts-ignore
url = (appRoot + url).replace(/\/+.?\/+/g, '/')
}
return fetch(url).then(res => {
return fetch(url).then((res) => {
if (res.ok) {
return {getContentData: binary => binary ? res.arrayBuffer() : res.text()};
return { getContentData: (binary) => (binary ? res.arrayBuffer() : res.text()) }
} else if (res.status === 404) {
return `<template><el-empty description="${res.status},${res.statusText}">${url}</el-empty></template>`;
return `<template><el-empty description="${res.status},${res.statusText}">${url}</el-empty></template>`
} else {
throw Object.assign(new Error(url + ' ' + res.statusText), {res});
throw Object.assign(new Error(url + ' ' + res.statusText), { res })
}
});
}, addStyle(style) {
const before = document.head.getElementsByTagName('style')[0] || null;
const object = Object.assign(document.createElement('style'), {textContent: style});
document.head.insertBefore(object, before);
})
},
};
// 追加样式HTML
addStyle(style) {
const before = document.head.getElementsByTagName('style')[0] || null
const object = Object.assign(document.createElement('style'), { textContent: style })
document.head.insertBefore(object, before)
},
// 输出日志信息
log(type, ...args) {
console.log(type, ...args)
},
}
const {loadModule} = window['vue3-sfc-loader'];
const loadVue = (vuePath) => loadModule(vuePath, options);
const { loadModule } = window['vue3-sfc-loader']
const loadVue = (vuePath) => loadModule(vuePath, options)
// @ts-ignore
const router = VueRouter.createRouter({
routes: [], history: VueRouter.createWebHashHistory(),
});
routes: [],
// @ts-ignore
history: VueRouter.createWebHashHistory(),
})
// 创建后台主路由
router.addRoute({
name: 'layout', path: '/', component: () => {
return loadVue('/static/template/layout.vue');
}, children: [{path: '/', redirect: '/static/template/login.vue'},]
});
name: 'layout',
path: '/',
component: () => {
return loadVue('/static/template/layout.vue')
},
children: [{ path: '/', redirect: '/static/template/login.vue' }],
})
// 动态注销路由
router.afterEach(function (to) {
let name = to.fullPath.replace(/[.\/]+/g, '_');
let name = to.fullPath.replace(/[.\/]+/g, '_')
if (router.hasRoute(name)) router.removeRoute(name)
if (loading) loading = loading.close(), null;
document.querySelectorAll('.think-page-loader').forEach(function (el) {
el.style.display = 'none';
});
});
if (loading) (loading = loading.close()), null
// @ts-ignore
document.querySelectorAll('.think-page-loader').forEach((el) => (el.style.display = 'none'))
})
// 动态注册路由
let loading = null;
let loading = null
// @ts-ignore
router.beforeEach(function (to, fr, next) {
let name = to.fullPath.replace(/[.\/]+/g, '_');
let name = to.fullPath.replace(/[.\/]+/g, '_')
if (router.hasRoute(name)) {
console.log('PAGE-LOADING:', to.fullPath)
// @ts-ignore
loading = ElementPlus.ElLoading.service({
lock: true, text: 'Loading', background: 'rgba(0, 0, 0, 0.3)',
});
next();
lock: true,
text: 'Loading',
background: 'rgba(0, 0, 0, 0.3)',
})
next()
} else {
// 删除页面缓存
delete options.moduleCache[to.fullPath];
delete options.moduleCache[to.fullPath]
// 登录页面处理
if (to.fullPath.indexOf('/login.vue') > -1) {
router.addRoute({name: name, path: to.fullPath, component: () => loadVue(to.fullPath)})
router.addRoute({ name: name, path: to.fullPath, component: () => loadVue(to.fullPath) })
} else {
// 动态注册路由并触发新路由
router.addRoute('layout', {name: name, path: to.fullPath, component: () => loadVue(to.fullPath)});
router.addRoute('layout', { name: name, path: to.fullPath, component: () => loadVue(to.fullPath) })
}
next({name: name});
next({ name: name })
}
});
})
// 创建 Vue 应用
const app = Vue.createApp({});
// @ts-ignore
const app = Vue.createApp({})
app.directive('href', {
mounted(el, binding) {
console.log(el)
el.addEventListener(
'click',
(e) => {
e.stopPropagation()
if (binding.value) {
router.push(binding.value)
}
},
{ passive: false }
)
},
unmounted(el) {
// 移除点击事件监听器
el.removeEventListener('click')
},
})
// 定义全局缓存,加载字体组件
app.cache = {loadOpt: options, loadVue: loadVue, icons: ElementPlusIconsVue};
for (let i in app.cache.icons) app.component(i, app.cache.icons[i]);
// @ts-ignore
app.cache = { loadOpt: options, loadVue: loadVue, icons: ElementPlusIconsVue }
for (let i in app.cache.icons) app.component(i, app.cache.icons[i])
// 注册 getApp 获取应用
window.getApp = () => app;
// 绑定 data-route 路由处理
document.body.addEventListener('click', function (event) {
let target = event.target, attrname = 'data-router';
while (target && !target.hasAttribute(attrname)) {
target = target.parentElement;
if (target && target.hasAttribute(attrname)) break;
}
if (target && target.hasAttribute(attrname)) {
event.stopPropagation();
router.push(target.dataset.route);
}
});
// @ts-ignore
window.getApp = () => app
// 应用组件及路由
app.use(ElementPlus).use(router).mount(document.body);
})().catch(ex => console.error(ex));
// @ts-ignore
app.use(ElementPlus).use(router).mount(document.body)
})().catch((ex) => console.error(ex))

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,7 @@
<template>
<el-container>
<el-header>
<el-menu
mode="horizontal"
text-color="#fff"
background-color="rgba(54,25,88,0.9)"
active-text-color="rgba(54,25,88,1.0)"
>
<el-menu mode="horizontal" text-color="#fff" background-color="rgba(54,25,88,0.9)" active-text-color="rgba(54,25,88,1.0)">
<el-menu-item data-route="/" index="1">
<el-avatar size="small">Ta</el-avatar>
<span style="margin-left:5px">ThinkAdmin For HTML</span>
@ -54,24 +49,24 @@
<span>Navigator One</span>
</template>
<el-menu-item index="1-1" data-route="/static/template/pages/one.vue">item one route</el-menu-item>
<el-menu-item index="1-2" data-route="/static/template/pages/two.vue">item two route</el-menu-item>
<el-menu-item index="1-3" data-route="/static/template/pages/thr.vue">item Three route</el-menu-item>
<el-menu-item index="1-1" v-href="`/static/template/pages/one.vue`">item one route</el-menu-item>
<el-menu-item index="1-2" v-href="`/static/template/pages/two.vue`">item two route</el-menu-item>
<el-menu-item index="1-3" v-href="`/static/template/pages/thr.vue`">item Three route</el-menu-item>
</el-sub-menu>
<el-menu-item index="2" data-route="/static/template/pages/two.vue">
<el-menu-item index="2" v-href="`/static/template/pages/two.vue`">
<el-icon>
<aim></aim>
</el-icon>
<span>Navigator Two</span>
</el-menu-item>
<el-menu-item index="3" data-route="/static/template/pages/thr.vue">
<el-menu-item index="3" v-href="`/static/template/pages/thr.vue`">
<el-icon>
<document></document>
</el-icon>
<span>Navigator Three</span>
</el-menu-item>
<el-menu-item index="4" data-route="/static/template/pages/four.vue">
<el-menu-item index="4" v-href="`/static/template/pages/four.vue`">
<el-icon>
<setting></setting>
</el-icon>
@ -85,25 +80,57 @@
<el-main>
<router-view></router-view>
</el-main>
<el-footer>©版权所有 2014-2021 ThinkAdmin</el-footer>
<el-footer>©版权所有 2014-2024 ThinkAdmin</el-footer>
</el-container>
</el-container>
</el-container>
</template>
<style lang="less">
<script>
export default {
name: 'layout',
data() {
return {
menus: [
{ name: 'ONE', title: 'SHOW-ONE-LIST', subs: [] },
{ name: 'TWO', title: 'SHOW-TWO-LIST', subs: [] },
{ name: 'THR', title: 'SHOW-THR-LIST', subs: [] },
{ name: 'FOR', title: 'SHOW-FOR-LIST', subs: [] },
{ name: 'FIV', title: 'SHOW-FOR-LIST', subs: [] },
{ name: 'SIX', title: 'SHOW-FOR-LIST', subs: [] },
{ name: 'SEN', title: 'SHOW-FOR-LIST', subs: [] },
{ name: 'SIX', title: 'SHOW-FOR-LIST', subs: [] },
{ name: 'EVN', title: 'SHOW-FOR-LIST', subs: [] },
{ name: 'TEN', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '111', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '122', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '133', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '144', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '155', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '166', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '177', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '188', title: 'SHOW-FOR-LIST', subs: [] },
{ name: '199', title: 'SHOW-FOR-LIST', subs: [] },
]
}
}
}
</script>
html, body {
<style lang="less">
html,
body {
margin: 0;
height: 100%;
padding: 0;
display: block;
}
body > .el-container {
body>.el-container {
height: 100%;
> .el-header {
>.el-header {
margin: 0;
padding: 0;
@ -124,7 +151,10 @@ body > .el-container {
padding: 0;
font-weight: bold;
&:hover, &:active, &:focus, &.is-active {
&:hover,
&:active,
&:focus,
&.is-active {
color: #FFF !important;
background: rgba(0, 0, 0, 0) !important;
}
@ -162,10 +192,10 @@ body > .el-container {
}
}
> .el-container {
>.el-container {
height: 1px;
> .el-aside {
>.el-aside {
z-index: 99;
background: #53a8ff;
--el-aside-width: 280px;
@ -200,9 +230,11 @@ body > .el-container {
.el-tabs__item {
color: #FFF;
display: flex;
height: 58px !important;
line-height: 58px !important;
text-align: center !important;
justify-content: center;
&.is-active {
color: #333;
@ -236,34 +268,34 @@ body > .el-container {
}
}
> .el-container {
> .el-main {
>.el-container {
>.el-main {
padding: 0;
background: #EFEFEF;
> .el-container {
>.el-container {
height: 100%;
> .el-header {
>.el-header {
z-index: 99;
background: white;
line-height: 60px;
box-shadow: 0 0 6px 0 rgb(0 0 0 / 20%);
}
> .el-main {
>.el-main {
height: 1px;
z-index: 88;
--el-main-padding: 0;
> .el-scrollbar {
>.el-scrollbar {
padding: 0;
box-sizing: border-box;
> .el-scrollbar__wrap {
>.el-scrollbar__wrap {
border-radius: 5px;
> .el-scrollbar__view {
>.el-scrollbar__view {
margin: 15px;
padding: 20px;
background: #FFF;
@ -276,7 +308,7 @@ body > .el-container {
}
}
> .el-footer {
>.el-footer {
color: #333;
z-index: 99;
box-shadow: 0 0 6px 0 rgb(0 0 0 / 20%);
@ -288,37 +320,3 @@ body > .el-container {
}
}
</style>
<script>
export default {
name: 'layout',
data() {
return {
menus: [
{name: 'ONE', title: 'SHOW-ONE-LIST', subs: []},
{name: 'TWO', title: 'SHOW-TWO-LIST', subs: []},
{name: 'THR', title: 'SHOW-THR-LIST', subs: []},
{name: 'FOR', title: 'SHOW-FOR-LIST', subs: []},
{name: 'FIV', title: 'SHOW-FOR-LIST', subs: []},
{name: 'SIX', title: 'SHOW-FOR-LIST', subs: []},
{name: 'SEN', title: 'SHOW-FOR-LIST', subs: []},
{name: 'SIX', title: 'SHOW-FOR-LIST', subs: []},
{name: 'EVN', title: 'SHOW-FOR-LIST', subs: []},
{name: 'TEN', title: 'SHOW-FOR-LIST', subs: []},
{name: '111', title: 'SHOW-FOR-LIST', subs: []},
{name: '122', title: 'SHOW-FOR-LIST', subs: []},
{name: '133', title: 'SHOW-FOR-LIST', subs: []},
{name: '144', title: 'SHOW-FOR-LIST', subs: []},
{name: '155', title: 'SHOW-FOR-LIST', subs: []},
{name: '166', title: 'SHOW-FOR-LIST', subs: []},
{name: '177', title: 'SHOW-FOR-LIST', subs: []},
{name: '188', title: 'SHOW-FOR-LIST', subs: []},
{name: '199', title: 'SHOW-FOR-LIST', subs: []},
]
}
},
created() {
let app = this;
}
}
</script>

View File

@ -10,7 +10,7 @@
<el-input v-model="login.verify" placeholder="请输入图形验证"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" data-route="/static/template/pages/one.vue">登录</el-button>
<el-button type="primary" v-href="`/static/template/pages/one.vue`">登录</el-button>
</el-form-item>
</el-form>
</template>
@ -26,7 +26,7 @@
</style>
<script lang="ts" setup>
import {reactive, ref} from 'vue'
import {reactive} from 'vue'
const login = reactive({
verify: '',

View File

@ -28,9 +28,9 @@
</el-form>
<el-table :data="tableData" border style="width:100%">
<el-table-column prop="date" label="Date" width="180"/>
<el-table-column prop="name" label="Name" width="180"/>
<el-table-column prop="address" label="Address"/>
<el-table-column prop="date" label="Date" width="180" />
<el-table-column prop="name" label="Name" width="180" />
<el-table-column prop="address" label="Address" />
</el-table>
</el-scrollbar>