Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-cli into dev

This commit is contained in:
Xu Chang 2023-12-01 22:40:53 +08:00
commit 9f905f5f4e
6 changed files with 55 additions and 34 deletions

View File

@ -32,7 +32,7 @@ module.exports = (babel) => {
ele => t.isObjectProperty(ele) && t.isIdentifier(ele.key) && ele.key.name === 'path'
);
if (pathProperty) {
console.warn(`${rel}页面的OakPage中还是定义了path可以删除掉了`);
console.warn(`${resolvePath}页面的OakPage中还是定义了path可以删除掉了`);
pathProperty.value = t.stringLiteral(relativePath);
}
else {

View File

@ -137,14 +137,29 @@ function transformCode(text, namespace, moduleName) {
const { node } = path;
if (t.isIdentifier(node.callee) && node.callee.name === 't') {
const { arguments } = node;
// 在t的后面加五个参数oakLocales, oakLng, oakDefaultLng, oakNamespace, oakModule
arguments.push(
t.identifier('oakLocales'),
t.identifier('oakLng'),
t.identifier('oakDefaultLng'),
t.stringLiteral(namespace),
t.stringLiteral(moduleName)
);
// 在t的后面加五个参数oakLocales, oakLng, oakDefaultLng, oakNamespace,
// 增强能力如果t后面的第二个参数是字符串说明想指定oakNamespace在一些抽象模块中会有此需求
if (arguments[1] && t.isStringLiteral(arguments[1])) {
arguments.splice(
1,
0,
t.identifier('oakLocales'),
t.identifier('oakLng'),
t.identifier('oakDefaultLng')
);
arguments.push(
t.stringLiteral(moduleName)
);
}
else {
arguments.push(
t.identifier('oakLocales'),
t.identifier('oakLng'),
t.identifier('oakDefaultLng'),
t.stringLiteral(namespace),
t.stringLiteral(moduleName)
);
}
node.callee = t.memberExpression(
t.identifier('i18n'),
t.identifier('t')
@ -253,7 +268,8 @@ module.exports = async function (content) {
x.indexOf('missed quot(")!') === -1 &&
x.indexOf('unclosed xml attribute') == -1
) {
console.log(x);
console.warn(`${filePath}文件出现警告:${x}`);
}
},
},
@ -309,7 +325,7 @@ module.exports = async function (content) {
const wxIfNode = node.ownerDocument.createElement('block');
wxIfNode.setAttribute('wx:if', '{{oakFullpath}}');
wxIfNode.setAttribute('oakInjected', 'true');
node.parentNode.replaceChild(wxIfNode, node);
wxIfNode.appendChild(node);
}

View File

@ -21,6 +21,7 @@ const nullthrows = require("nullthrows");
const replaceEnvExpressionPlugin = require('./babelEnvPlugin');
const { injectGetRender } = require('../utils/injectGetRender');
const oakPathTsxPlugin = require('../babel-plugin/oakPath');
async function renderToCSS({ src, filename, options = {} }) {
const { lessOptions = {} } = options;
@ -50,7 +51,7 @@ function transform({ filename, options, plugins, src }) {
cwd: options.projectRoot,
highlightCode: true,
filename,
plugins: plugins.concat(replaceEnvExpressionPlugin),
plugins: plugins.concat([replaceEnvExpressionPlugin, oakPathTsxPlugin]),
sourceType: "module",
// NOTE(EvanBacon): We split the parse/transform steps up to accommodate
// Hermes parsing, but this defaults to cloning the AST which increases

View File

@ -27,7 +27,7 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
allowedHeaders: ["oak-cxt"],
};
const io = new socket_io_1.Server(httpServer, socketOption);
if (process.env.PM2_STATUS) {
if (process.env.pm_id || process.env.PM_ID) {
// pm2环境下要接入clusterAdapter
// https://socket.io/zh-CN/docs/v4/pm2/
io.adapter((0, cluster_adapter_1.createAdapter)());
@ -148,5 +148,9 @@ async function startup(path, contextBuilder, connector, omitWatchers, omitTimers
if (!omitTimers) {
appLoader.startTimers();
}
process.on('SIGINT', async () => {
await appLoader.unmount();
process.exit(0);
});
}
exports.startup = startup;

View File

@ -35,7 +35,7 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
allowedHeaders: ["oak-cxt"],
};
const io = new Server(httpServer, socketOption);
if (process.env.PM2_STATUS) {
if (process.env.pm_id || process.env.PM_ID) {
// pm2环境下要接入clusterAdapter
// https://socket.io/zh-CN/docs/v4/pm2/
io.adapter(createAdapter());
@ -170,4 +170,9 @@ export async function startup<ED extends EntityDict & BaseEntityDict, Cxt extend
if (!omitTimers) {
appLoader.startTimers();
}
process.on('SIGINT', async () => {
await appLoader.unmount();
process.exit(0);
});
}

View File

@ -1,24 +1,19 @@
/** app.wxss **/
@font-face {
font-family: "Material Symbols Rounded";
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/sandbox/materialsymbolsrounded/v7/syl0-zNym6YjUruM-QrEh7-nyTnjDwKNJ_190FjpZIvDmUSVOK7BDB_Qb9vUSzq3wzLK-P0J-V_Zs-QtQth3-jOc7TOVpeRL2w5rwZu2rIelXxc.woff2) format("woff2");
}
page {
height: 100%;
width: 100%;
.material-symbols-rounded {
font-family: "Material Symbols Rounded";
font-weight: normal;
font-style: normal;
font-size: 44rpx;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
font-feature-settings: "liga";
-webkit-font-smoothing: antialiased;
--oak-color-primary: #0052d9;
--oak-color-error: #e34d59;
--oak-color-warning: #db7b2f;
--oak-color-success: #00a870;
--oak-color-info: #d4e3fc;
--oak-bg-color-page: #eee;
--oak-bg-color-container: #fff;
--oak-bg-color-component: #e7e7e7;
--oak-text-color-primary: rgb(0 0 0 / 90%);
--oak-text-color-secondary: rgb(0 0 0 / 60%);
--oak-text-color-placeholder: rgb(0 0 0 / 40%);
--oak-text-color-disabled: rgb(0 0 0 / 26%);
}