Skip to content

Commit

Permalink
fix: clear store (#405)
Browse files Browse the repository at this point in the history
* fix: clear store

* mod: code review
  • Loading branch information
hetao92 committed Dec 22, 2022
1 parent 369d498 commit 38ca762
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 41 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% if (initProps.dev) { %>
window.gConfig = { maxBytes: <%= JSON.stringify(initProps.maxBytes) %> }
<% } else { %>
window.gConfig = { maxBytes: { {.maxBytes } } }
window.gConfig = { maxBytes: {{.maxBytes}} }
<% } %>
</script>
<style>
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/FileUpload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const FileUpload = () => {
const [loading, setLoading] = useState(false);
const transformFile = async (_file: StudioFile, fileList: StudioFile[]) => {
const size = fileList.reduce((acc, cur) => acc + cur.size, 0);
if(size > global.gConfig.maxBytes) {
if(global.gConfig?.maxBytes && size > global.gConfig.maxBytes) {
message.error(intl.get('import.fileSizeLimit', { size: getFileSize(global.gConfig.maxBytes) }));
return false;
}
Expand Down
11 changes: 6 additions & 5 deletions app/stores/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ export class ConsoleStore {
}

resetModel = () => {
this.update({
currentGQL: 'SHOW SPACES;',
results: [],
paramsMap: null
});
const shadowStore = new ConsoleStore();
for (const key in shadowStore) {
if (typeof shadowStore[key] !== 'function') {
this[key] = shadowStore[key];
}
}
};

update = (param: Partial<ConsoleStore>) => {
Expand Down
9 changes: 9 additions & 0 deletions app/stores/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ export class FilesStore {
Object.keys(payload).forEach(key => Object.prototype.hasOwnProperty.call(this, key) && (this[key] = payload[key]));
};

resetModel = () => {
const shadowStore = new FilesStore();
for (const key in shadowStore) {
if (typeof shadowStore[key] !== 'function') {
this[key] = shadowStore[key];
}
}
};

getFiles = async () => {
const { code, data } = (await service.getFiles()) as any;
if (code === 0 && data) {
Expand Down
9 changes: 8 additions & 1 deletion app/stores/sketchModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ export class SketchStore {
sketchList: observable.deep,
});
}

resetModel = () => {
const shadowStore = new SketchStore();
for (const key in shadowStore) {
if (typeof shadowStore[key] !== 'function') {
this[key] = shadowStore[key];
}
}
};
update = (payload: Record<string, any>) => {
Object.keys(payload).forEach(
(key) => Object.prototype.hasOwnProperty.call(this, key) && (this[key] = payload[key])
Expand Down
10 changes: 9 additions & 1 deletion config/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const Package = require('../package.json');

const { getAppConfig } = require('./config');
const { getEnv } = require('./env');

Expand All @@ -15,6 +16,13 @@ const commonConfig = {
entry: {
app: [path.join(__dirname, '../app/index.tsx')],
},
output: {
path: path.join(__dirname, '../dist/'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[contenthash].js',
publicPath: '/',
},
mode: isDevEnv() ? 'development' : 'production',
module: {
exprContextCritical: true,
rules: [
Expand Down Expand Up @@ -127,7 +135,7 @@ const commonConfig = {
},
pageInitialProps: {
dev: isDevEnv(),
maxBytes: appConfig.MaxBytes
maxBytes: appConfig.MaxBytes || 1048576 // go-zero default value
}
}),
new AntdDayjsWebpackPlugin(),
Expand Down
49 changes: 20 additions & 29 deletions config/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const { merge } = require('webpack-merge');

const commonConfig = require('./webpack.base');
const { setEnv } = require('./env');

setEnv('production');
const publicConfig = {
mode: 'production',
output: {
path: path.join(__dirname, '../dist/'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[contenthash].js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
],
},

plugins: [
new CleanWebpackPlugin(),
const config = require('./webpack.base');
config.module.rules.push(
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
);
config.plugins.push(
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [path.resolve(__dirname, '..', 'dist')],
}),
);

new MiniCssExtractPlugin({
filename: '[name].[fullhash].css',
chunkFilename: '[id].[fullhash].css',
}),
],
};
config.plugins.push(
new MiniCssExtractPlugin({
filename: '[name].[fullhash].css',
chunkFilename: '[id].[fullhash].css',
}),
);

module.exports = merge(commonConfig, publicConfig);
module.exports = config;
4 changes: 2 additions & 2 deletions server/api/studio/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/api/studio/restapi/import.api
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type (

GetManyImportTaskRequest {
Page int `form:"page,default=1"`
PageSize int `form:"pageSize,default=100"`
PageSize int `form:"pageSize,default=999"`
}

GetManyImportTaskData {
Expand Down

0 comments on commit 38ca762

Please sign in to comment.