create时的细节修正,模板中web/namespace/console的修改
This commit is contained in:
parent
feb268dc67
commit
6a6b57d382
|
|
@ -232,7 +232,7 @@ async function create(dirName, cmd) {
|
||||||
}
|
}
|
||||||
// 获取package.json内容
|
// 获取package.json内容
|
||||||
const packageJson = (0, template_1.packageJsonContent)({
|
const packageJson = (0, template_1.packageJsonContent)({
|
||||||
name: DEFAULT_PROJECT_NAME, // 后面再统一rename
|
name: DEFAULT_PROJECT_NAME,
|
||||||
version,
|
version,
|
||||||
description,
|
description,
|
||||||
cliName: config_1.CLI_NAME,
|
cliName: config_1.CLI_NAME,
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ const path_1 = require("path");
|
||||||
*/
|
*/
|
||||||
function getPackageLatestVersion(name) {
|
function getPackageLatestVersion(name) {
|
||||||
const result = (0, child_process_1.execSync)(`npm info ${name}`).toString('utf-8');
|
const result = (0, child_process_1.execSync)(`npm info ${name}`).toString('utf-8');
|
||||||
const data = result.match(/latest: \d\.\d\.\d\s*published/g);
|
const data = result.match(/latest: \d+\.\d+\.\d+\s*published/g);
|
||||||
return data[0].slice(8, 13);
|
const versionStr = data[0];
|
||||||
|
const version = versionStr.slice(8, versionStr.indexOf('published')).replace(/[^0-9.]/g, '');
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, isModule, dependencies }) {
|
function packageJsonContent({ name, version, description, cliName, cliBinName, isDev, isModule, dependencies }) {
|
||||||
let oakDependencyStr = '';
|
let oakDependencyStr = '';
|
||||||
|
|
@ -37,15 +39,15 @@ function packageJsonContent({ name, version, description, cliName, cliBinName, i
|
||||||
else {
|
else {
|
||||||
// todo,这里从npmjs.org上获取最新版本
|
// todo,这里从npmjs.org上获取最新版本
|
||||||
oakDependencyStr = `
|
oakDependencyStr = `
|
||||||
"oak-domain": "^${getPackageLatestVersion('oak-domain')}",
|
"oak-domain": "~${getPackageLatestVersion('oak-domain')}",
|
||||||
"oak-external-sdk": "^${getPackageLatestVersion('oak-external-sdk')}",
|
"oak-external-sdk": "~${getPackageLatestVersion('oak-external-sdk')}",
|
||||||
"oak-frontend-base": "^${getPackageLatestVersion('oak-frontend-base')}",`;
|
"oak-frontend-base": "~${getPackageLatestVersion('oak-frontend-base')}",`;
|
||||||
if (dependencies?.length) {
|
if (dependencies?.length) {
|
||||||
dependencies?.forEach((dep) => {
|
dependencies?.forEach((dep) => {
|
||||||
oakDependencyStr += `\n"${dep}": "^${getPackageLatestVersion(dep)}"`;
|
oakDependencyStr += `\n"${dep}": "~${getPackageLatestVersion(dep)}",`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
oakDevDependencyStr = `"${cliName}": "^${getPackageLatestVersion(cliName)}",`;
|
oakDevDependencyStr = `"${cliName}": "~${getPackageLatestVersion(cliName)}",`;
|
||||||
}
|
}
|
||||||
const serverInitScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/initServer.js" : "cross-env OAK_PLATFORM=server node scripts/initServer.js";
|
const serverInitScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/initServer.js" : "cross-env OAK_PLATFORM=server node scripts/initServer.js";
|
||||||
const serverStartScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/startServer.js" : "cross-env OAK_PLATFORM=server node scripts/startServer.js";
|
const serverStartScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/startServer.js" : "cross-env OAK_PLATFORM=server node scripts/startServer.js";
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,11 @@ import { PackageJsonInput } from './interface';
|
||||||
*/
|
*/
|
||||||
function getPackageLatestVersion(name: string) {
|
function getPackageLatestVersion(name: string) {
|
||||||
const result = execSync(`npm info ${name}`).toString('utf-8');
|
const result = execSync(`npm info ${name}`).toString('utf-8');
|
||||||
const data = result.match(/latest: \d\.\d\.\d\s*published/g);
|
const data = result.match(/latest: \d+\.\d+\.\d+\s*published/g);
|
||||||
return data![0].slice(8, 13);
|
const versionStr = data![0];
|
||||||
|
const version = versionStr.slice(8, versionStr.indexOf('published')).replace(/[^0-9.]/g, '');
|
||||||
|
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -50,17 +53,17 @@ export function packageJsonContent({
|
||||||
else {
|
else {
|
||||||
// todo,这里从npmjs.org上获取最新版本
|
// todo,这里从npmjs.org上获取最新版本
|
||||||
oakDependencyStr = `
|
oakDependencyStr = `
|
||||||
"oak-domain": "^${getPackageLatestVersion('oak-domain')}",
|
"oak-domain": "~${getPackageLatestVersion('oak-domain')}",
|
||||||
"oak-external-sdk": "^${getPackageLatestVersion('oak-external-sdk')}",
|
"oak-external-sdk": "~${getPackageLatestVersion('oak-external-sdk')}",
|
||||||
"oak-frontend-base": "^${getPackageLatestVersion('oak-frontend-base')}",`;
|
"oak-frontend-base": "~${getPackageLatestVersion('oak-frontend-base')}",`;
|
||||||
if (dependencies?.length) {
|
if (dependencies?.length) {
|
||||||
dependencies?.forEach(
|
dependencies?.forEach(
|
||||||
(dep) => {
|
(dep) => {
|
||||||
oakDependencyStr += `\n"${dep}": "^${getPackageLatestVersion(dep)}"`;
|
oakDependencyStr += `\n"${dep}": "~${getPackageLatestVersion(dep)}",`;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
oakDevDependencyStr = `"${cliName}": "^${getPackageLatestVersion(cliName)}",`
|
oakDevDependencyStr = `"${cliName}": "~${getPackageLatestVersion(cliName)}",`
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverInitScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/initServer.js" : "cross-env OAK_PLATFORM=server node scripts/initServer.js";
|
const serverInitScript = isDev ? "cross-env NODE_ENV=development cross-env OAK_PLATFORM=server node scripts/initServer.js" : "cross-env OAK_PLATFORM=server node scripts/initServer.js";
|
||||||
|
|
@ -70,11 +73,10 @@ export function packageJsonContent({
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"description": "${description}",
|
"description": "${description}",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"make:domain": "${
|
"make:domain": "${isModule
|
||||||
isModule
|
? `cross-env COMPLING_AS_LIB=yes ${cliBinName}`
|
||||||
? `cross-env COMPLING_AS_LIB=yes ${cliBinName}`
|
: cliBinName
|
||||||
: cliBinName
|
} make:domain",
|
||||||
} make:domain",
|
|
||||||
"make:locale": "${cliBinName} make:locale ${isModule ? '-m' : ''}",
|
"make:locale": "${cliBinName} make:locale ${isModule ? '-m' : ''}",
|
||||||
"make:dep": "${cliBinName} make:dependency",
|
"make:dep": "${cliBinName} make:dependency",
|
||||||
"clean:cache": "rimraf node_modules/.cache",
|
"clean:cache": "rimraf node_modules/.cache",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
.footer {
|
||||||
|
background: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
/** 文本1 */
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 400;
|
||||||
|
letter-spacing: 0px;
|
||||||
|
line-height: 16.8px;
|
||||||
|
color: rgba(165, 192, 203, 1);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { Layout } from 'antd';
|
||||||
|
import Style from './index.module.less';
|
||||||
|
|
||||||
|
const { Footer } = Layout;
|
||||||
|
|
||||||
|
export default function Render() {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Footer className={Style.footer}>
|
||||||
|
<div className={Style.panel}>
|
||||||
|
<span>
|
||||||
|
Copyright © {new Date().getFullYear()}{' '}
|
||||||
|
浙江大学计算机创新技术研究院
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</Footer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"copyright": "Oak Team & INSTITUTE OF COMPUTING INNOVATION, ZHEJIANG UNIVERSITY"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
.mixPanel {
|
||||||
|
height: 100% !important;
|
||||||
|
background: var(--oak-bg-color-page) !important;
|
||||||
|
min-height: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mixMain {
|
||||||
|
background: unset !important;
|
||||||
|
flex-direction: row !important;
|
||||||
|
flex: 1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mixLayout {
|
||||||
|
background: unset !important;
|
||||||
|
overflow: auto !important;
|
||||||
|
min-height: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mixContent {
|
||||||
|
background: unset !important;
|
||||||
|
min-height: unset !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loadingBox {
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
@ -1,69 +1,121 @@
|
||||||
|
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Routes, Route, Outlet, useLocation } from 'react-router-dom';
|
import { Outlet, useLocation } from 'react-router-dom';
|
||||||
|
import { Layout, Spin, Result, Button } from 'antd';
|
||||||
|
import Styles from './index.pc.module.less';
|
||||||
import Header from '../../components/header';
|
import Header from '../../components/header';
|
||||||
import Styles from './web.pc.module.less';
|
import Footer from '../../components/footer';
|
||||||
|
import Login from 'oak-general-business/es/components/user/login';
|
||||||
import useFeatures from '@project/hooks/useFeatures';
|
import useFeatures from '@project/hooks/useFeatures';
|
||||||
// import Menu from '@project/components/console/menu';
|
// import Menu from '@project/components/menu';
|
||||||
import { useWidth } from 'oak-frontend-base/es/platforms/web';
|
|
||||||
|
import {
|
||||||
|
OakTokenExpiredException,
|
||||||
|
OakUserInfoLoadingException,
|
||||||
|
} from 'oak-general-business';
|
||||||
|
|
||||||
|
import { OakUnloggedInException } from 'oak-domain/lib/types/Exception';
|
||||||
|
|
||||||
|
const { Content } = Layout;
|
||||||
|
|
||||||
|
type Status = 'waiting' | 'success' | 'fail';
|
||||||
|
|
||||||
function Console(props: { namespace: string }) {
|
function Console(props: { namespace: string }) {
|
||||||
const { namespace } = props;
|
const { namespace } = props;
|
||||||
const features = useFeatures();
|
const features = useFeatures();
|
||||||
const [currentMenuPath, setCmp] = useState('');
|
features.navigator.setNamespace(namespace);
|
||||||
|
|
||||||
const width = useWidth();
|
const [userId, setUserId] = useState('');
|
||||||
const location = useLocation();
|
const [status, setStatus] = useState<Status>('waiting');
|
||||||
const { pathname } = location;
|
|
||||||
const path = pathname.slice(namespace.length);
|
const init = async () => {
|
||||||
const showBack = currentMenuPath && currentMenuPath !== path;
|
try {
|
||||||
const isRoot = features.token.isRoot();
|
const id = features.token.getUserId(true);
|
||||||
// const mode = features.console.getMode(true);
|
if (id) {
|
||||||
const [mode, setMode] = useState(features.console.getMode(true));
|
setUserId(id);
|
||||||
|
} else {
|
||||||
|
setUserId('');
|
||||||
|
}
|
||||||
|
setStatus('success');
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof OakUserInfoLoadingException) {
|
||||||
|
setStatus('waiting');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setStatus('fail');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
features.navigator.setNamespace(namespace);
|
init();
|
||||||
features.console.initialize();
|
const unsub1 = features.token.subscribe(() => {
|
||||||
const location = window.location;
|
init();
|
||||||
const { pathname } = location;
|
});
|
||||||
const path2 = pathname.slice(namespace.length);
|
const unsub2 = features.locales.subscribe(() => {
|
||||||
setCmp(path2);
|
init();
|
||||||
const unModeSubscribe = features.console.subscribe(
|
});
|
||||||
() => {
|
|
||||||
const newMode = features.console.getMode();
|
|
||||||
setMode(newMode);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return () => {
|
return () => {
|
||||||
unModeSubscribe();
|
unsub1();
|
||||||
features.console.destroy();
|
unsub2();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// const showOpenStoreBtn = !isRoot && !mode && pathname === '/console';
|
const location = useLocation();
|
||||||
const [showOpenStore, setShowOpenStore] = useState(true);
|
const { pathname } = location;
|
||||||
useEffect(() => {
|
const isRoot = features.token.isRoot();
|
||||||
if (mode || isRoot) {
|
|
||||||
setShowOpenStore(false);
|
if (status === 'waiting') {
|
||||||
} else {
|
return (
|
||||||
setShowOpenStore(true);
|
<div className={Styles.loadingBox}>
|
||||||
}
|
<Spin tip="Loading" />
|
||||||
}, [mode, isRoot])
|
|
||||||
return (
|
|
||||||
<div className={Styles.container}>
|
|
||||||
<div className={Styles.header}>
|
|
||||||
<Header />
|
|
||||||
</div>
|
</div>
|
||||||
<div className={Styles.body}>
|
);
|
||||||
{/* <Menu
|
}
|
||||||
pathname={path}
|
|
||||||
onPathClicked={(path) => setCmp(path)}
|
if (status === 'fail') {
|
||||||
/> */}
|
return (
|
||||||
<div className={Styles.content}>
|
<Layout className={Styles.mixPanel}>
|
||||||
<Outlet />
|
<div className={Styles.login}>
|
||||||
|
<Result
|
||||||
|
status="error"
|
||||||
|
title={features.locales.t('errorInLoading')}
|
||||||
|
extra={[
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
window.location.reload();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{features.locales.t('reload')}
|
||||||
|
</Button>,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userId) {
|
||||||
|
return (
|
||||||
|
<Layout className={Styles.mixPanel}>
|
||||||
|
<Header />
|
||||||
|
<Layout className={Styles.mixMain}>
|
||||||
|
{/* <Menu /> */}
|
||||||
|
<Layout className={Styles.mixLayout}>
|
||||||
|
<Content className={Styles.mixContent}>
|
||||||
|
<Outlet />
|
||||||
|
</Content>
|
||||||
|
<Footer />
|
||||||
|
</Layout>
|
||||||
|
</Layout>
|
||||||
|
</Layout>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Layout className={Styles.mixPanel}>
|
||||||
|
<div className={Styles.login}>
|
||||||
|
<Login />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Layout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"errorInLoading": "抱歉,页面加载出现错误!请稍后再试。",
|
||||||
|
"reload": "重新加载"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue