This commit is contained in:
wangchen147 2023-11-27 15:33:54 +08:00
parent a0c9a04155
commit 85422756a9
18 changed files with 654 additions and 460 deletions

View File

@ -45,6 +45,6 @@ export function getModuleVersion() {
* @param params * @param params
* @returns * @returns
*/ */
export function downloadVersion(addon) { export function downloadVersion(params: Record<string, any>) {
return request.post(`addon/download/${addon}`, {}, {showSuccessMessage: true}) return request.post(`addon/download/${params.addon}`, params, { showSuccessMessage: true })
} }

View File

@ -16,6 +16,7 @@
"refreshPage": "刷新", "refreshPage": "刷新",
"placeholderTemplate": "请选择一个模板", "placeholderTemplate": "请选择一个模板",
"placeholderMyPage": "请选择一个微页面", "placeholderMyPage": "请选择一个微页面",
"placeholderOtherPage": "请选择一个页面",
"developTitle": "开发环境配置", "developTitle": "开发环境配置",
"wapDomain": "wap域名WAP_DOMAIN", "wapDomain": "wap域名WAP_DOMAIN",
"wapDomainPlaceholder": "请输入wap域名" "wapDomainPlaceholder": "请输入wap域名"

View File

@ -0,0 +1,12 @@
{
"preview": "预览",
"weapp": "微信小程序",
"wechat": "微信公众号",
"link": "链接",
"copy": "复制",
"copySuccess": "复制成功",
"weappNotSet": "小程序未配置",
"developTitle": "开发环境配置",
"wapDomain": "wap域名WAP_DOMAIN",
"wapDomainPlaceholder": "请输入wap域名"
}

View File

@ -540,7 +540,7 @@
save((id: number) => { save((id: number) => {
id = diyStore.id || id; id = diyStore.id || id;
let url = router.resolve({ let url = router.resolve({
path: '/preview/wap', path: '/site/preview/wap',
query: { query: {
page: page.value + '?id=' + id page: page.value + '?id=' + id
} }

View File

@ -27,8 +27,7 @@
<div class="item-hide absolute inset-x-0 inset-y-0 bg-black bg-opacity-50 text-center" <div class="item-hide absolute inset-x-0 inset-y-0 bg-black bg-opacity-50 text-center"
:class="{ 'disabled' : item.isDisabledPop }"> :class="{ 'disabled' : item.isDisabledPop }">
<div <div class="item-btn-box absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] flex flex-col flex-wrap">
class="item-btn-box absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] flex flex-col flex-wrap">
<el-button @click="show(key,item)">{{ t('changePage') }}</el-button> <el-button @click="show(key,item)">{{ t('changePage') }}</el-button>
<el-button @click="toDecorate(item.use_template)" <el-button @click="toDecorate(item.use_template)"
v-show="item.use_template.mode != 'other' || item.use_template.action == 'decorate'">{{ v-show="item.use_template.mode != 'other' || item.use_template.action == 'decorate'">{{
@ -46,8 +45,7 @@
<el-form :model="form" label-width="0px" v-if="formData.type"> <el-form :model="form" label-width="0px" v-if="formData.type">
<el-form-item label=""> <el-form-item label="">
<div>{{ t('hopeBeforeTip') }}<span class="text-primary px-[5px]">{{ page[formData.type].title <div>{{t('hopeBeforeTip')}}<span class="text-primary px-[5px]">{{ page[formData.type].title }}</span>{{t('hopeAfterTip')}}
}}</span>{{ t('hopeAfterTip') }}
</div> </div>
</el-form-item> </el-form-item>
@ -68,7 +66,8 @@
<el-form-item label="" v-show="hope == 'diy'"> <el-form-item label="" v-show="hope == 'diy'">
<el-select v-model="formData.id" class="w-full"> <el-select v-model="formData.id" class="w-full">
<el-option v-for="(item, index) in page[formData.type].my_page" :label="item.title" :value="item.id" /> <el-option v-for="(item, index) in page[formData.type].my_page" :label="item.title"
:value="item.id"/>
</el-select> </el-select>
<div class="mt-[10px]"> <div class="mt-[10px]">
<span class="cursor-pointer text-primary mr-[10px]" @click="toDiyList">{{ t('createPage') }}</span> <span class="cursor-pointer text-primary mr-[10px]" @click="toDiyList">{{ t('createPage') }}</span>
@ -92,6 +91,7 @@
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -112,6 +112,7 @@ const wapDomain = ref('')
// //
const formData = reactive({ const formData = reactive({
type: '', type: '',
name: '',
mode: '', mode: '',
template: '', template: '',
id: '', id: '',
@ -122,200 +123,204 @@ const formData = reactive({
// //
const refreshData = () => { const refreshData = () => {
formData.type = '' formData.type = '';
formData.mode = '' formData.name = '';
formData.template = '' formData.mode = '';
formData.id = '' formData.template = '';
formData.page = '' formData.id = '';
formData.title = '' formData.page = '';
formData.action = '' formData.title = '';
getDecoratePage({}).then(res => { formData.action = '';
for (const key in res.data) { getDecoratePage({}).then((res => {
for (let key in res.data) {
page[key] = res.data[key] page[key] = res.data[key]
} }
for (const key in page) { for (let key in page) {
if (page[key].use_template.url) { if (page[key].use_template.url) {
page[key].loadingIframe = false // iframe
page[key].loadingDev = false //
page[key].isDisabledPop = false //
page[key].difference = 0 // 1000wap
wapDomain.value = page[key].domain_url.wap_domain page[key].loadingIframe = false; // iframe
page[key].wapUrl = page[key].domain_url.wap_url page[key].loadingDev = false; //
page[key].isDisabledPop = false; //
page[key].difference = 0; // 1000wap
wapDomain.value = page[key].domain_url.wap_domain;
page[key].wapUrl = page[key].domain_url.wap_url;
if (import.meta.env.MODE == 'development') { if (import.meta.env.MODE == 'development') {
// wap // wap
if (wapDomain.value) { if (wapDomain.value) {
page[key].wapUrl = wapDomain.value + '/wap' page[key].wapUrl = wapDomain.value + '/wap';
setDomain(key) setDomain(key);
} }
if (storage.get('wap_domain')) { if (storage.get('wap_domain')) {
page[key].wapUrl = storage.get('wap_domain') page[key].wapUrl = storage.get('wap_domain')
setDomain(key) setDomain(key);
} }
} }
setDomain(key) setDomain(key);
} }
} }
})
}
refreshData() }));
}
refreshData();
// uni-app // uni-app
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
try { try {
const data = JSON.parse(event.data) let data = JSON.parse(event.data);
if (['appOnLaunch', 'appOnReady'].indexOf(data.type) != -1) { if (['appOnLaunch', 'appOnReady'].indexOf(data.type) != -1) {
for (const key in page) { for (let key in page) {
page[key].loadingDev = false // page[key].loadingDev = false; //
page[key].loadingIframe = true // iframe page[key].loadingIframe = true; // iframe
const loadTime = new Date().getTime() var loadTime = new Date().getTime();
page[key].difference = loadTime - page[key].timeIframe page[key].difference = loadTime - page[key].timeIframe;
page[key].isDisabledPop = false // page[key].isDisabledPop = false; //
} }
} }
} catch (e) { } catch (e) {
for (const key in page) { for (let key in page) {
initLoad(key) initLoad(key);
} }
console.log('后台接受数据错误', e) console.log('后台接受数据错误', e)
} }
}, false) }, false);
// uniapp // uniapp
const postMessage = (key: string) => { const postMessage = (key: string) => {
const diyData = JSON.stringify({ var diyData = JSON.stringify({
type: 'appOnReady', type: 'appOnReady',
message: '加载完成' message: '加载完成'
}) });
if (window['previewIframe_' + key]) window['previewIframe_' + key].contentWindow.postMessage(diyData, '*') if (window['previewIframe_' + key]) window['previewIframe_' + key].contentWindow.postMessage(diyData, '*');
} };
// //
const initLoad = (key: string) => { const initLoad = (key: string) => {
page[key].loadingDev = true page[key].loadingDev = true;
page[key].isDisabledPop = true page[key].isDisabledPop = true;
page[key].loadingIframe = false page[key].loadingIframe = false;
} }
const saveDomain = () => { const saveDomain = () => {
if (wapDomain.value.trim().length == 0) { if (wapDomain.value.trim().length == 0) {
ElMessage({ ElMessage({
type: 'warning', type: 'warning',
message: `${t('wapDomainPlaceholder')}` message: `${t('wapDomainPlaceholder')}`,
}) });
return return;
} }
const wapUrl = wapDomain.value + '/wap' let wapUrl = wapDomain.value + '/wap';
storage.set({ key: 'wap_domain', data: wapUrl }) storage.set({key: 'wap_domain', data: wapUrl});
for (const key in page) { for (let key in page) {
if (page[key].use_template.url) { if (page[key].use_template.url) {
page[key].wapUrl = wapUrl page[key].wapUrl = wapUrl;
setDomain(key) setDomain(key);
} }
} }
setTimeout(() => { setTimeout(() => {
for (const key in page) { for (let key in page) {
if (page[key].use_template.url) { if (page[key].use_template.url) {
page[key].loadingIframe = true // iframe page[key].loadingIframe = true; // iframe
page[key].loadingDev = false // page[key].loadingDev = false; //
page[key].isDisabledPop = false // page[key].isDisabledPop = false; //
} }
} }
}, 100 * 3) }, 100 * 3);
} }
const setDomain = (key: string) => { const setDomain = (key: string) => {
page[key].use_template.wapPreview = page[key].wapUrl + page[key].use_template.url page[key].use_template.wapPreview = page[key].wapUrl + page[key].use_template.url;
page[key].timeIframe = new Date().getTime() page[key].timeIframe = new Date().getTime();
postMessage(key) postMessage(key);
setTimeout(() => { setTimeout(() => {
if (page[key].difference == 0) initLoad(key) if (page[key].difference == 0) initLoad(key);
}, 1000 * 2) }, 1000 * 2);
} }
const show = (key: string, data: any) => { const show = (key: string, data: any) => {
// //
showDialog.value = true showDialog.value = true;
hope.value = data.use_template.hope hope.value = data.use_template.hope;
formData.type = key formData.type = key;
formData.mode = data.use_template.mode formData.name = data.use_template.name;
formData.action = data.use_template.action formData.mode = data.use_template.mode;
formData.action = data.use_template.action;
if (hope.value == 'template') { if (hope.value == 'template') {
formData.template = data.use_template.template formData.template = data.use_template.template;
} else if (hope.value == 'diy') { } else if (hope.value == 'diy') {
formData.id = data.use_template.id formData.id = data.use_template.id;
} else if (hope.value == 'other') { } else if (hope.value == 'other') {
formData.page = data.use_template.page formData.page = data.use_template.page;
formData.title = data.use_template.title formData.title = data.use_template.title;
} }
} }
// //
const toDecorate = (data: any) => { const toDecorate = (data: any) => {
const query: any = { let query: any = {
back: '/site/diy/index' back: '/site/diy/index'
} };
if (data.id) { if (data.id) {
query.id = data.id query.id = data.id;
} else if (data.name) { } else if (data.name) {
query.name = data.name query.name = data.name;
} else if (data.url) { } else if (data.url) {
query.url = data.url query.url = data.url;
} }
const url = router.resolve({ let url = router.resolve({
path: '/decorate/edit', path: '/decorate/edit',
query query
}) });
window.open(url.href) window.open(url.href);
} }
// //
const toPreview = (data: any) => { const toPreview = (data: any) => {
let page = data.page let page = data.page;
if (data.url) { if (data.url) {
page = data.url page = data.url;
} else if (data.id) { } else if (data.id) {
page += '?id=' + data.id page += '?id=' + data.id;
} }
const url = router.resolve({ let url = router.resolve({
path: '/preview/wap', path: '/preview/wap',
query: { query: {
page page
} }
}) });
window.open(url.href) window.open(url.href);
} }
// //
const toDiyList = (data: any) => { const toDiyList = (data: any) => {
const url = router.resolve({ let url = router.resolve({
path: '/site/diy/list' path: '/diy/list'
}) });
window.open(url.href) window.open(url.href);
} }
// //
const refreshMyPage = () => { const refreshMyPage = () => {
getDiyList({type: formData.type}).then((res) => { getDiyList({type: formData.type}).then((res) => {
let isExist = true // let isExist = true; //
for (let i = 0; i < res.data.length; i++) { for (let i = 0; i < res.data.length; i++) {
if (formData.id == res.data[i].id) { if (formData.id == res.data[i].id) {
isExist = false isExist = false;
break break;
} }
} }
if (isExist) { if (isExist) {
formData.id = '' formData.id = '';
} }
page[formData.type].my_page = {} page[formData.type].my_page = {};
Object.assign(page[formData.type].my_page, res.data) Object.assign(page[formData.type].my_page, res.data);
}) })
} }
@ -324,40 +329,48 @@ watch(
(newValue, oldValue) => { (newValue, oldValue) => {
// //
if (newValue == 'template') { if (newValue == 'template') {
formData.id = '' //
formData.page = '' formData.id = '';
formData.action = 'decorate' formData.page = '';
formData.action = 'decorate';
formData.name = formData.type;
} else if (newValue == 'diy') { } else if (newValue == 'diy') {
formData.mode = 'diy' //
formData.template = '' formData.mode = 'diy';
formData.page = '' formData.template = '';
formData.action = 'decorate' formData.page = '';
formData.action = 'decorate';
formData.name = formData.type;
} else if (newValue == 'other') { } else if (newValue == 'other') {
formData.mode = 'other' //
formData.template = '' formData.mode = 'other';
formData.id = '' formData.template = '';
formData.id = '';
} }
} }
) )
//
watch( watch(
() => formData.template, () => formData.template,
(newValue, oldValue) => { (newValue, oldValue) => {
if (newValue) { if (newValue) {
formData.mode = page[formData.type].template[newValue].mode formData.mode = page[formData.type].template[newValue].mode;
} }
} }
) )
//
watch( watch(
() => formData.page, () => formData.page,
(newValue, oldValue) => { (newValue, oldValue) => {
if (newValue) { if (newValue) {
for (let i = 0; i < page[formData.type].other_page.length; i++) { for (let i = 0; i < page[formData.type].other_page.length; i++) {
if (page[formData.type].other_page[i].page == newValue) { if (page[formData.type].other_page[i].page == newValue) {
formData.title = page[formData.type].other_page[i].title formData.name = page[formData.type].other_page[i].name;
formData.action = page[formData.type].other_page[i].action formData.title = page[formData.type].other_page[i].title;
break formData.action = page[formData.type].other_page[i].action;
break;
} }
} }
} }
@ -370,17 +383,25 @@ const save = () => {
if (formData.template == '') { if (formData.template == '') {
ElMessage({ ElMessage({
type: 'warning', type: 'warning',
message: `${t('placeholderTemplate')}` message: `${t('placeholderTemplate')}`,
}) });
return return;
} }
} else if (hope.value == 'diy') { } else if (hope.value == 'diy') {
if (formData.id == '') { if (formData.id == '') {
ElMessage({ ElMessage({
type: 'warning', type: 'warning',
message: `${t('placeholderMyPage')}` message: `${t('placeholderMyPage')}`,
}) });
return return;
}
} else if (hope.value == 'other') {
if (formData.page == '') {
ElMessage({
type: 'warning',
message: `${t('placeholderOtherPage')}`,
});
return;
} }
} }
@ -390,10 +411,11 @@ const save = () => {
changeTemplate({ changeTemplate({
...formData ...formData
}).then((res) => { }).then((res) => {
isRepeat.value = false isRepeat.value = false;
showDialog.value = false showDialog.value = false;
refreshData() refreshData();
}) })
} }
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="main-container w-[375px] mx-auto mt-[20px] mb-[40px] relative"> <div class="main-container w-[375px] mx-auto mt-[20px] mb-[40px] relative">
<div class="flex h-full"> <div class="flex full-container">
<iframe v-show="loadingIframe" class="w-[375px]" :src="wapPreview" frameborder="0" <iframe v-show="loadingIframe" class="w-[375px]" :src="wapPreview" frameborder="0"
id="previewIframe"></iframe> id="previewIframe"></iframe>
<div v-show="loadingDev" class="w-[375px] border border-slate-100 bg-body pt-[20px] px-[20px]"> <div v-show="loadingDev" class="w-[375px] border border-slate-100 bg-body pt-[20px] px-[20px]">
@ -121,6 +121,7 @@
const setDomain = () => { const setDomain = () => {
if (route.query.page) { if (route.query.page) {
wapPreview.value = `${wapUrl.value}${route.query.page}`; wapPreview.value = `${wapUrl.value}${route.query.page}`;
console.log(wapPreview.value)
// errorCorrectionLevelLH() // errorCorrectionLevelLH()
QRCode.toDataURL(wapPreview.value, {errorCorrectionLevel: 'L', margin: 0, width: 100}).then(url => { QRCode.toDataURL(wapPreview.value, {errorCorrectionLevel: 'L', margin: 0, width: 100}).then(url => {
wapImage.value = url wapImage.value = url

View File

@ -294,7 +294,7 @@
</div> </div>
</div> </div>
<div v-show="installStep == 2" class="h-[50vh] mt-[20px]"> <div v-show="installStep == 2" class="h-[50vh] mt-[20px]">
<terminal name="my-terminal" :context="currAddon" :init-log="null" :show-header="false" <terminal :name="currAddon" :context="currAddon" :init-log="null" :show-header="false"
:show-log-time="true" /> :show-log-time="true" />
</div> </div>
<div v-show="installStep == 3" class="h-[50vh] mt-[20px] flex flex-col"> <div v-show="installStep == 3" class="h-[50vh] mt-[20px] flex flex-col">
@ -635,8 +635,8 @@ const handleCloudInstall = () => {
cloudInstallAddon({ addon: currAddon.value }).then(res => { cloudInstallAddon({ addon: currAddon.value }).then(res => {
installStep.value = 2 installStep.value = 2
terminalApi.execute('my-terminal', 'clear') terminalApi.execute(currAddon.value, 'clear')
terminalApi.pushMessage('my-terminal', { content: '开始安装插件', class: 'info' }) terminalApi.pushMessage(currAddon.value, { content: '开始安装插件', class: 'info' })
getInstallTask() getInstallTask()
cloudInstalling.value = false cloudInstalling.value = false
}).catch((res) => { }).catch((res) => {
@ -670,11 +670,11 @@ const getCloudInstallLog = () => {
if (data[0] && data[0].length && installShowDialog.value == true) { if (data[0] && data[0].length && installShowDialog.value == true) {
data[0].forEach(item => { data[0].forEach(item => {
if (!installLog.includes(item.action)) { if (!installLog.includes(item.action)) {
terminalApi.pushMessage('my-terminal', { content: `正在执行:${item.action}` }) terminalApi.pushMessage(currAddon.value, { content: `正在执行:${item.action}` })
installLog.push(item.action) installLog.push(item.action)
if (item.code == 0) { if (item.code == 0) {
terminalApi.pushMessage('my-terminal', { content: item.msg, class: 'error' }) terminalApi.pushMessage(currAddon.value, { content: item.msg, class: 'error' })
} }
} }
}) })

View File

@ -7,8 +7,18 @@
</div> </div>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<el-dropdown-item @click="toSiteLink">切换站点</el-dropdown-item> <el-dropdown-item @click="toSiteLink">
<el-dropdown-item command="logout">退出登录</el-dropdown-item> <div class="flex items-center leading-[1] py-[5px]">
<span class="iconfont iconqiehuan ml-[4px] !text-[14px] mr-[10px]"></span>
<span class="text-[14px]">切换站点</span>
</div>
</el-dropdown-item>
<el-dropdown-item command="logout">
<div class="flex items-center leading-[1] py-[2px]">
<span class="iconfont icontuichudenglu !text-[21px] mr-[8px]"></span>
<span class="text-[14px]">退出登录</span>
</div>
</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
@ -35,4 +45,8 @@ const toSiteLink = ()=>{
} }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped>
.el-popper .el-dropdown-menu{
width: 150px;
}
</style>

View File

@ -1,8 +1,8 @@
@font-face { @font-face {
font-family: "iconfont"; /* Project id 3883393 */ font-family: "iconfont"; /* Project id 3883393 */
src: url('//at.alicdn.com/t/c/font_3883393_ppfj41ck5w.woff2?t=1699092341669') format('woff2'), src: url('//at.alicdn.com/t/c/font_3883393_46xoryy5l7v.woff2?t=1701067532618') format('woff2'),
url('//at.alicdn.com/t/c/font_3883393_ppfj41ck5w.woff?t=1699092341669') format('woff'), url('//at.alicdn.com/t/c/font_3883393_46xoryy5l7v.woff?t=1701067532618') format('woff'),
url('//at.alicdn.com/t/c/font_3883393_ppfj41ck5w.ttf?t=1699092341669') format('truetype'); url('//at.alicdn.com/t/c/font_3883393_46xoryy5l7v.ttf?t=1701067532618') format('truetype');
} }
.iconfont { .iconfont {
@ -13,6 +13,26 @@
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
.icontuichudenglu:before {
content: "\e64a";
}
.iconhuojian:before {
content: "\e6ff";
}
.iconicon_huojian1:before {
content: "\e6fe";
}
.iconrili1:before {
content: "\e62e";
}
.iconrili:before {
content: "\e664";
}
.iconshouquanliebiao:before { .iconshouquanliebiao:before {
content: "\e6fd"; content: "\e6fd";
} }

View File

@ -144,7 +144,10 @@ class Addon extends BaseAdminController
* @return Response * @return Response
*/ */
public function download($addon){ public function download($addon){
(new AddonService())->download($addon); $data = $this->request->params([
['version', '']
]);
(new AddonService())->download($addon, $data['version']);
return success('DOWNLOAD_SUCCESS'); return success('DOWNLOAD_SUCCESS');
} }

View File

@ -203,8 +203,12 @@ class Diy extends BaseAdminController
$data = $this->request->params([ $data = $this->request->params([
[ "id", "" ], [ "id", "" ],
[ 'type', '' ], // 页面类型 [ 'type', '' ], // 页面类型
['mode', ''], // 页面展示模式diy自定义fixed固定 [ 'name', '' ], // 页面名称标识
['template', ''] // 模板名称 [ 'mode', '' ], // 页面展示模式diy自定义fixed固定other其他页面
[ 'template', '' ], // 模板名称
[ 'page', '' ], // 页面路由
[ 'title', '' ], // 页面标题
[ 'action', '' ] // 是否存在操作decorate 表示支持装修
]); ]);
return success(( new DiyService() )->changeTemplate($data)); return success(( new DiyService() )->changeTemplate($data));
} }
@ -221,5 +225,4 @@ class Diy extends BaseAdminController
$res = (new DiyService())->getPreviewData($data); $res = (new DiyService())->getPreviewData($data);
return success($res); return success($res);
} }
} }

View File

@ -166,8 +166,8 @@ class AddonService extends BaseAdminService
* @param string $app_key * @param string $app_key
* @return true * @return true
*/ */
public function download(string $app_key){ public function download(string $app_key, string $version){
return (new CoreAddonDownloadService())->download($app_key); return (new CoreAddonDownloadService())->download($app_key, $version);
} }
/** /**

View File

@ -43,4 +43,24 @@ class DiyConfigService extends BaseAdminService
return (new CoreDiyConfigService())->setBottomConfig($this->site_id, $data); return (new CoreDiyConfigService())->setBottomConfig($this->site_id, $data);
} }
/**
* 设置启动页
* @param $data
* @return SysConfig|bool|Model
*/
public function setStartUpPageConfig($data)
{
return ( new CoreDiyConfigService() )->setStartUpPageConfig($this->site_id, $data);
}
/**
* 获取启动页配置
* @param $name
* @return array
*/
public function getStartUpPageConfig($name)
{
return ( new CoreDiyConfigService() )->getStartUpPageConfig($this->site_id, $name);
}
} }

View File

@ -62,10 +62,10 @@ class DiyService extends BaseAdminService
* @throws DbException * @throws DbException
* @throws ModelNotFoundException * @throws ModelNotFoundException
*/ */
public function getList(array $where = [], $field = 'id,site_id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time') public function getList(array $where = [], $field = 'id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time')
{ {
$order = "update_time desc"; $order = "update_time desc";
return $this->model->where([ [ [ 'site_id', '=', $this->site_id ] ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->select()->order($order)->toArray(); return $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->select()->order($order)->toArray();
} }
/** /**
@ -400,14 +400,30 @@ class DiyService extends BaseAdminService
{ {
// 查询可装修的页面 // 查询可装修的页面
$template = $this->getTemplate([ 'action' => 'decorate' ]); $template = $this->getTemplate([ 'action' => 'decorate', 'type' => [ 'DIY_INDEX', 'DIY_MEMBER_INDEX' ] ]);
$specific_page = array_column($template, 'page');
// 查询其他页面,排除特定页面
$other_page = ( new DiyRouteService() )->getList();
foreach ($other_page as $ck => $cv) {
if (in_array(substr($cv[ 'page' ], 1), $specific_page) || $cv[ 'is_share' ] == 0) {
unset($other_page[ $ck ]);
}
}
$other_page = array_values($other_page);
$diy_config_service = new DiyConfigService();
// 遍历查询页面数据,使用了那套模板 // 遍历查询页面数据,使用了那套模板
foreach ($template as $k => $v) { foreach ($template as $k => $v) {
$template[ $k ][ 'domain_url' ] = ( new SystemService() )->getUrl();
// 查询我的微页面 // 查询我的微页面
$template[ $k ][ 'my_page' ] = $this->getList([ 'type' => $k ], 'id,title,name,template,type,is_default,mode'); $template[ $k ][ 'my_page' ] = $this->getList([ 'type' => $k ], 'id,title,name,template,type,is_default,mode');
$template[ $k ][ 'domain_url' ] = ( new SystemService() )->getUrl();
// 查询其他页面,排除特定页面
$template[ $k ][ 'other_page' ] = $other_page;
// 查询默认页面数据 // 查询默认页面数据
$default_page_data = $this->getFirstPageData($k); $default_page_data = $this->getFirstPageData($k);
@ -421,14 +437,45 @@ class DiyService extends BaseAdminService
'desc' => $default_page_data[ 'desc' ], // 模板描述 'desc' => $default_page_data[ 'desc' ], // 模板描述
'mode' => $default_page_data[ 'mode' ], // 页面模式diy自定义fixed固定 'mode' => $default_page_data[ 'mode' ], // 页面模式diy自定义fixed固定
'hope' => 'template', // 默认选中 模板 'hope' => 'template', // 默认选中 模板
'url' => '' // 自定义页面链接,实时预览效果 'url' => '', // 自定义页面链接,实时预览效果
'page' => $v[ 'page' ], // 页面地址
'action' => '' // 是否存在操作decorate 表示支持装修
]; ];
// 查询启动页配置
$start_up_page = $diy_config_service->getStartUpPageConfig($k);
if (!empty($start_up_page)) {
$use_template[ 'name' ] = $k;
if ($start_up_page[ 'mode' ] == 'other') {
if (empty($start_up_page[ 'name' ])) {
// 查询页面的名称标识
foreach ($other_page as $ck => $cv) {
if ($cv[ 'page' ] == $start_up_page[ 'page' ]) {
$use_template[ 'name' ] = $cv['name'];
break;
}
}
}
}
$use_template[ 'hope' ] = $start_up_page[ 'mode' ];
$use_template[ 'mode' ] = $start_up_page[ 'mode' ];
$use_template[ 'page' ] = $start_up_page[ 'page' ];
$use_template[ 'action' ] = $start_up_page[ 'action' ] ?? '';
if ($use_template[ 'hope' ] == 'other') {
// 其他页面没有预览图
$use_template[ 'url' ] = $use_template[ 'page' ];
$use_template[ 'cover' ] = ''; // 默认图
$use_template[ 'template' ] = '';
$use_template[ 'desc' ] = '将 ' . $start_up_page[ 'title' ] . ' 设为首页';
}
} else {
// 查询页面数据 // 查询页面数据
$info = $this->getInfoByName($k); $info = $this->getInfoByName($k);
if (!empty($info)) { if (!empty($info)) {
$use_template[ 'id' ] = $info[ 'id' ]; $use_template[ 'id' ] = $info[ 'id' ];
$use_template[ 'name' ] = $info[ 'name' ];
$use_template[ 'title' ] = $info[ 'title' ]; $use_template[ 'title' ] = $info[ 'title' ];
$use_template[ 'template' ] = $info[ 'template' ]; $use_template[ 'template' ] = $info[ 'template' ];
$use_template[ 'mode' ] = $info[ 'mode' ]; $use_template[ 'mode' ] = $info[ 'mode' ];
@ -445,6 +492,9 @@ class DiyService extends BaseAdminService
} else { } else {
$use_template[ 'cover' ] = $page_data[ 'cover' ]; // 默认图 $use_template[ 'cover' ] = $page_data[ 'cover' ]; // 默认图
$use_template[ 'desc' ] = $page_data[ 'desc' ]; $use_template[ 'desc' ] = $page_data[ 'desc' ];
if (empty($page_data[ 'cover' ])) {
$use_template[ 'url' ] = $v[ 'page' ] . '?id=' . $info[ 'id' ];
}
} }
} else { } else {
// 自定义页面,实时预览效果 // 自定义页面,实时预览效果
@ -456,20 +506,23 @@ class DiyService extends BaseAdminService
$use_template[ 'hope' ] = $use_template[ 'mode' ]; $use_template[ 'hope' ] = $use_template[ 'mode' ];
} }
} }
}
// 如果没有预览图,并且没有地址,则赋值
if (empty($use_template[ 'cover' ]) && empty($use_template[ 'url' ])) {
$use_template[ 'url' ] = $v[ 'page' ];
}
$template[ $k ][ 'use_template' ] = $use_template; $template[ $k ][ 'use_template' ] = $use_template;
} }
return $template; return $template;
} }
/**
* 切换模板
* @param array $params
* @return array
* @throws Exception
*/
public function changeTemplate(array $params = []) public function changeTemplate(array $params = [])
{ {
$info = [];
if ($params[ 'mode' ] == 'diy') { if ($params[ 'mode' ] == 'diy') {
// 自定义页面 // 自定义页面
@ -481,14 +534,10 @@ class DiyService extends BaseAdminService
// 状态 变为 使用中 // 状态 变为 使用中
$this->setUse($info[ 'id' ]); $this->setUse($info[ 'id' ]);
} }
return $info;
} elseif ($params[ 'template' ]) { } elseif ($params[ 'template' ]) {
// 查询模板信息
$page_data = $this->getPageData($params[ 'type' ], $params[ 'template' ]);
// 查询表中未修改的模板数据 // 查询表中未修改的模板数据
$field = 'id'; $field = 'id,title,type';
$condition = [ $condition = [
[ 'site_id', '=', $this->site_id ], [ 'site_id', '=', $this->site_id ],
[ 'type', '=', $params[ 'type' ] ], [ 'type', '=', $params[ 'type' ] ],
@ -500,9 +549,12 @@ class DiyService extends BaseAdminService
if (!empty($info)) { if (!empty($info)) {
// 状态 变为 使用中 // 状态 变为 使用中
$this->setUse($info[ 'id' ]); $this->setUse($info[ 'id' ]);
return $info;
} else { } else {
// 新增 数据 // 新增 数据
// 查询模板信息
$page_data = $this->getPageData($params[ 'type' ], $params[ 'template' ]);
$data = [ $data = [
'title' => $page_data[ 'title' ], 'title' => $page_data[ 'title' ],
'name' => $params[ 'type' ], 'name' => $params[ 'type' ],
@ -513,10 +565,14 @@ class DiyService extends BaseAdminService
]; ];
$res = $this->add($data); $res = $this->add($data);
$this->setUse($res); $this->setUse($res);
$info = $data;
} }
} }
$page_template = TemplateDict::getTemplate([ 'type' => [ $info[ 'type' ] ] ])[ $info[ 'type' ] ];
$info[ 'page' ] = $page_template[ 'page' ];
} elseif ($params[ 'mode' ] == 'fixed') { } elseif ($params[ 'mode' ] == 'fixed') {
// 固定模板 // 固定模板
@ -524,9 +580,8 @@ class DiyService extends BaseAdminService
$page_data = $this->getPageData($params[ 'type' ], $params[ 'template' ]); $page_data = $this->getPageData($params[ 'type' ], $params[ 'template' ]);
// 检查表里是否存在数据 // 检查表里是否存在数据
$field = 'id'; $field = 'id,title,type';
$condition = [ $condition = [
[ 'site_id', '=', $this->site_id ],
[ 'type', '=', $params[ 'type' ] ], [ 'type', '=', $params[ 'type' ] ],
[ 'template', '=', $params[ 'template' ] ], [ 'template', '=', $params[ 'template' ] ],
[ 'mode', '=', $params[ 'mode' ] ] [ 'mode', '=', $params[ 'mode' ] ]
@ -547,11 +602,31 @@ class DiyService extends BaseAdminService
]; ];
$res = $this->add($data); $res = $this->add($data);
$this->setUse($res); $this->setUse($res);
$info = $data;
} }
$page_template = TemplateDict::getTemplate([ 'type' => [ $info[ 'type' ] ] ])[ $info[ 'type' ] ];
$info[ 'page' ] = $page_template[ 'page' ];
} else if ($params[ 'mode' ] == 'other') {
// 其他页面
$info[ 'title' ] = $params[ 'title' ];
$info[ 'page' ] = $params[ 'page' ];
}
// 设置启动页
$start_up_page_data = [
'type' => $params[ 'type' ], // 页面类型
'name' => $params[ 'name' ], // 页面名称标识
'mode' => $params[ 'mode' ], // 模式diy自定义页面fixed模板other其他页面
'title' => $info[ 'title' ],
'page' => $info[ 'page' ],
'action' => $params[ 'action' ]
];
$diy_config_service = new DiyConfigService();
$diy_config_service->setStartUpPageConfig($start_up_page_data);
return $info; return $info;
} }
return $params;
}
/** /**
* 获取页面预览数据 * 获取页面预览数据

View File

@ -41,21 +41,20 @@ class CoreAddonDownloadService extends CoreAddonBaseService
* @throws GuzzleException * @throws GuzzleException
* @throws GuzzleException * @throws GuzzleException
*/ */
public function download($app_key) public function download($app_key, $version)
{ {
$app_path = $this->addon_path . $app_key . '/'; $app_path = $this->addon_path . $app_key . DIRECTORY_SEPARATOR;
//先判断当前的应用在本地是否存在 //先判断当前的应用在本地是否存在
// if(is_dir($app_path)) throw new NiucloudException(); // if(is_dir($app_path)) throw new NiucloudException();
$app_download_path = $this->addon_download_path . $app_key . '/';
//下载文件到本地 //下载文件到本地
$zip_file = (new CoreModuleService())->downloadModule($app_key, $app_download_path); $zip_file = (new CoreAddonCloudService())->downloadAddon($app_key, $version);
//解压到应用addon下 //解压到应用addon下
//删除旧版本文件 //删除旧版本文件
del_target_dir($app_path, true); del_target_dir($app_path, true);
//解压文件 //解压文件
$this->unzip($zip_file, $this->addon_path); $this->unzip($zip_file, $this->addon_path);
//删除压缩包 //删除压缩包
@unlink($zip_file); @del_target_dir(dirname($zip_file), true);
return true; return true;
} }

View File

@ -79,4 +79,27 @@ class CoreDiyConfigService extends BaseCoreService
return ( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::DIY_BOTTOM, $data); return ( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::DIY_BOTTOM, $data);
} }
/**
* 设置启动页
* @param array $data
* @return SysConfig|bool|Model
*/
public function setStartUpPageConfig(int $site_id, array $data)
{
return ( new CoreConfigService() )->setConfig($site_id,'START_UP_PAGE_' . strtoupper($data[ 'type' ]), $data);
}
/**
* 获取启动页配置
* @param $name
* @return array
*/
public function getStartUpPageConfig(int $site_id, string $type)
{
$info = ( new CoreConfigService() )->getConfig($site_id, 'START_UP_PAGE_' . strtoupper($type))[ 'value' ] ?? [];
if (!empty($info)) {
$info[ 'name' ] = isset($info[ 'name' ]) ? $info[ 'name' ] : '';
}
return $info;
}
} }

View File

@ -125,6 +125,7 @@ class CoreMenuService extends BaseCoreService
foreach ($tree as $key => $value) { foreach ($tree as $key => $value) {
$item = [ $item = [
'menu_name' => $value['menu_name'], 'menu_name' => $value['menu_name'],
'menu_short_name' => $value['menu_short_name'] ?? '',
'menu_key' => $value['menu_key'], 'menu_key' => $value['menu_key'],
'app_type' => $app_type, 'app_type' => $app_type,
'addon' => $addon, 'addon' => $addon,

View File

@ -5,21 +5,21 @@
<link rel="icon" type="image" href="/admin/niucloud.ico" /> <link rel="icon" type="image" href="/admin/niucloud.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title></title> <title></title>
<script type="module" crossorigin src="/admin/assets/index-acad5537.js"></script> <script type="module" crossorigin src="/admin/assets/index-e35911a1.js"></script>
<link rel="modulepreload" crossorigin href="/admin/assets/base-9962c822.js"> <link rel="modulepreload" crossorigin href="/admin/assets/base-9962c822.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-57446bef.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-57446bef.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-5c4817f4.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-5c4817f4.js">
<link rel="modulepreload" crossorigin href="/admin/assets/pinia-a9fc3924.js"> <link rel="modulepreload" crossorigin href="/admin/assets/pinia-a9fc3924.js">
<link rel="modulepreload" crossorigin href="/admin/assets/storage-0874d153.js"> <link rel="modulepreload" crossorigin href="/admin/assets/storage-0874d153.js">
<link rel="modulepreload" crossorigin href="/admin/assets/system-1108e5c1.js"> <link rel="modulepreload" crossorigin href="/admin/assets/system-1108e5c1.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-15d712d1.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-6e46fb55.js">
<link rel="modulepreload" crossorigin href="/admin/assets/vue-router-d7e63612.js"> <link rel="modulepreload" crossorigin href="/admin/assets/vue-router-d7e63612.js">
<link rel="modulepreload" crossorigin href="/admin/assets/typescript-defaf979.js"> <link rel="modulepreload" crossorigin href="/admin/assets/typescript-defaf979.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-c98e204a.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-c98e204a.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-2cabf788.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-2cabf788.js">
<link rel="modulepreload" crossorigin href="/admin/assets/_plugin-vue_export-helper-c27b6911.js"> <link rel="modulepreload" crossorigin href="/admin/assets/_plugin-vue_export-helper-c27b6911.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-c4e33d8d.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-c4e33d8d.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-43b4f8e3.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-db1ad0a3.js">
<link rel="modulepreload" crossorigin href="/admin/assets/event-9519ab40.js"> <link rel="modulepreload" crossorigin href="/admin/assets/event-9519ab40.js">
<link rel="modulepreload" crossorigin href="/admin/assets/error-78e43d3e.js"> <link rel="modulepreload" crossorigin href="/admin/assets/error-78e43d3e.js">
<link rel="modulepreload" crossorigin href="/admin/assets/scroll-d85c8f38.js"> <link rel="modulepreload" crossorigin href="/admin/assets/scroll-d85c8f38.js">
@ -48,7 +48,7 @@
<link rel="modulepreload" crossorigin href="/admin/assets/index-6d647c6f.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-6d647c6f.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-6edd46fb.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-6edd46fb.js">
<link rel="modulepreload" crossorigin href="/admin/assets/isEqual-240b5e0a.js"> <link rel="modulepreload" crossorigin href="/admin/assets/isEqual-240b5e0a.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-8f077450.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-00b73d5a.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-189f302e.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-189f302e.js">
<link rel="modulepreload" crossorigin href="/admin/assets/strings-66191554.js"> <link rel="modulepreload" crossorigin href="/admin/assets/strings-66191554.js">
<link rel="modulepreload" crossorigin href="/admin/assets/index-da093955.js"> <link rel="modulepreload" crossorigin href="/admin/assets/index-da093955.js">
@ -91,7 +91,7 @@
<link rel="stylesheet" href="/admin/assets/base-a43f0bed.css"> <link rel="stylesheet" href="/admin/assets/base-a43f0bed.css">
<link rel="stylesheet" href="/admin/assets/index-f5c6a819.css"> <link rel="stylesheet" href="/admin/assets/index-f5c6a819.css">
<link rel="stylesheet" href="/admin/assets/index-f5128a35.css"> <link rel="stylesheet" href="/admin/assets/index-f5128a35.css">
<link rel="stylesheet" href="/admin/assets/index-7accde1d.css"> <link rel="stylesheet" href="/admin/assets/index-4ddae479.css">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>