diff --git a/zero.Web.UI/App/editor/fields/media.vue b/zero.Web.UI/App/editor/fields/media.vue index a30d63e1..caf28ddb 100644 --- a/zero.Web.UI/App/editor/fields/media.vue +++ b/zero.Web.UI/App/editor/fields/media.vue @@ -1,5 +1,5 @@  @@ -14,7 +14,15 @@ type: Boolean, default: false }, - config: Object + limit: { + type: Number, + default: 1 + } }, + + created() + { + console.info(this); + } } \ No newline at end of file diff --git a/zero.Web.UI/vite.config.js b/zero.Web.UI/vite.config.js index 80096f82..46dc3e89 100644 --- a/zero.Web.UI/vite.config.js +++ b/zero.Web.UI/vite.config.js @@ -2,31 +2,34 @@ const path = require('path'); const fs = require('fs'); const { createVuePlugin } = require('vite-plugin-vue2'); + +let loadedPlugins = JSON.parse(process.env.ZERO_PLUGINS || "[]"); let zeroPlugins = []; -let _plugins = [ - { - path: '../zero.Commerce/Plugin/vite.plugin.js', - root: '../zero.Commerce/Plugin' - }, - { - path: '../../Laola/Laola.Backoffice/Plugin/vite.plugin.js', - root: '../../Laola/Laola.Backoffice/Plugin' - } -]; +//let _plugins = [ +// { +// path: '../zero.Commerce/Plugin/vite.plugin.js', +// root: '../zero.Commerce/Plugin' +// }, +// { +// path: '../../Laola/Laola.Backoffice/Plugin/vite.plugin.js', +// root: '../../Laola/Laola.Backoffice/Plugin' +// } +//]; let pluginFileContent = ''; let pluginAliases = {}; let pluginNames = []; let idx = 0; -_plugins.forEach(plugin => +loadedPlugins.forEach(pluginPath => { - const pluginConfig = require(plugin.path); + const viteConfigPath = pluginPath + "/vite.plugin.js"; + const pluginConfig = require(viteConfigPath); zeroPlugins.push(pluginConfig()); const name = 'zeroPlugin' + idx; const alias = '/@zeroplugin' + (idx++) + '/'; - pluginAliases[alias] = path.resolve(__dirname, plugin.root); + pluginAliases[alias] = path.resolve(__dirname, pluginPath); pluginNames.push(name); pluginFileContent += "import " + name + " from '" + alias + "plugin.js';\n"; }); @@ -43,21 +46,6 @@ fs.writeFile(path.resolve(__dirname, 'app/core/plugins.js'), pluginFileContent, //file written successfully }) -//if (process.env.ZERO_PLUGINS) -//{ -// let plugins = JSON.parse(process.env.ZERO_PLUGINS); - -// plugins.forEach(plugin => -// { -// const pluginConfig = require(plugin.path); - -// if (pluginConfig != null) -// { -// zeroPlugins.push(pluginConfig()); -// } -// }); -//} - const aliasResolver = { alias(id) { diff --git a/zero.Web/DevServer/PluginResolver.cs b/zero.Web/DevServer/PluginResolver.cs index c2f1e8c7..1be22366 100644 --- a/zero.Web/DevServer/PluginResolver.cs +++ b/zero.Web/DevServer/PluginResolver.cs @@ -5,7 +5,7 @@ namespace Zero.Web.DevServer { public class PluginResolver { - protected IEnumerable Plugins { get; set; } + public IEnumerable Plugins { get; set; } public PluginResolver(IEnumerable plugins) diff --git a/zero.Web/DevServer/ZeroDevService.cs b/zero.Web/DevServer/ZeroDevService.cs index 2908897f..7e633975 100644 --- a/zero.Web/DevServer/ZeroDevService.cs +++ b/zero.Web/DevServer/ZeroDevService.cs @@ -97,13 +97,15 @@ namespace Zero.Web.DevServer PidUtils.KillPort((ushort)port, true); // get all plugins which need to be passed to vite - var plugins = new List() + List plugins = new(); + + foreach (var plugin in pluginResolver.Plugins) { - new + if (!String.IsNullOrEmpty(plugin.Options.PluginPath)) { - path = Path.Combine(env.ContentRootPath, "../", "ViteZero.Plugin", "vite.plugin.js") + plugins.Add(plugin.Options.PluginPath); } - }; + } // create and run the vite script ProcessProxy process = new ProcessProxy(workingDirectory, "npm", options.Value.ForwardLog) diff --git a/zero.Web/ZeroVue.cs b/zero.Web/ZeroVue.cs index 31793e4e..b2734387 100644 --- a/zero.Web/ZeroVue.cs +++ b/zero.Web/ZeroVue.cs @@ -256,16 +256,21 @@ namespace zero.Web Dictionary CreateTranslations() { var zeroTranslations = CreateTranslationsForFile("O:/zero/zero.Web/Resources/Localization/zero.en-us.json"); // TODO - var commerceTranslations = CreateTranslationsForFile("O:/zero/zero.Commerce/Resources/Localization/zero.commerce.en-us.json"); - var debugTranslations = CreateTranslationsForFile("O:/Laola/Laola.Backoffice/Resources/laola.en-us.json"); // TODO move into project - foreach (var translation in commerceTranslations) + foreach (IZeroPlugin plugin in Plugins) { - zeroTranslations.Add(translation.Key, translation.Value); - } - foreach (var translation in debugTranslations) - { - zeroTranslations.Add(translation.Key, translation.Value); + if (plugin.Options.LocalizationPaths.Count > 0) + { + foreach (string path in plugin.Options.LocalizationPaths) + { + Dictionary translations = CreateTranslationsForFile(path); + + foreach (var translation in translations) + { + zeroTranslations.Add(translation.Key, translation.Value); + } + } + } } return zeroTranslations;